I hear you. I had never heard of YAML when I started messing with HA last year.
Bottom line, the YAML provided does not do what you asked, but it would not take much work to get what you want. If your goal is just to turn off a security system though, then this is probably overkill. The foundations for what you want are in there though.
Basically you need a trigger. A trigger is what starts the automation
So in this case
trigger:
- platform: state
entity_id: lock.front_door
from: 'locked'
to: 'unlocked'
then you need a condition and that condition is your code slot
Not tested but something like this should work
then your action will be whatever you want to happen, in your case disarm your system. Iāll say if you search the forums youāll find many examples of doing similiar things that youāll be able to adjust to fit your needs. Good luck
I did have to correct 3 lines in the common lock yaml to match my lock names. My primary issue was that I had configured my uptime sensor incorrectly, and I was completely missing a time_date sensor.
The one time use code uses the uptime sensor as a condition and the google calendar code uses the time_date sensor.
Figured it out and Iām working great now. Thanks again for your hard work and for your help.
Edit: The only odd thing Iāve noticed, is that if I schedule a code for say 4 PM, it doesnāt activate until about 4:04 - 4:08. Are you seeing this type of behavior also, or am I having a possible timing issue?
I have seen issues with google calendar. I believe it only updates once every 5 min. But Iāve personally not had issues when the calendar event was in a 5 min increment. Such as 5:05am vs 5:04am.
Glad you got it āmostlyā working. I did use input date times on my initial implementation and they worked on a per minute basis. But was not nearly as flexible as the calendar.
Its giving no reaction, and it may be due to the way its being created via the automations interface in HA. this is the resultant yaml, minus the action section. I feel like its borking the code somehow.
- id: '#############'
alias: Disarm Security System on Coded Door Unlock
description: ''
trigger:
- entity_id: lock.front_door_lock_locked
from: locked
platform: state
to: unlocked
condition:
- condition: template
value_template: '{{ ''user 1'' in states.lock.front_door.attributes.lock_status
| lower }}'
hahā¦ I didnāt even notice the wrong name in the condition. My error thereā¦ Iāve done coding, logic, and other assundry, should have spotted that. oh wellā¦ Iāll fix and see what goes.
couple questionsā¦ the user 1 variable. is that the name iāve assigned that slot in your lock manager? or is that coming from the lock itself? what is the ā| lowerā doing?
These codes were set manually on the lock itself. But with a lock manager on Smartthings I was able to see which user unlocked the door with the name I set in that ST smartapp. I have added the code and name to your lock manager. Does it force set those the moment I do that?
value_template: '{{ ''user 1'' in states.lock.front_door_lock.attributes.lock_status | lower }}'
Home assistant reports user 1 (or 2 or 3) in that attribute natively. It does not know who is who
Lower just ensures that regardless of the text that comes out fro HA that the value for the condition will be lower case. Saves you from having to worry about case
The info I provided has nothing to do with my yaml colde for lock manager.
looking at the .lock_status I have a long text line in the value. is the IN states search for the āuser 1ā string in the data stored in that value?
So I have been using the old setup for awhile now, other than the user code/google calendar stuff (and I donāt really use scheduled codes) that changed is there any other reasons Iād want to update?
Been working awesome by the way, thanks for your time!
No reason at all. Really just shortened the lock and sensor names, added google calendar, and made the lovelace a little more āresponsiveā, but the core functionalty has not changed. Thanks for the kind words
Hey @ptdalen it looks like pyozw was updated to 0.1.7. I was going to fork this myself but Iām not sure what you mean by āHA open-zwaveā can you send a link to the GitHub that needs to be cloned or is this now fixed in 0.1.7 and no patch necessary?
If I understand this correctly, pyozw is just a wrapper for Open Zwave. About a year or so ago, HA forked Open Zwave to include a few fixes that had not been merged into the Open Zwave. For the most part HA is very close to the 1.4 version of Open Zwave. Version 1.5 is the dev branch, and 1.6 is what will be the next release version of open zwave.
The user_code.cpp is from Open Zwave, not the wrapper.
Thereās a section in common_lock I was curious about:
# this is where usercodes get deleted, for the Schlage locks there seems to be an issue with
# clear usercode, so this sets a random code, of course that means there is an unknown code in the cleared
# slots. If you dont like that set a specific code that only you know
action:
#front Door Lock
- service: lock.set_usercode
data_template:
usercode: >-
{{ range(1000, 9999) | random }}
node_id: >-
{{ states.lock.front_door.attributes.node_id }}
code_slot: >-
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = object_id[7:-19] %}
{{ code_slot }}
Yeah, I assume that either would work. Also you are correct that this is the only place itās used. You could even put in the actual node id since itās only referenced once. Thatās actually how i used to do it when I first started. I think the thought was that if I ever wanted to use this elsewhere it would be easier.
edit: I used to have this all in one package, but some people did not care to have to remove all the extra yaml if they only had one or two locks, so I tried to separate it out as much as possible. The node_id is used in each individual lock package as well. It actually used 4 or 5 times in the individual lock packages
Ah got it; (again very new at this) looks like the service ālock.set_usercodeā needs a node_id, code_slot, and usercode. code_slot and usercode are set dynamically with a template. Previously you had hardcoded the node_id but the new version uses the state attribute to pull the node_id instead. This way if you ever re-configure your zwave network and your locks end up in different nodes nothing needs to change with your door locks code.