oklona / Miele-MQTT

A very simple script to read data from Miele@home cloud services, and publish using Mosquitto MQTT
21 stars 10 forks source link

Issue when devices are disconnected #17

Closed Oberchefe closed 3 years ago

Oberchefe commented 3 years ago

I'm using a modified script based on an older version of this Miele-MQTT. Thanks for this script! I just had one issue. In case my Miele devices had problems connecting to the Miele server(Miele App shows "Device not connected"), the script stopped with errors due to the server doesn't send all of the informations used in the script in that case. At the end I added some lines for each device to skip these informations in this case:

switch ($appliance_type) {

    case "Dishwasher":
        If ($programStatusRaw=$appliance['state']['status']['value_raw'] != 255){

existing code here

        }
        else
            {

$programStatus=$appliance['state']['status']['value_localized']; //working also in case not connected $programTypeRaw=''; //not working in case not connected $programPhaseRaw=''; //not working in case not connected .... ... ... }

Based on my experience with devices not connected, only 4 things are working all the time:

$appliance['state']['ProgramID']['value_raw']; $appliance['state']['ProgramID']['value_localized']; $appliance['state']['status']['value_raw']; $appliance['state']['status']['value_localized'];

I hope this helps.

oklona commented 3 years ago

Thank you! This is a very good point. I will make sure to incoroprate this (or something similar) into the script! -But you are basically saying that Status = 255 when it is disconnected? That sounds like a perfect way to check for it! -And if that is the case, we could return "Disconnected" in the MQTT publishings.

Oberchefe commented 3 years ago

as you can see in the official documentation https://www.miele.com/developer/swagger-ui/swagger.html Status 255: NOT_CONNECTED

and this is what I get in this case:

  ["status"]=>
  array(3) {
    ["value_raw"]=>
    int(255)
    ["value_localized"]=>
    string(13) "Not Connected"
    ["key_localized"]=>
    string(5) "State"
  }
oklona commented 3 years ago

Hehe, thanks. I guess I read the documentation before this was even there, and haven't really checked back since :-)

-But this is absolutely perfect! I will add it to the script ASAP!

oklona commented 3 years ago

Tnank you for this suggestion. It has now been added as part of the "Development" branch.