HomematicIP Python Library

HMIP Installation - Server im Internet

Moderator: Co-Administratoren

Greenberet
Beiträge: 164
Registriert: 12.01.2017, 23:33
Danksagung erhalten: 4 Mal

HomematicIP Python Library

Beitrag von Greenberet » 23.05.2018, 21:47

Hallo,

einige von euch kennen sie ja bereits, aber dennoch möchte ich sie euch vorstellen.
mit dieser Library ist es möglich die HMIP Cloud direkt anzusprechen.
Es können Werte wie Temperatur (soll/ist), Zustand diverser Schalter ausgelesen bzw. gesetzt werden.

Github: https://github.com/coreGreenberet/homematicip-rest-api

Zusätzlich wird ein kleines CLI Skript mitgeliefert, welches bereits jetzt schon fast alles auslesen und setzen kann.

Code: Alles auswählen

usage: hmip_cli.py [-h] [--config_file CONFIG_FILE]
                   [--debug-level DEBUG_LEVEL] [--version]
                   [--dump-configuration] [--anonymize] [--list-devices]
                   [--list-groups] [--list-group-ids] [--list-firmware]
                   [--list-rssi] [--list-events] [--list-last-status-update]
                   [--list-security-journal] [--list-rules] [-d DEVICE]
                   [-g GROUP] [-r RULES] [--turn-on] [--turn-off]
                   [--set-dim-level DEVICE_DIM_LEVEL]
                   [--set-shutter-level DEVICE_SHUTTER_LEVEL]
                   [--set-shutter-stop] [--set-label DEVICE_NEW_LABEL]
                   [--set-display {actual,setpoint,actual_humidity}]
                   [--enable-router-module] [--disable-router-module]
                   [--reset-energy-counter]
                   [--set-protection-mode {presence,absence,disable}]
                   [--set-pin NEW_PIN] [--delete-pin] [--old-pin OLD_PIN]
                   [--set-zones-device-assignment]
                   [--external-devices EXTERNAL_DEVICES [EXTERNAL_DEVICES ...]]
                   [--internal-devices INTERNAL_DEVICES [INTERNAL_DEVICES ...]]
                   [--activate-absence ACTIVATE_ABSENCE]
                   [--deactivate-absence] [--list-profiles]
                   [--activate-profile GROUP_ACTIVATE_PROFILE]
                   [--set-group-shutter-level GROUP_SHUTTER_LEVEL]
                   [--set-group-shutter-stop]
                   [--set-point-temperature GROUP_SET_POINT_TEMPERATURE]
                   [--set-boost] [--set-boost-stop]
                   [--set-boost-duration GROUP_BOOST_DURATION] [--enable-rule]
                   [--disable-rule]

a cli wrapper for the homematicip API

optional arguments:
  -h, --help            show this help message and exit
  --config_file CONFIG_FILE
                        the configuration file. If nothing is specified the
                        script will search for it.
  --debug-level DEBUG_LEVEL
                        the debug level which should get used(Critical=50,
                        DEBUG=10)
  --version             show program's version number and exit
  --list-security-journal
                        display the security journal
  --list-rules          display all automation rules
  -d DEVICE, --device DEVICE
                        the device you want to modify (see "Device Settings").
                        You can use * to modify all devices or enter the
                        parameter multiple times to modify more devices
  -g GROUP, --group GROUP
                        the group you want to modify (see "Group Settings")
  -r RULES, --rule RULES
                        the automation you want to modify (see "Automation
                        Rule Settings"). You can use * to modify all
                        automations or enter the parameter multiple times to
                        modify more automations

Display Configuration:
  --dump-configuration  dumps the current configuration from the AP
  --anonymize           used together with --dump-configuration to anonymize
                        the output
  --list-devices        list all devices
  --list-groups         list all groups
  --list-group-ids      list all groups and their ids
  --list-firmware       list the firmware of all devices
  --list-rssi           list the reception quality of all devices
  --list-events         prints all the events
  --list-last-status-update
                        prints the last status update of all systems

Device Settings:
  --turn-on             turn the switch on
  --turn-off            turn the switch off
  --set-dim-level DEVICE_DIM_LEVEL
                        set dimmer to level (0..1)
  --set-shutter-level DEVICE_SHUTTER_LEVEL
                        set shutter to level (0..1)
  --set-shutter-stop    stop shutter
  --set-label DEVICE_NEW_LABEL
                        set a new label
  --set-display {actual,setpoint,actual_humidity}
                        set the display mode
  --enable-router-module
                        enables the router module of the device
  --disable-router-module
                        disables the router module of the device
  --reset-energy-counter
                        resets the energy counter

Home Settings:
  --set-protection-mode {presence,absence,disable}
                        set the protection mode
  --set-pin NEW_PIN     set a new pin
  --delete-pin          deletes the pin
  --old-pin OLD_PIN     the current pin. used together with --set-pin or
                        --delete-pin
  --set-zones-device-assignment
                        sets the zones devices assignment
  --external-devices EXTERNAL_DEVICES [EXTERNAL_DEVICES ...]
                        sets the devices for the external zone
  --internal-devices INTERNAL_DEVICES [INTERNAL_DEVICES ...]
                        sets the devices for the internal zone
  --activate-absence ACTIVATE_ABSENCE
                        activates absence for provided amount of minutes
  --deactivate-absence  deactivates absence

Group Settings:
  --list-profiles       displays all profiles for a group
  --activate-profile GROUP_ACTIVATE_PROFILE
                        activates a profile by using its index or its name
  --set-group-shutter-level GROUP_SHUTTER_LEVEL
                        set all shutters in group to level (0..1)
  --set-group-shutter-stop
                        stop all shutters in group
  --set-point-temperature GROUP_SET_POINT_TEMPERATURE
                        sets the temperature for the given group. The group
                        must be of the type "HEATING"
  --set-boost           activates the boost mode for a HEATING group
  --set-boost-stop      deactivates the boost mode for a HEATING group
  --set-boost-duration GROUP_BOOST_DURATION
                        sets the boost duration for a HEATING group in minutes

Automation Rule Settings:
  --enable-rule         activates the automation rules
  --disable-rule        deactivates the automation rules
Einige Beispielskripts gibt es unter https://github.com/coreGreenberet/homematicip-samples

Letzte VERSION: 0.10.6
Zuletzt geändert von Greenberet am 02.03.2019, 22:57, insgesamt 5-mal geändert.
Homematic IP mit Access Point - Python Modul: Programmieren mit dem Access Point

mash4077
Beiträge: 65
Registriert: 26.05.2018, 08:43

Re: HomematicIP Python Library

Beitrag von mash4077 » 26.05.2018, 08:50

Hi,

ich nutze deine Library bereits seit ein paar Wochen u. a. für meine Rollläden (HMIP-BROLL). Jetzt wollte ich meine Schalt- und Messsteckdose schalten und erhalte den folgenden Fehler:

hmip_cli.py --device 3*** --turn-off

2018-05-26 08:46:44,281 - root - ERROR - can't turn on/off device 3*** of type PLUGABLE_SWITCH_MEASURING

(Die ID habe ich durch 3*** ersetzt, weil ich nicht weiß, ob das ein schützenswertes Datum ist)

Was mache ich falsch?

Gruß
mash4077

Greenberet
Beiträge: 164
Registriert: 12.01.2017, 23:33
Danksagung erhalten: 4 Mal

Re: HomematicIP Python Library

Beitrag von Greenberet » 29.05.2018, 13:50

Kann ich so leider nicht nachvollziehen :/

Ich habe es mit meinem HMIP-PSM probiert und bei mir hat sowohl das ein als auch das ausschalten problemlos geklappt.

benutzt du die aktuelle PIP Version (0.9.4) oder die Version von Github?
Homematic IP mit Access Point - Python Modul: Programmieren mit dem Access Point

mash4077
Beiträge: 65
Registriert: 26.05.2018, 08:43

Re: HomematicIP Python Library

Beitrag von mash4077 » 29.05.2018, 21:33

Hi,

C:\***\Python\Python36\Scripts>pip -V
pip 10.0.1 from c:\***\python\python36\lib\site-packages\pip (python 3.6)

Habe ich hier heruntergeladen:
https://www.python.org/downloads/release/python-365/

Greenberet
Beiträge: 164
Registriert: 12.01.2017, 23:33
Danksagung erhalten: 4 Mal

Re: HomematicIP Python Library

Beitrag von Greenberet » 30.05.2018, 15:23

sorry ich meinte die homematicip version die du über pip installiert hast

Code: Alles auswählen

pip show homematicip
Homematic IP mit Access Point - Python Modul: Programmieren mit dem Access Point

mash4077
Beiträge: 65
Registriert: 26.05.2018, 08:43

Re: HomematicIP Python Library

Beitrag von mash4077 » 31.05.2018, 00:09

C:\**\Python36\Scripts>pip show homematicip
Name: homematicip
Version: 0.9.2.3
Summary: An API for the homematicip cloud
Home-page: https://github.com/coreGreenberet/homematicip-rest-api

Okay, habe ich aktualisiert, indem ich die neuen Dateien per Zip-Archiv heruntergeladen habe. Schalten funktioniert jetzt, danke!

Gerade in einem anderen Thread gefunden:
pip install homematicip --upgrade

Alles gut! :-)

Greenberet
Beiträge: 164
Registriert: 12.01.2017, 23:33
Danksagung erhalten: 4 Mal

Re: HomematicIP Python Library

Beitrag von Greenberet » 06.07.2018, 21:36

Version 0.9.7 ist soeben veröffentlicht worden:
Neben Stabilitätsverbesserungen wird jetzt auch der Wassersensor (HMIP-SWD) und der Bewegungsmelder mit 2-Kanal-Funksender (HMIP-SMI55) unterstützt.
Homematic IP mit Access Point - Python Modul: Programmieren mit dem Access Point

Greenberet
Beiträge: 164
Registriert: 12.01.2017, 23:33
Danksagung erhalten: 4 Mal

Re: HomematicIP Python Library

Beitrag von Greenberet » 23.12.2018, 15:44

Version 0.10.0 veröffentlicht
unter anderen werden jetzt die folgenden Geräte unterstützt:
  • HMIP-FDT
  • HMIP-MOD-OC8
  • HMIP-RC8
  • HMIP-SWDM
  • HMIP-SWDM-2
  • HMIP-WRC6
ganzer Changelog
Homematic IP mit Access Point - Python Modul: Programmieren mit dem Access Point

silvermaster
Beiträge: 5
Registriert: 26.12.2018, 14:46

Re: HomematicIP Python Library

Beitrag von silvermaster » 29.12.2018, 13:51

Hallo greenberet,

ich bin in Sachen Python und Homematic IP noch ein echter Newcomer, aber ich habe das Ziel die Ist-Temperator meiner Thermostate und den Status der Ventile auszulesen.

Ich habe bei mir einen Homematic Accesspoint und 9 Thermostate installiert und nutze die Smartphone App.
Über die App sind ja bekanntlich die o.g. Info nicht auslesbar. Über das Forum bin ich uaf deine API gestoßen.

Folgenden Stand habe ich jetzt:
- Ich habe mir Python 3.7.2 installiert.
- danach habe ich pip3 install homematicip ausgeführt
- dann habe ich wie beschrieben das config file für meinen AP erstellt.
- dann habe ich im github die Rest-API als ZIP heruntergeladen
- ich habe die hmip-cli ausgeführt und schaue mir ein paar Infos an

Jetzt ist die Frage:
- Bis jetzt kann ich nur die Infos sehen, die ich auch in der App habe.
- Wie kann ich die Ist Temperatur der Thermostate sehen?
- Wie kann ich den Ventil Statuts sehen? ---> habe ich gefunden valvePosition
- wie kann ich diese extrahieren und sogar in einer APP darstellen?

Update: Über --list-events habe ich herausgefunden, dass es einen Parameter actualTemperature gibt. Allerdings wird der Wert für Räume in denen ich nur einen Thermostaten habe mit (None) angezeigt.

Dann habe ich versucht die API von hier --> https://github.com/coreGreenberet/homem ... sAndValues
in in eine API2 zu kopieren und unter write_heatingthermostat das Argument device.actualTemperature hinzugefügt

Code: Alles auswählen

def write_shutter(room,device):
	print(room, " ", device.label, " ", device.lastStatusUpdate, " ", device.windowState)
	#print(device)

def write_plugableswitchmeasuring(room,device):
	print(room, " ", device.label, " ", device.lastStatusUpdate, " ", device.currentPowerConsumption, " ", device.energyCounter)

def write_heatingthermostat(room,device):
	print(room, " ", device.label, " ", device.lastStatusUpdate, " ", device.actualTemperature)

def write_wallmountedthermostatpro(room,device):
    print(room, " ", device.label, " ", device.lastStatusUpdate, " ", device.actualTemperature, " ", device.setPointTemperature, " ", device.humidity)
Als Fehlermeldung kommt dann, dass das Objekt Heating Thermostat kein Attribut actualTemperature hat.

Kann mir einer erklären wie ich diese Info bekomme?

Vielen Dank für deine Hilfe im voraus!

Grüße
silvermaster

Greenberet
Beiträge: 164
Registriert: 12.01.2017, 23:33
Danksagung erhalten: 4 Mal

Re: HomematicIP Python Library

Beitrag von Greenberet » 30.12.2018, 10:33

Hallo,

über die Cloud bekommen wir leider nicht die Temperatur vom Heizungsthermostaten geliefert =(

Wenn du die Temperatur auslesen willst, dann brauchst du ein Thermometer wie das HMIP-WTH2

lg
Green
Homematic IP mit Access Point - Python Modul: Programmieren mit dem Access Point

Antworten

Zurück zu „HomeMatic IP mit Access Point“