HMIP Cloud Skripting

User stellen ihre Haussteuerung vor

Moderator: Co-Administratoren

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

HMIP Cloud Skripting

Beitrag von Greenberet » 25.06.2017, 00:36

Halle Zusammen,

wie einige schon mitbekommen haben, habe ich vor einiger Zeit begonnen die "Handy Clients" in python nachzuprogrammieren.
Das Ergebnis ist eine doch ziemlich umfangreiche python library. -> https://github.com/coreGreenberet/homematicip-rest-api
Nachdem die Verbindung über die HMIP Cloud funtioniert, kann man die API auf jedem X beliebigen System laufen lassen ohne umwege über NAT/VPN gehen zu müssen.

Hintergrund
Wie ich begonnen hatte die Library zu schreiben waren 2 für mich wichtige Punkte im AP Betrieb nicht möglich
1) eine Statistik der Geräte/Räume (Temperatur, Luftfeuchtigkeit, Fenster Offen/Zu, Stromverbrauch, Schalter Ein/Aus,...)
2) Zeitgesteuertes De/Aktivieren der Schaltsteckdose (geht allerdings seit dem letzten Firmwareupgrade)

Später kam dann noch ein 3ter Punkt hinzu:
3) Ich wollte die Alarmanlage automatisch scharf Schalten für den Fall, dass ich darauf vergesse

homematicip_cli.py
Für demonstationszwecke & simple skripts existiert ein kleines cli tool. Die Hilfe sollte hier schon mal ein paar Vorstellungen bringen was alles möglich ist:

Code: Alles auswählen

usage: homematicip_cli.py [-h] [--debug-level DEBUG_LEVEL] [--list-devices]
                          [--list-groups] [--list-group-ids] [--list-firmware]
                          [--list-events] [--list-last-status-update]
                          [--list-security-journal] [-d DEVICE] [-g GROUP]
                          [--turn-on] [--turn-off]
                          [--set-label DEVICE_NEW_LABEL]
                          [--set-display {actual,setpoint,actual_humidity}]
                          [--enable-router-module] [--disable-router-module]
                          [--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]

a cli wrapper for the homematicip API

optional arguments:
  -h, --help            show this help message and exit
  --debug-level DEBUG_LEVEL
                        the debug level which should get used(Critical=50,
                        DEBUG=10)
  --list-security-journal
                        display the security journal
  -d DEVICE, --device DEVICE
                        the device you want to modify (see "Device Settings")
  -g GROUP, --group GROUP
                        the group you want to modify (see "Group Settings")

Display Configuration:
  --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-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-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

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
Was bringt das alles jetzt genau?
Im Endeffekt kann man nun basierend auf Geäte/Raumstati die einzelnen Geräte steueren
z.b.
  • Wenn die Temperatur vom WTH größer als 25°C ist, dann schalte die Steckdose XYZ ein (da hängt eine Klimaanlage dran)
  • Wenn der Stromverbrauch von der SchaltMessSteckdose > 10W ist, dann schalte eine 2te Steckdose ein
  • Schalte die Steckdosen zu gewissen Zeiten ein/aus (das habe ich über die homematicip_cli und der crontab gelöst)
  • Speichere alle Werte der Geräte in einer Datenbank (Hier mal ein Auszug aus den letzten 2 Wochen für die Luftfeuchtigkeit & den Stromverbrauch)
    Stromverbrauch.png
    Luftfeuchtigkeit.png
  • Beim Auslösen der Alarmanlage führe ein anderes Skript aus/verschicke eine Nachricht via Telegram/Email/SMS/...
Wer jetzt weiterhin behauptet, man kann keine komplexen Programme wie auf der CCU2 schreiben ist somit ein Lügner :twisted:
Homematic IP mit Access Point - Python Modul: Programmieren mit dem Access Point

Antworten

Zurück zu „Projektvorstellungen“