Deadbolt connected via wink attributes

I’ve discovered the following attributes with my deadbolt connected via a wink hub 2.

battery_level: 97
alarm mode: forced_entry
vacation mode: false
beeper mode: false
alarm enabled: true
auto lock: false
alarm sensitivity: medium_low

I’m having a hard time accessing them because of the spaces. Using some help on the forum, I’ve been able to query the battery using this code in a sensor:

value_template: "{{ states.lock.front_door.attributes.battery_level }}"

But, the other values are proving more difficult to query because of the spaces. Is there a way to pad the attributes with underscores or to query these values? I’ve tried to contain the attribute in single quotes without success.

Thanks!

I’m using this for the attributes of my TP-Link Switch in order to read out the power consumption:

sensor:
  - platform: template
    sensors:
      tp_link1_cwatts:
        value_template: '{{ states.switch.kitchenplug.attributes["Current consumption"] | replace(" W", "") | float }}'
        unit_of_measurement: 'W'
        friendly_name: Current Watt (Pump)
      tp_link1_dwatts:
        value_template: '{{ states.switch.kitchenplug.attributes["Daily consumption"] | replace(" kW", "") | float }}'
        unit_of_measurement: 'kW'
        friendly_name: Daily kW (Pump)

I think you can modify it to meet your needs by using something like this - not sure about single ’ and double " quotes, though:

value_template: "{{ states.lock.front_door.attributes["alarm mode"] }}"

This is my fault, when I setup the lock features I didn’t put in the underscores like I did with battery_level. I’ll get that fixed.

That works great. As for the quotes, it could be single quotes outside and double inside.

Thanks!

No worries. It was good to know how to access the attributes as an array.

Thanks!

Somewhat related to this, I have created UI elements for the attributes I was asking to query. The interface works great, except when hass is restarted. Is there some trick to loading a sensors state into an input_boolean/input_select that I’m missing?

I tried doing it at homeassistant.start , but I’m guessing that got called before the wink api had finished loading the values.

Thanks

The values should have been present before homeassistant start was called. I haven’t tried what you are doing though, so I can really help you there.

Finally made it back around to this. I’m having a difficult time with the automation to load the values at hass start.

alias: Home Assistant Start Front Door Lock Alarm Mode
hide_entity: False
trigger:
  platform: homeassistant
  event: start
action:
  - service: input_select.select_option
    data_template:
      entity_id: input_select.front_door_lock_alarm_mode
      option: >
        {% if is_state('sensor.front_door_lock_alarm_mode', 'tamper') %>
          "Tamper"
        {% elif is_state('sensor.front_door_lock_alarm_mode', 'forced_entry') %>
          "Forced Entry"
        {% elif is_state('sensor.front_door_lock_alarm_mode', 'activity') %>
          "Activity"
        {% endif %}

I’m getting the following error when verifying the config:

ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: invalid template (TemplateSyntaxError: unexpected '>') for dictionary value @ data['action'][0]['data_template']['option']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/automation/

Not quite sure what I’m missing other than the option isn’t being filled into the data template and there appears to be some kind of syntax error. Ideas?

Thanks!

Looks like I had a curly brace error at the end of almost each line. Found the template editor in ha.

Thanks.