homeassistant-homeconnect icon indicating copy to clipboard operation
homeassistant-homeconnect copied to clipboard

On/Off switch not in sync

Open Krocko opened this issue 4 years ago • 21 comments

I have a Siemens coffee maker. The attributes are right, but the on/off switch not.

A56EAB67-A696-4F4D-8CF2-F0003993E67D

Krocko avatar Apr 07 '20 05:04 Krocko

Hmm, operation state is "ready" but power state is "off". I assume one of them is wrong. Can you monitor the event stream (e.g. by enabling debug logging) in which order and at what times which of those is reported?

DavidMStraub avatar Apr 10 '20 13:04 DavidMStraub

The power state is wrong. Yes, I will do.

Krocko avatar Apr 10 '20 14:04 Krocko

@DavidMStraub how can I give you the log file?

Krocko avatar Apr 12 '20 11:04 Krocko

If you don't want to host it here because it contains sensitive information, you can send it to me via the e-mail address you can see in the git commits. Otherwise, just post it here or in a Gist.

DavidMStraub avatar Apr 12 '20 11:04 DavidMStraub

Can I send it to the @tum address?

Krocko avatar Apr 12 '20 11:04 Krocko

@DavidMStraub are there any news?

Krocko avatar Apr 20 '20 11:04 Krocko

Hi, I finally had a look at the log file. The power state remains "Standby" all the time. I suspect that the event stream simply doesn't update this setting. Does the switch go to "on" state at all at any point? What happens when you manually switch it "on"?

DavidMStraub avatar May 02 '20 08:05 DavidMStraub

If the coffemaker is on and the switch is off, the switch goes back to off, if I toggle it. If I restart ha then, the switch is on and is in sync for a certain time.

Krocko avatar May 02 '20 10:05 Krocko

Curious. Right now, the pseudo code for determining the power state is as follows,

if PowerState == "on":
    return "on"
if PowerState == "standby":
    return "off"
if OperationState == "ready":
    return "on"

Your problem could probably be fixed by changing the order of the 2nd and 3rd if statement, since your machine reports an updated operation state, but not power state. The problem is that I'm not sure whether this won't screw up any other devices, e.g. if the update their power state but not their operation state.

The best solution would be to check which value was changed most recently, but unfortunately this would require quite some refactoring of the underlying library.

DavidMStraub avatar May 02 '20 10:05 DavidMStraub

I have changed the order in switch.py (from line 142) and will test.

    def update(self):
        """Update the switch's status."""
        if (
            self.device.appliance.status.get("BSH.Common.Setting.PowerState", {}).get(
                "value", None
            )
            == "BSH.Common.EnumType.PowerState.On"
        ):
            self._state = True
        elif self.device.appliance.status.get(
            "BSH.Common.Status.OperationState", {}
        ).get("value", None) in [
            "BSH.Common.EnumType.OperationState.Ready",
            "BSH.Common.EnumType.OperationState.DelayedStart",
            "BSH.Common.EnumType.OperationState.Run",
            "BSH.Common.EnumType.OperationState.Pause",
            "BSH.Common.EnumType.OperationState.ActionRequired",
            "BSH.Common.EnumType.OperationState.Aborting",
            "BSH.Common.EnumType.OperationState.Finished",
        ]:
            self._state = True
        elif (
            self.device.appliance.status.get("BSH.Common.Setting.PowerState", {}).get(
                "value", None
            )
            == self.device.power_off_state
        ):
            self._state = False

Krocko avatar May 02 '20 11:05 Krocko

It was not working.

Krocko avatar May 03 '20 06:05 Krocko

I found out, it is only if I switch the maschine on directly on the maschine. If I switch it on with the home connect app or with ha, the switch state is right. So the problem occurs only if I switch it on with the button on the maschine.

Krocko avatar May 08 '20 07:05 Krocko

Hi @DavidMStraub. I tested the last day and the problem is definitely only if use the button on the maschine. Have you any ideas?

Krocko avatar May 12 '20 07:05 Krocko

Hi @DavidMStraub, I have more appliance connected to home assistant, the problme persist only for caffe maker, and only if I turn ON by the button on the machine like @Krocko reported. See in attached debug log file Button.txt: power on by button (directly from caffe machine) See in attached debug log file homeconnect_app.txt: power on by home connect app. The response by postman is always correct, see log: { "data": { "settings": [ { "key": "BSH.Common.Setting.PowerState", "value": "BSH.Common.EnumType.PowerState.On" } ] } }

Maibe this log can help you to find the problem.

homeconnect_app.txt button.txt

Many Thanks for your job, I'm avalible to made some trobleshotting test.

Reagards Ivan

zufivan avatar Oct 13 '20 15:10 zufivan

In the button.txt, the API reports PowerState.Standby the whole time!

DavidMStraub avatar Oct 13 '20 15:10 DavidMStraub

In the button.txt, the API reports PowerState.Standby the whole time!

Yes I see, I don't know where the integration take this value... the postam response always correct "PowerState.on", I don't know where cache it. Ïf I reboot HomeAssisatnt the intergration home_connect_beta work fine, see log in attacched. button.after_ha_restart.txt

zufivan avatar Oct 13 '20 15:10 zufivan

Oh OK, perhaps the value is fetched initially by get_status and then never updated by the API.

Can you post a log where the actual API response is shown, perhaps using Postman or the homeconnect Python library? What is shown in the HA log is the appliance.status dictionary which is always .update()d by the API response but can also contain "old" values that never change.

DavidMStraub avatar Oct 13 '20 17:10 DavidMStraub

Hi David in attacched debug log (homeassistant core and home_conect_beta) about the turn on caffe machine by button, following the output from postman, look like good: image debug_log.txt

zufivan avatar Oct 14 '20 14:10 zufivan

Hi. Are there any news on this? @DavidMStraub, @badguy99, @Sjack-Sch, @SantaFox can anyone please look into this again?

Krocko avatar Feb 04 '21 07:02 Krocko

To me, this looks like a bug in the firmware of your coffee machine. The messages show LocalControlActive going true, and then back to false. The docs say this will go back to false after a period of time, rather than after an action completing. However OperationState and PowerState never change, even though ProgramProgress is increasing. It may be worth contacting Siemens to see if there is an update that can be applied.

badguy99 avatar Feb 04 '21 18:02 badguy99

I don't think it is a bug in the coffee maker firmware. It is only if i turn on the device directly with the button on the device. If i turn on the device with home assistant or the home connect app it is working. Also if i turn on the device directly with the button on the device, the state in the home connect app is right but not in home assistant. If i restart home assistant after this, the state is also right in home assistant.

Krocko avatar Feb 05 '21 13:02 Krocko