Skip to content

Commit

Permalink
removed "button call" and opt to wait for HA MQTT performance boost t…
Browse files Browse the repository at this point in the history
…o update sensor faster. make a Schlage tweak
  • Loading branch information
FutureTense committed Dec 2, 2020
1 parent db250d4 commit 6038b61
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 63 deletions.
2 changes: 1 addition & 1 deletion custom_components/lock-manager/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DOMAIN = "lock-manager"
VERSION = "0.0.42"
VERSION = "0.0.43"
ISSUE_URL = "https://github.com/FutureTense/lock-manager"
PLATFORM = "sensor"
ZWAVE_NETWORK = "zwave_network"
Expand Down
15 changes: 8 additions & 7 deletions custom_components/lock-manager/lock_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ automation:
- platform: state
entity_id: "binary_sensor.pin_synched_LOCKNAME_TEMPLATENUM"
to: 'off'
- platform: time_pattern
seconds: "/5"
- platform: state
entity_id: "sensor.LOCKNAME_code_slot_TEMPLATENUM"
condition:
- condition: state
entity_id: "binary_sensor.allow_automation"
Expand Down Expand Up @@ -252,16 +252,17 @@ automation:
{{ USINGOZW }}
# this comment preserves formating
sequence:
# a fake call to clear a non existent slot seems to fix a non clearing call on Schlage
- service: ozw.clear_usercode
data_template:
entity_id: LOCKENTITYNAME
code_slot: >-
{{ 999 }}
- service: ozw.clear_usercode
data_template:
entity_id: LOCKENTITYNAME
code_slot: >-
{{ TEMPLATENUM }}
# #Debug for flaky clear
# - service: persistent_notification.create
# data_template:
# title: Slot TEMPLATENUM
# message: 'ozw clear_usercode called'
- conditions: >
{{ USINGOZW == False }}
# this comment preserves formating
Expand Down
53 changes: 1 addition & 52 deletions custom_components/lock-manager/lock_manager_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -400,58 +400,7 @@ automation:
title: CASE_LOCK_NAME
message: "Opened"

# - alias: CASE_LOCK_NAME Add Code
# trigger:
# entity_id: ACTIVELOCKHEADER
# platform: state
# to: "on"
# condition:
# - condition: state
# entity_id: "binary_sensor.allow_automation"
# state: "on"
# action:
# - choose:
# - conditions: >
# {{ USINGOZW }}
# # this comment preserves formating
# sequence:
# - service: ozw.set_usercode
# data_template:
# entity_id: LOCKENTITYNAME
# code_slot: >-
# {% set object_id = trigger.to_state.object_id %}
# {% set index = object_id.rfind('_') + 1 %}
# {% set code_slot = object_id[index:] %}
# {{ code_slot }}
# usercode: >-
# {% set object_id = trigger.to_state.object_id %}
# {% set index = object_id.rfind('_') + 1 %}
# {% set code_slot = object_id[index:] %}
# {% set codetext = 'LOCKNAME_pin_' + code_slot | string %}
# {% set code = states['input_text'][codetext].state %}
# {{ code | string }}
# - conditions: >
# {{ USINGOZW == False }}
# # this comment preserves formating
# sequence:
# - service: lock.set_usercode
# data_template:
# node_id: >-
# {{ state_attr('LOCKENTITYNAME','node_id') }}
# code_slot: >-
# {% set object_id = trigger.to_state.object_id %}
# {% set index = object_id.rfind('_') + 1 %}
# {% set code_slot = object_id[index:] %}
# {{ code_slot }}
# usercode: >-
# {% set object_id = trigger.to_state.object_id %}
# {% set index = object_id.rfind('_') + 1 %}
# {% set code_slot = object_id[index:] %}
# {% set codetext = 'LOCKNAME_pin_' + code_slot | string %}
# {% set code = states['input_text'][codetext].state %}
# {{ code | string }}

- alias: CASE_LOCK_NAME Update Code
- alias: CASE_LOCK_NAME Changed Code
trigger:
entity_id: INPUTLOCKPINHEADER
platform: state
Expand Down
8 changes: 5 additions & 3 deletions custom_components/lock-manager/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def __init__(self, hass, config):
self._lockname = config.get(CONF_LOCK_NAME)
self._data = None

self.update = Throttle(timedelta(seconds=60))(self.update)
# sensor refresh interval
self.update = Throttle(timedelta(seconds=1))(self.update)

async def update(self):
"""Get the latest data"""
Expand All @@ -59,8 +60,9 @@ async def update(self):
# data["node_id"] = _get_node_id(self._hass, self._entity_id)
data[ATTR_NODE_ID] = self._get_node_id()

servicedata = {"entity_id": self._entity_id}
await self._hass.services.async_call(DOMAIN, SERVICE_REFRESH_CODES, servicedata)
# # make button call
# servicedata = {"entity_id": self._entity_id}
# await self._hass.services.async_call(DOMAIN, SERVICE_REFRESH_CODES, servicedata)

# pull the codes for ozw
if OZW_DOMAIN in self._hass.data:
Expand Down

0 comments on commit 6038b61

Please sign in to comment.