When you do that is it just verifying that your code is good, or is it comparing to your actual configuration.
Verifies your coding.
@ptdalen I cannot wait to see. Iāve been holding off on implementing the @nalipaz version due to my lack of confidence in translating it over to my instance. By the way @nalipaz I am BLOWN AWAY by what you implemented and think itās amazing. I downloaded your package but have been short on time (we have a newborn at home) so i have not had any chance to really get into the nitty gritty to even attempt an implementation. Itās also more advanced than anything i have done so i have no problem admitting the code in this is above my head.
Anyways, the more simplified version that youāre working on @ptdalen seems exactly what I am looking for at least to start. Just a basic lock manager to start really with the code management.
Also I confirmed that setting the code to ā0000ā actually sets a code of 0000, which works for opening my door.
Iām going to try the setting to a random number route
Current in your code
action:
- service: lock.set_usercode
data_template:
usercode: '0000'
node_id: >-
{% set object_id = trigger.to_state.object_id %}
{% set lock_name = "_".join(object_id.split("_")[3:-1]) %}
{% set lock_id = 'lock_' ~ lock_name ~ '_door_lock' %}
{{ states['lock'][lock_id].attributes.node_id }}
code_slot: >-
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{{ code_slot }}
What I am planning on changing it to
action:
- service: lock.set_usercode
data_template:
usercode: >-
{{ range(1000, 9999) | random }}
node_id: >-
{% set object_id = trigger.to_state.object_id %}
{% set lock_name = "_".join(object_id.split("_")[3:-1]) %}
{% set lock_id = 'lock_' ~ lock_name ~ '_door_lock' %}
{{ states['lock'][lock_id].attributes.node_id }}
code_slot: >-
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{{ code_slot }}
Seems the 0000 clear code issue is with schlage locks and openzwave. The only way I was able to clear my codes, what to change the pin length to 6 and then back to 4. Well that or doing a reset on the deadbold, which i did not want to do.
So I want to get better at understanding how to use the templating menu, but the couple of timeās Iāve tried, it has not worked for me. 100% itās me and not understanding.
For example I want see if I can changed this
condition:
- condition: or
conditions:
- condition: template
value_template: >-
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %}
{{ states['input_select'][select_id].state == 'Always' }}
- condition: template
value_template: >-
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %}
{{ states['input_select'][select_id].state == 'Enabled' }}
into this
value_template: >-
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %}
{{ states['input_select'][select_id].state == 'Always' or states['input_select'][select_id].state == 'Enabled' }}
``
When I paste the bottom bit of code, I get errors about trigger being unidentified, etc. How would I start with something like this?
value_template: >-
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %}
{{ states['input_select'][select_id].state in ['Always', 'Enabled'] }}
So how would I test something like that in the UI template testing area?
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %}
{{ states['input_select'][select_id].state == 'Enabled' }}
This is the bits you put in there to see the output. Youād have to put something into the object_id =
part tho.
Example:
{% set object_id = "lock.lock_front_door_locked" %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %}
{{ states['input_select'][select_id].state == 'Enabled' }}
You canāt with triggers :(. You can fake it out by changing your first line to something that returns an object ID
{% set object_id = xxxxxxxxxxxxxxxxxxxxx.object_id %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %}
{{ states['input_select'][select_id].state in ['Always', 'Enabled'] }}
I have a Kwikset 910, works great.
I have three Schlage Locks. Two BE469, and one FE599. Iāve had them for a couple years. Previously I used them with smartthings, and they worked great. They are working good with HA as well, but of course a bit of work has been required to get some of the functions I missed from Smartthings.
As far as the most important functions to me : Locking and unlocking with HA, they are 99%. I lock any unlocked doors when I go to bed, unlock a door when I get home, etc.
Setting codes is a good feature, but for most people itās something youād only do once in a while. I can get into the UI services and just put in a quick bit of code and set a code super quick without the need for any fancy automation. This is more of cool stuff sort of thing.
Maybe running different automatons based on who unlocked a door is pretty cool too, for the most part I already know who is home based on Presence Sensors.
Another nice thing to remember with most of these, is they are not really ātiedā to any Smart Home system. Even if there is no power, your codes will still unlock the doors. I actually stopped carrying my key about a year ago. Of course I have two doors with smart deadbolts and a dumb code gargage door opener as a failsafe. The odds of all three failing or running out of battery is pretty slim.
Also both the quickset and the schlage do go on sale once in a while. I think I paid $140 ish for mine and normal price was $200
do they require a ācompany loginā and constant internet? Trying to keep my digital footprint small.
No, 100% local. Honeslty, they dont even require any sort of Home automation. codes can be entered 100% via keypad. Thatās how I did mine for the first few months.
OK, So this is one that is new to me, Trying to borrow yaml from other areas
- alias: Keypad set random code for one time use
trigger:
- platform: state
to: 'Enabled'
entity_id:
- input_select.door_keypad_16_access_schedule
- input_select.door_keypad_17_access_schedule
- input_select.door_keypad_18_access_schedule
action:
- service: input_text.set_value
data_template:
entity_id: >-
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
{{ ['input_text'][user_code_id] }}
value: '{{ range(1000, 9999) | random }}'
My intent is for this to populate the input text with a 4 digit number when I select enabled. But nothing is happening. Well the value changes to enabled, but the input_text never gets a value
Might be because I donāt understand how the range works? Or maybe something else is wrong? Any ideas?
I see this error in the log, so Iām thinking its formatting
Invalid service data for input_text.set_value: Entity ID is an invalid entity id for dictionary value @ data[āentity_idā]. Got āā
Edit:
Iām thinking this is the issue??
{% set code_slot = ā".join(object_id.split("ā)[2:-2]) %}
And I finally used the template checker tool in the UI.
This is retuning blank, so thatās my issue, but why?
{% set object_id = 'input_select.door_keypad_16_access_schedule.object_id' %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
{{ ['input_text'][user_code_id] }}
are you sure object_id is a valid attribute? are you trying to get the entity_id? If so:
- alias: Keypad set random code for one time use
trigger:
- platform: state
to: 'Enabled'
entity_id:
- input_select.door_keypad_16_access_schedule
- input_select.door_keypad_17_access_schedule
- input_select.door_keypad_18_access_schedule
action:
- service: input_text.set_value
data_template:
entity_id: >-
{% set object_id = trigger.entity_id %} #This is the entity_id
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
{% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
{{ ['input_text'][user_code_id] }}
value: '{{ range(1000, 9999) | random }}'
EDIT: JUst for your own edification, here is the docās that cover triggers and their attributes. Itās in an odd spot, took me a while to find:
@ptdalen
Try this:
{% set object_id = trigger.to_state.object_id %}
{% set code_slot = "_".join(object_id.split("_")[3:-1]) %}
{% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
{{ ['input_text'][user_code_id] }}
Unfortunatelty, the same results. Iāll keep poking around and see what I find
Iām having troubles getting this to work.
This
{% set object_id = trigger.to_state.entity_id %}
{% set code_slot = "_".join(object_id.split("_")[3:-2]) %}
{% set user_code_id = 'input_text.door_keypad_' ~ code_slot ~ '_code' %}
{{ [user_code_id] }}
receives the following error
Invalid service data for input_text.set_value: Entity ID [āinput_text.door_keypad_16_codeā] is an invalid entity id for dictionary value @ data[āentity_idā]. Got ā[āinput_text.door_keypad_16_codeā]ā and input_text.door_keypad_16_code is what the entity ID I am trying to set a value for.
{% set object_id = 'input_select.door_keypad_16_access_schedule' %}
{% set code_slot = "_".join(object_id.split("_")[3:-2]) %}
{% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
{{ ['input_text'][user_code_id] }}
This returns blank value.
Iāve been playing a lot with the template test section of the UI, but cannot seem to figure it out.
Here is the the entire section
- service: input_text.set_value
data_template:
entity_id: >-
{% set object_id = trigger.to_state.entity_id %}
{% set code_slot = "_".join(object_id.split("_")[3:-2]) %}
{% set user_code_id = 'input_text.door_keypad_' ~ code_slot ~ '_code' %}
{{ [user_code_id] }}
value: '{{ range(1000, 9999) | random }}'