I have a Schlage zwave door with 10 slot for codes to open door.
entity: sensor.schlage_allegion_fe599gr_wireless_door_lock_alarm_level_2
values will be 1 through 10. it will be “1” if i use my code. it will be “2” if kid uses her code to open the door.
the problem is that the value is stuck at 2 forever until i use my code. i am curious to know how many times she goes in and out of the house at night.
how can i set the value to 10 or 0 here?
There are no services in Home Assistant to set a sensor’s value because a sensor normally represents data received from a monitoring device.
However, there are ways around it as long as you understand that they can only set the sensor’s value temporarily. Whatever value you set will be overwritten either when the sensor receives new data from the device or when Home Assistant restarts.
Try this:
If you need a service to do it then rodpayne has created a python_script:
im happy to say your first suggestion works great!!! too bad i have to get my hands dirty and use Rodpayne’s python script to get the values change automatic. ideally it would change value to 10 after 1minute if value 2 is received.
i try to do everything via the GUI, even setting up the automations, because im terrifed of coding.
so right now, the value is 10. if it becomes 2, when her code is used to open the door, for two minutes, it should execute to become 10 again.
it didnt
What you described isn’t how the code you wrote works.
You want something like this:
alias: example
trigger: state
platform: state
entity_id: sensor.schlage_allegion_fe599gr_wireless_door_lock_alarm_level_2
to: 2
for: '00:02:00'
action:
service: python_script.set_state
data:
entity_id: sensor.schlage_allegion_fe599gr_wireless_door_lock_alarm_level_2
state: 10
When the sensor’s state changes to 2 and stays that way for 2 minutes, the automation is triggered and its action sets the sensor’s state to 10.
i see why my code didnt work before. after i restarted HA, the value auto load whatever is in a memory…which is a 2, not a 10.
therefore my automation will never ever switch back to a 10.