[Neues Modul] Miele@Home

Begonnen von choenig, 14 Juni 2020, 11:08:17

Vorheriges Thema - Nächstes Thema

choenig

Hi,

Das Modul ist seit dem 09.11.2020 ins offizielle FHEM-svn eingecheckt.

im Anhang findet Ihr ein Modul im Beta-Stadium, mit dem Ihr eure Miele@Home-fähigen Geräte in FHEM einbinden könnt (nur monitoring).

Ich habe das Modul bereits vor 6 Monaten geschrieben, und so lange arbeitet es für mich einwandfrei und liest die Informationen meiner Waschmaschine aus der Miele-Cloud aus.

Aktuell werden nur Waschmaschinen unterstützt, da ich nix anderes zur Hand habe. Ich geh' davon aus, dass andere Geräte auch angezeigt werden, jedoch noch nicht alle Readings erzeugt werden (z.B. Kühlschränke). Wenn ihr mich dabei unterstützt, füge ich jedoch gerne weitere Gerätetypen hinzu :).

Das Modul kommuniziert mit der Miele 3rd-Party-Cloud-API, für die Ihr euch zwingend registrieren müsst. Folgende Schritte sind nötig (die in der CommandRef genauer dokumentiert sind):

  • Registrierung für die Miele 3rd-Party-Cloud-API
  • Definieren des MieleAtHome-Connection Devices
  • Setzen der Attribute login und clientId
  • Setzen von password und clientSecret via set
  • Erzeugen der Geräte-Instanzen via set <MY_MieleAtHome_Connection_Device> autocreate

Benutzung des Moduls auf eigene Gefahr!

Aktuelle CommandRef:

MieleAtHome - Controls Miele@home Devices

About

The MieleAtHome module uses the Miele 3rd Party Cloud API. You need a Miele Developer Account to use it! See below for details.
To use the MieleAtHome module you first have to define a device which will act als shared provider for your credentials. When this one is set up, you can use the autocreate-feature to create devices for your appliances.

Miele Developer Account:

To use this module you need to register as a developer at https://www.miele.com/f/com/en/register_api.aspx. After you successfully registered, you will receive a clientId and a clientSecret which you'll need to configure in your <gateway>-device.

Define

(1) Setup gateway:
define <gateway> MieleAtHome

(2a) Autocreate devices:
set <gateway> autocreate

(2b) Manually create devices:
define <MieleDevice> MieleAtHome <DeviceId>@<gateway> [Interval]

Example

(1) Setup gateway:
define MieleConnection MieleAtHome
attr MieleConnection login mylogin@example.com
attr MieleConnection clientId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
set MieleConnection password mypassword
set MieleConnection clientSecret yyyyyyyyyyyyyyyyyyyy

This instance (MieleConnection) will be used to share the credentials. You have to set the attributes login and clientId. Then you have to set password and clientSecret via set MieleConnection-command.

(2a) Autocreate devices:
set MieleConnection autocreate

This will create a device called Miele_xxxxxxxxxxxxx. You can rename autocreated devices afterwards.

(2b) Manually create devices:
define Waschmaschine MieleAtHome 000123456789@MieleConnection 120

This statement creates the instance of your specific Miele@home appliance with the name Waschmaschine and the DeviceId 000123456789 and a refresh-interval of 120 seconds. The interval is optional, its default is 1800 seconds.

Set
autocreate
autocreate fhem-devices for each Miele@home appliance found in your account. Needs login, clientId, password and clientSecret to be configured properly. Only available for the gateway device.
clientSecret <secret>
sets the clientSecret of your Miele@home-developer Account and stores it in a file (base64-encoded if you have MIME::Base64 installed).
light [enable|disable]
enable/disable the light of your device. only available depending on the type and state of your appliance.
on
power up your device. only available depending on the type and state of your appliance.
off
power off your device. only available depending on the type and state of your appliance.
password <pass>
set the password of your Miele@home Account and stores it in a file (base64-encoded if you have MIME::Base64 installed).
pause
pause your device. only available depending on the type and state of your appliance.
start
start your device. only available depending on the type and state of your appliance.
stop
stop your device. only available depending on the type and state of your appliance.
startSuperFreezing
start super freezing your device. only available depending on the type and state of your appliance.
stopSuperFreezing
stop super freezing your device. only available depending on the type and state of your appliance.
startSuperCooling
start super cooling your device. only available depending on the type and state of your appliance.
stopSuperCooling
stop super cooling your device. only available depending on the type and state of your appliance.
update
instantly update all readings.
ventilationStep [Step1|Step2|Step3|Step4]
set the ventilation step of your device. only available depending on the type and state of your appliance.

Get
listDevices
lists the devices associated with your Miele@home-account. Needs login, clientId, password and clientSecret to be configured properly.

Attributes
clientId
set the clientId of your Miele@home-developer account.
login
set the login of your Miele@home account.
disable
disables this MieleAtHome-instance.
lang [de|en]
request the readings in either german or english. en is default.



Changelog
0.5.0

  • first public release
0.6.0

  • implement all processActions as setters

    • START
    • STOP
    • PAUSE
    • START SUPERFREEZING
    • STOP SUPERFREEZING
    • START SUPERCOOLING
    • STOP SUPERCOOLING
0.6.1

  • implement set <DEV> light <enable|disable>
  • implement set <DEV> ventilationStep <Step1|Step2|Step3|Step4>
  • implement set <DEV> startTime <hh:mm>
0.7.0

  • update commandref
0.8.0

  • urlEncode all data sent for oauth2
  • fix warning about $action hiding other variable
0.9.0

  • set default interval to 120s (was 1800s before)
  • fix crash when calling 'autocreate', but the device was not ready, yet (thanks @JoWiemann)
0.10.0

  • (try to) fix initial authorization
  • add attribute country (default is Deutschland/de-DE)
  • extend logging when verbose=5
0.11.0

  • workaround an encoding bug by using german country names instead of localized (thanks @Florie for reporting and @amenomade for the investigation)
0.12.0

  • rename IODev -> IODevName to not interfere with FHEM expecting IODev to contain a HASH
  • enhance renaming of devices
0.13.0

  • fix bug that deleted clientSecret and password from uniqueID when rereadcfg was called
0.14.0

  • fix minor bug that prevented proactive token refresh within the last 24h of validity
  • refresh token using REFRESH_TOKEN after first authorization
0.15.0

  • replace unicode chars with ascii ones in COUNTRIES
1.0.0

  • add ecoFeedback values
  • first official version in FHEM-svn

Viel Spass und LG
Christian

xerion

Hi Christian,

danke für das Modul. Habe das gerade mal installiert und hat auf Anhieb funktioniert. Ich werde das mal parallel zu meiner vorhandenen Installation von meiner Waschmaschine beobachten.
Hast du auch vor die "PUT" Befehle zu integrieren? Da ich das jetzt schon für meine PV-Anlage nutze um die WM anzuschalten.

Danke und Gruß
Frank
Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880

choenig

Hi,

PUT für powerOn und powerOff habe ich bereits implementiert. Den Rest implementiere ich gerne, wenn interesse besteht :)

Das sind in Deinem Fall die 'processActions' START und STOP und PAUSE?

Ich weiss ehrlich gesagt gar nicht mehr, wieso ich die PUTs nicht alle schon implementiert habe.

LG
Christian

xerion

Hi,

oh stimmt habe ich glatt übersehen. Ich nutze nur den Fernstart ({"processAction":1}, diese setzte aber voraus, das die WM entsprechend vorbereitet ist, das Frage ich per DOIF ab.
Aber das könnte ich jetzt ja über remoteEnableFullRC und remoteEnableSmartGrid.

Ideal wäre es natürlich wenn du für den jeweiligen processAction die PreCondoition abfragen könntest und wenn diese nicht True sind, das es einen Fehler gibt wenn man die dazugehörige ProcessAction ausführen möchte. Also in meinen Beispiel den Fernstart wo (fullRemoteControl==true) && (status==4) sein muss.
Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880

LukeSky007

Hi Christian,
hab dein Modul gerade mal auf unsere neue WCI860  losgelassen ... und geht ;-)   - supi - vielen Dank für dein Modul.

Was schön wäre, wenn man die Einstellung von INTERVAL  nachträglich  ändern könnte, so was wie Set <Device> Interval <value>|<default>

Viele Grüße
Luke


FHEM 5.9 RasPi 3B+,  1x HM-MOD-RPI-PCB, 4x HM-LC-BL1-FM, 1x HM-ES-PMSw1-Pl-DN-R1, 3x HM-CC-RT-DN, 5x HM-SEC-SCo, 1x HM-LC-SW1-FM, 1x HM-SEC-MDIR-2, 1x HM-Sen-MDIR-O, 1x HM-WDS40-TH-I-2, ecowitt: GW200X , WS90, 4x WH51

choenig

Hi,

Zitat von: xerion am 15 Juni 2020, 10:28:51
Ideal wäre es natürlich wenn du für den jeweiligen processAction die PreCondoition abfragen könntest und wenn diese nicht True sind, das es einen Fehler gibt wenn man die dazugehörige ProcessAction ausführen möchte. Also in meinen Beispiel den Fernstart wo (fullRemoteControl==true) && (status==4) sein muss.

Das kann ich überprüfen, in dem ich die actions_* readings auslese. Diese entsprechen nämlich den aktuell verfügbaren Aktionen. Das bau ich ein, hab gestern damit angefangen, hab' aber leider nicht so viel Zeit, kommt aber :).

Zitat von: LukeSky007 am 15 Juni 2020, 20:32:22
Was schön wäre, wenn man die Einstellung von INTERVAL  nachträglich  ändern könnte, so was wie Set <Device> Interval <value>|<default>

Du kannst das INTERVAL als parameter im DEF angeben, also

define Waschmaschiene MieleAtHome <DeviceId>@<gateway> [Interval].

Es ist zur Zeit so, dass das eingestellte INTERVAL nur gilt, so lange die WaMa 'Off' ist, sobald sie eingeschaltet ist, wird immer 60s verwendet.

Ich nutz hier zu Hause ein Interval von 120s, das finde ich ziemlich passend. Vielleicht wäre das auch der bessere Default-Wert. Ich weiss jedoch noch nicht, wie sich das ganze bei Kühlschränken verhält, die ja vermutlich immer 'On' sind.

LG
Christian

choenig

Hi,

ich habe gerade Version 0.6.0 hochgeladen. Jetzt werden erstmal alle ProcessActions unterstützt:
0x01 => "start",              # 1 START
0x02 => "stop",               # 2 STOP
0x03 => "pause",              # 3 PAUSE
0x04 => "startSuperFreezing", # 4 START SUPERFREEZING
0x05 => "stopSuperFreezing",  # 5 STOP SUPERFREEZING
0x06 => "startSuperCooling",  # 6 START SUPERCOOLING
0x07 => "stopSuperCooling",   # 7 STOP SUPERCOOLING


LG
Christian

choenig

Ich habe jetzt gerade noch eine 0.6.1 hinterhergeschoben, in der man auch light, ventilationStep und startTime setzen kann.

Das scheint meine WaMa aber nicht zu unterstützen, bitte deshalb um Mithilfe von Benutzern mit entsprechenden Geräten :)

LG
Christian

xerion

#8
Bei mir sieht es jetzt bis dato alles sehr gut aus. Man kann ja die Value in "de" und "en" anzeigen lassen. Was hältst du davon, das als Atribute einzubauen damit man sich die Sprache der Stati auswählen kann?

Ergänzung. Ich war zu schnell. Habe gerade mal im Code geschaut...das hast du ja schon drin. Kannst also meine Anfrage ignorieren.
Tolle Arbeit Danke.
Ich würde mich  freuen, wenn du meinen Einladungscode für Tibber, der Stromanbieter, der dir hilft, deinen Stromverbrauch zu verstehen und zu reduzieren, nutzt: https://invite.tibber.com/5fc08jbs. So bekommen wir beide 50 Euro und 100 % Ökostrom / https://geld-fuer-eauto.de/ref/334561880

choenig

Ich empfehle die commandref, die ich heute übrigens nochmal überarbeitet habe ;)

Danke, für das Feedback :)

LG
Christian

fhemfrederik

#10
Hallo Christian,

habe eine Spülmaschine und bekomme leider immer
MieleConnection (MieleAtHome::MAH_onOauthLoginReply:597) Error: Bearer code not found
zurück. Bei Miele komme ich mit meinen Zugangsdaten rein.

Hast du einen Tipp? Kann es was damit zu tun haben?
1: PERL WARNING: "my" variable $action masks earlier declaration in same scope at ./FHEM/48_MieleAtHome.pm line 1219.

Viele Grüße
Frederik

choenig

Hi Frederik,

Zitat von: fhemfrederik am 21 Juni 2020, 22:15:40
habe eine Spülmaschine und bekomme leider immer
MieleConnection (MieleAtHome::MAH_onOauthLoginReply:597) Error: Bearer code not found
zurück. Bei Miele komme ich mit meinen Zugangsdaten rein.

Mh, habe ich noch nie gesehen. Ich geh davon aus, dass Du login, password, clientId und clientSecret korrekt gesetzt hast? Benutzt du configDB? (Nicht, dass ich glaube, dass es was damit zu tun hat). Hast Du Mime::Base64 installiert? (Was zeigt das Internal HAS_MimeBase64?)

Das muss ich mir mal genauer ansehen.

Zitat von: fhemfrederik am 21 Juni 2020, 22:15:40
1: PERL WARNING: "my" variable $action masks earlier declaration in same scope at ./FHEM/48_MieleAtHome.pm line 1219.

Nein, damit hat es nichts zu tun, den fixe mit dem nächsten Release :).

LG
Christian

choenig

#12
Ich nochmal,

Frederik, siehst Du Dich in der Lage, die 48_MieleAtHome.pm selber anzupassen, oder soll ich dir eine mit mehr logging zur Verfügung stellen?

Wenn Du es kannst, könntest Du vor Zeile 597 folgendes Log einfügen:
MAH_Log($hash, 2, "headers: ${headers}");


Dann nochmal versuchen und gucken, ob im Log 'code=...' vorkommt. Vielleicht sieht der auch anders aus, als von mir erwartet.

Wenn der headers-log keine geheimen Daten enthält, kannst du sie auch gerne posten, oder auch gerne per PM.

LG
Christian

fhemfrederik

#13
Hallo Christian,

HAS_MimeBase64 = 1

Die Zugangsdaten habe ich (mehrmals) aus einem PW-Manager rauskopiert. Bei Miele klappt es. Einen Fehler würde ich ausschließen. Gibt es bei Dir verbotene Sonderzeichen?
ConfigDB habe ich nicht im Einsatz. Nur LogDB!

Hier das Log.

2020.06.21 23:13:38 2: MieleConnection (MieleAtHome::MAH_onOauthLoginReply:597) headers: HTTP/1.1 400 Bad Request
Server: openresty/1.15.8.2
Date: Sun, 21 Jun 2020 21:13:38 GMT
Content-Type: application/json
Content-Length: 45
Connection: close
Strict-Transport-Security: max-age=15724800; includeSubDomains
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: PUT, GET, POST, OPTIONS
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
2020.06.21 23:13:38 2: MieleConnection (MieleAtHome::MAH_onOauthLoginReply:598) Error: Bearer code not found

Bei Miele muss ich übrigens noch "Miele Deutschland" wählen. Die Einstellung habe ich bei Dir nicht gefunden.

Viele Grüße
Frederik

choenig

Ok, das hilft mir nicht. Bad Request. Keine Ahnung, wieso.

Kannst Du verbose mal auf 5 stellen? Dann sehe ich auch den $data-Teil.

Sonst muss ich mich mal genauer in oauth2 einlesen.

> Gibt es bei Dir verbotene Sonderzeichen?

Nein, nicht, dass ich wüsste.

LG
Christian