Custom integration/Automation reporting state changes of same value

Hi folks, looking for some assistance with the HA state machine.

I am the author of the BHyve integration which provides a switch entity. The integration connects to the service provider API with a websocket, and on certain events the switch’s state may change. My current logic simply sets the value of the property self._is_on based on the event data received, for example:

if event == "device_idle" or event == "watering_complete":
    self._is_on = False

Separately, I have an automation which notifies me whenever this switch’s state changes. The notification payload looks like:

    message: >
        {{ }} changed ({{ trigger.from_state.state }} : {{ trigger.to_state.state }})

I often receive notifications with the following payload: Switch changed (False : False), which indicates that the Switch’s state has changed value, but to the same value. My integration does not override the force_update prop.

I’m not clear if this is an error in my Integration or Automation. Is anybody able to give me any tips at what might be going wrong?


I’m assuming you’re using a state trigger with no to: or from: in the automation. If that’s the case, it will trigger every time the entity’s state or one of its state attributes changes. You could add a template condition checking that the to and from state don’t equal each other to work around this.

Ah yes, thank you @Tediore - indeed do not have a to: or from: property set:

    - entity_id: switch.backyard_zone
      platform: state

Many of the updates would include a change to the state attributes, which explains this behaviour. Thanks for the help!!

1 Like