some new automations

This commit is contained in:
Your Name
2019-11-07 12:36:14 +03:00
parent 7a32cb74da
commit a00aaba52b
116 changed files with 6720 additions and 126 deletions
@@ -0,0 +1,29 @@
import appdaemon.plugins.hass.hassapi as hass
#
# Listen for homekit presence
#
# Args:
# sensor - home presence 'sensor'
# ha_panel - alarm control panel entity (to arm and disarm).
# constraint - (optional, input_boolen), if turned off - alarm panel will be not armed\disarmed.
#
# Release Notes
#
# Version 1.0:
# Initial Version
class HomekitPresense(hass.Hass):
def initialize(self):
if "sensor" not in self.args or "arrive_event" not in self.args or "leave_event" not in self.args:
self.error("Please provide sensor, arrive_event, leave_event in config!")
return
self.listen_state(self.sensor_trigger, self.args['sensor'])
def sensor_trigger(self, entity, attribute, old, new, kwargs):
if new == "on" and old == "off":
self.fire_event(self.args['arrive_event'])
elif new == "off" and old == "on":
self.fire_event(self.args['leave_event'])
self.log("{} turned {}".format(entity, new))
self.notify("{} turned {}".format(entity, new), name = self.args['notify'])