Differentiating between switch off from HASS and physical button

Hi,

I have a Fibaro FGWP102 Z-Wave plug, into which I’ve connected an electric heater. I have created a climate entity out of that plug and a thermometer.

I have some automations, which turn on the climate device when the room is cold and some other conditions and maintain the temp. I would also like to use the physical button on the plug to start/stop/override the automations. The button is not a separate HASS entity, but rather just turns the switch corresponding to the plug on/off.

I would like to somehow separate the outcome of pressing the button physically from the plug being switched as a result of a trigger in HASS and a Z-wave instruction being issued through an automation. Is that possible?

I’ve tried adding a boolean helper to control the status of the heater (“on” means climate device cycling the plug to maintain temp), as opposed to whether the plug is on/off, but the moment I connect this helper to the physical button, I end up with the heater switching off permanently the moment that the first off instruction is issued, since HASS doesn’t see a difference between my pressing the button and HASS switching it of over Z-Wave.

Show us some code :wink:

An idea:

  • create two (hidden) input_booleans, “intended_state” and “automation_override”.
  • have every automation that controls the heater, change the “intended_state” to reflect if the heater was turned on or off.
  • put in a condition, that runs the automation only when “automation_override” is off.

Now create an automation that triggers when the heater/plug changes it’s state (on or off).
In there, check the “intended_state” boolean if it differs from the actual state (e.g. an automation turned the heater off and the “intended_state” boolean with it. You turn it on again using the physical button → now “intended_state” will still be off while the actual state is “on”).
Use that to activate the “automation_override” boolean → none of the automations will run any actions.

To re-enable automations, turn off the “automation_override” boolean manually.
Or: When the heater is turned on/off and now it’s state matches the “intended_state” again, you can re-enable automations and turn of the “automation_override” boolean.

Sebastian