updating configuration
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import appdaemon.plugins.hass.hassapi as hass
|
||||
import globals
|
||||
|
||||
#
|
||||
# Aqara lock notifications
|
||||
@@ -7,7 +8,7 @@ import appdaemon.plugins.hass.hassapi as hass
|
||||
# Args:
|
||||
# lock_state_entity - entity of aqara lock state
|
||||
# notify - notify entity to send message
|
||||
#
|
||||
#
|
||||
# Release Notes
|
||||
#
|
||||
# Version 1.0:
|
||||
@@ -18,17 +19,17 @@ class AqaraLock(hass.Hass):
|
||||
if 'lock_state_entity' not in self.args or 'notify' not in self.args:
|
||||
self.error("Please provide lock_state_entity and notify in config!")
|
||||
return
|
||||
|
||||
|
||||
lock_state_entity = self.args['lock_state_entity']
|
||||
|
||||
self.log(' [+] listening for lock_state_entity sensor {}'.format(lock_state_entity))
|
||||
self.listen_state(self.sensor_trigger, lock_state_entity)
|
||||
self.listen_state(self.sensor_trigger, lock_state_entity)
|
||||
|
||||
def sensor_trigger(self, entity, attribute, old, new, kwargs):
|
||||
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
|
||||
return
|
||||
|
||||
#(old != "" and old != "unknown") or
|
||||
#(old != "" and old != "unknown") or
|
||||
if new == "unknown" or new == "" or new == "unavailable":
|
||||
self.log('skiping event. {} changed from {} to {}'.format(entity, old, new))
|
||||
return
|
||||
@@ -36,7 +37,7 @@ class AqaraLock(hass.Hass):
|
||||
|
||||
action = new
|
||||
self.process_event(action)
|
||||
|
||||
|
||||
def process_event(self, eventname):
|
||||
if eventname == "ring_bell":
|
||||
self.fire_event('doorbell_call')
|
||||
@@ -51,5 +52,4 @@ class AqaraLock(hass.Hass):
|
||||
self.notify_tg("Неизвестное событие замка: {}".format(eventname))
|
||||
|
||||
def notify_tg(self, msg):
|
||||
extra_data = {'parse_mode': 'html'}
|
||||
self.notify(msg, name = self.args['notify'], data=extra_data)
|
||||
globals.send_telegram(self, msg, target = self.args['notify'])
|
||||
|
||||
Reference in New Issue
Block a user