Automation: Trigger when state get an update but NOT changed

Hello
New to HA, I have running openhab for some years but not but dont like openhab2 so i want to try HA.
In openhab you can write a rule that trigger when a state get an update but NOT changed

Is this pobilble in HA ?

I have try many diffrent setting but can not trigger it.
I wnat this because i have some sensor that only sends ‘off’ when it triggerd.

Sensor:

- platform: mqtt
  name: "Door sensor 2"
  state_topic: "rflink/command/03f95e/03"
  payload_on: 'on'
  payload_off: 'off'

I have an simple test automation that work when i send on then off …

- alias: update test
  trigger:
    - platform: state
      entity_id: binary_sensor.sensor_2
      from: 'off'
    # to: 'on'
  action:
      service: persistent_notification.create
      data:
        message:  "Test"

A workaround could be to set it back to ‘on’ when triggerd but i want yo check with you first.
I can also use the mqtt trigger but some sensors dont use mqtt.

Thanks
Andreas H

According to the docs here, the to:/from:/state: lines are optional. Does it work if you skip them?

In case leaving away the from/to does not solve the problem:
A sensor-device that only pushes update-messages without a real state are more comparable to events in HASS. At least as I understand it, the sensors you are using are never on or off, but instead always send off as soon as the sensor does it’s thing. So it has no state that you can query.
If I’m getting that correctly, my personal opinion would be to somehow make the device trigger events in HASS.
This could be done via the RESTful API. If for example you would keep openhab running and have an automation there that fires you custom event via REST, you could then use the Event trigger in HASS to react on that.
Looking at your example the sensors use MQTT. If they could do POST-requests instead without openhab in the middle, it would be even easier.

Hello thanks for your feed back.

I want to retired my openhab totally :slight_smile:

But i have found a solution for this
I move the sensor from binary to “regular” sensor
Then i set this parameter “expire_after” to 2 seconds

After this i can easily trigger my “off” with the automation.

Thanks again

1 Like