Lock Sensors and bubble magic

I have a kwikset deadbolt and I have the lock and unlock commands working on the home screen.
Although, when you unlock the lock manually, it does not display the correct state on the toggle switch.

So I noticed,
lock.kwikset_touchpad_electronic_deadbolt_locked_10_0 is the state which is locked

sensor.kwikset_touchpad_electronic_deadbolt_alarm_type_10_0 = 22
which means locked and 21 means unlocked.

What I would like to have:
the toggle on the homescreen of HA when the sensor state is 22 the toggle is switched to the locked position and vice versa with 21 and the toggle still unlocks/locks the deadbolt. Is this possible?

or what I could live with:
a way to change the sensor bubble sensor.kwikset_touchpad_electronic_deadbolt_alarm_type to locked instead of 22.

Try a template sensor:

Add the below to your sensor config file:

laptop:
value_template: ‘{% if is_state(“sensor.kwikset_touchpad_electronic_deadbolt_alarm_type”, “22”) %}Locked{% else %}Unlocked{% endif %}’

That will give you a new template sensor. Add the new template sensor to your front end and it should display locked/unlocked

thanks.

could I also use automation?

automation:

  • trigger:
    platform: state
    entity_id: sensor.kwikset_touchpad_electronic_deadbolt_alarm_type
    to: ‘22’
    action:
    platform: state
    entity_id: lock.kwikset_touchpad_electronic_deadbolt_locked_10_0
    to: ‘locked’

Not to my knowledge.

You can try something like this:

automation:
trigger:
  platform: state
  entity_id: sensor.kwikset_touchpad_electronic_deadbolt_alarm_type
  state: '22'
action:
  service: lock.lock
  entity_id: lock.kwikset_touchpad_electronic_deadbolt_locked_10_0

You will want to use a template sensor:

- platform: template
  sensors:
  bdlockstatus:
    friendly_name: 'Back Door'
    value_template: >
        {% if is_state('sensor.back_door_alarm_type_2_0', '21') or is_state('sensor.back_door_access_control_2_9', '1') %}
            locked manually
        {%  elif is_state('sensor.back_door_alarm_type_2_0', '22') or is_state('sensor.back_door_access_control_2_9', '2') %}
            unlocked manually
        {%  elif is_state('sensor.back_door_alarm_type_2_0', '18') or is_state('sensor.back_door_access_control_2_9', '5')%}
            locked with keypad
        {%  elif is_state('sensor.back_door_alarm_type_2_0', '19') or is_state('sensor.back_door_access_control_2_9', '6') %}
            unlocked with keypad
        {%  elif is_state('sensor.back_door_alarm_type_2_0', '0') and is_state('lock.back_door__2_0', 'locked') %}
            locked with Home Assistant
        {%  elif is_state('sensor.back_door_alarm_type_2_0', '0') and is_state('lock.back_door__2_0', 'unlocked') %}
            unlocked with Home Assistant
        {% else %}
            {{ states.sensor.bdlockstatus.state }}
        {% endif %}

Automations will not set the state of the lock. You could use something like this:

- alias: Back Door Locked With Keypad
  trigger:
    - platform: state
      entity_id: sensor.kwikset_touchpad_electronic_deadbolt_access_control_10
      from: '2'
      to: '5'
    - platform: state
      entity_id: sensor.kwikset_touchpad_electronic_deadbolt_alarm_type_10
      from: '22'
      to: '18'
  action:
    - service: lock.unlock
      entity_id: lock.garage_door_locked_11_0

See:
Splitting Up the Configuration
Templating

1 Like

Got the sensors to work. Now trying the automation…

 kwikset_touchpad_electronic_deadbolt_alarm_type1:
    friendly_name: 'outhouse bolt'
    value_template: >
        {% if is_state("sensor.kwikset_touchpad_electronic_deadbolt_alarm_type_10_0", "24") %}
            locked with Home Assistant
        {%  elif is_state("sensor.kwikset_touchpad_electronic_deadbolt_alarm_type_10_0", "25") %}
            unlocked with Home Assistant
        {%  elif is_state("sensor.kwikset_touchpad_electronic_deadbolt_alarm_type_10_0", "21") %}
            locked manually
        {%  elif is_state("sensor.kwikset_touchpad_electronic_deadbolt_alarm_type_10_0", "22") %}
            lock manually
        {% else %}
            unknown
        {% endif %}

got the automation to work

  • alias: ‘Sync Lock/Unlock State outhouse’
    trigger:
    platform: state
    entity_id: sensor.kwikset_touchpad_electronic_deadbolt_alarm_type_10_0
    action:
    service_template: >
    {%- if ( (trigger.to_state.state == “22”) or
    (trigger.to_state.state == “25”) )
    -%}
    lock.unlock
    {%- else -%}
    lock.lock
    {% endif %}
    entity_id: lock.kwikset_touchpad_electronic_deadbolt_locked_10_0