37 lines
1007 B
Python
37 lines
1007 B
Python
import appdaemon.plugins.hass.hassapi as hass
|
|
|
|
#
|
|
# App to send notification when intercom is ringing
|
|
#
|
|
# Args:
|
|
#
|
|
# notify = notification platform to send notifications to
|
|
# ringtone (optional) = ringtone to play
|
|
#
|
|
# None
|
|
#
|
|
# Release Notes
|
|
#
|
|
# Version 1.0:
|
|
# Initial Version
|
|
|
|
class Intercom(hass.Hass):
|
|
ringtone = 10
|
|
gw_mac = ''
|
|
def initialize(self):
|
|
if "notify" not in self.args:
|
|
self.error("Please provide notify in config!")
|
|
return
|
|
if "gw_mac" in self.args:
|
|
self.gw_mac = self.args['gw_mac']
|
|
|
|
if 'ringtone' in self.args:
|
|
self.ringtone = self.args['ringtone']
|
|
self.listen_event(self.domofon_call, "domofon_call")
|
|
|
|
def domofon_call(self, event_id, event_args, kwargs):
|
|
self.log("domofon_call")
|
|
self.log(event_args)
|
|
self.call_service("xiaomi_aqara/play_ringtone", gw_mac=self.gw_mac, ringtone_id=self.ringtone, ringtone_vol=100)
|
|
self.notify("Звонок в домофон!!!", name = self.args['notify'])
|