How to overide and set a numeric value?

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?


once i know how, then i can write an automation to set code to 10 after 1 minute

This is a sensor:

sensor.schlage_allegion_fe599gr_wireless_door_lock_alarm_level_2

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:
Screenshot from 2020-11-23 13-32-36

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.

i was able to get it working after playing around with the syntax. lol
thanks again

An automation can do that. Let me know if you need help to create it.

i thought this automation would work but it didnt

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 :frowning:

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 thought i could cut corners to save coding, because then I would have to create more trigger for value 1 and value 3…

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.