How to force a status?

In the developer menu in able to manual force a status of a sensor in the menu “Current Entity” > Status Attribute. I change the “last_action: vibrate” TO “last_action: Idle” using the button “Set Status”

But how can i create an automation that do the same automatically?

Thanks for the support

You can’t

Sensors report a status, the developer tools menu is for testing.

Well technically you can, either calling a Python script from your automation or by using a more powerful automation system like pyscript, which can directly access and modify states.

Doing this comes with a number of gotchas and caveats though, because you short circuit parts of the HA state machine. Sometimes this is exactly what you want (and the only way to do certain things). But it can have unintended side effects. Use at your own risk. You should probably think about if you really need to do this first. Usually you don’t and there are better ways.

Thanks for the feedback.
The issue is the follow: This sensor, vibration sensor, has an attribute “last_state” that assume 3 status: null, vibrate, tilt. The notification work only the first time (from null to vibrate, or from null to tilt, or from vibrate to tilt and viceverse)…but if there are 3 vibrate event, the variable keep the same value and the notification is not generated… Any idea?

In other words, it is much more common just to find out, how your sensor will report the correct status and if the goal, you are chasing is actually logic… :wink:

1 Like

Then you need to find a way to reset the sensor it self to null after it happens :wink:

Post the automation you are using.


You might be interested in this blueprint:

  • id: ‘000000000’
    alias: Vibration/Tilt Sensor
    description: ‘’
    • platform: state
      entity_id: binary_sensor.vibration_ID
      attribute: last_action
      to: vibrate
    • platform: state
      entity_id: binary_sensor.vibration_ID
      attribute: last_action
      to: tilt
      condition: []
    • service:
      message: Vibration/Tilt Sensor attivato
      title: ‘ALERT: Vibration/Tilt Sensor attivato’
      mode: single

I have red also this discussion but i dont see the solution:

I’m not sure what you’ll find, but I have an idea: Trigger on the “raw” events. It is possible that in the underlying event bus there are three events, but if the state that it affects is already in the right state, there is no subsequent state trigger.

You will need to monitor the event bus from just before the state changes the first time to see what the event type and other fields are to build the correct trigger.

There’s nothing you can (should) do to manipulate a sensor’s state. There van be many undesired side effects.

Also, please remember to format any code or logs properly on the forum.

Your automation is using a State Trigger that listens for changes to the binary_sensor’s last_action attribute. The attribute’s value has to change to vibrate in order for the State Trigger to be triggered. It has to change from some other value to vibrate in order to cause a trigger.

You want it to trigger when it receives consecutive vibrate values and that’s not possible with a State Trigger. You might be able to achieve your goal with an Event Trigger.