updating configuration

This commit is contained in:
monster
2019-02-05 00:41:50 +03:00
parent 4d9b2135e5
commit e5d73db095
10 changed files with 58 additions and 9 deletions
@@ -4,15 +4,16 @@ import globals
class KitchenLedController(hass.Hass):
listen_event_handle_list = []
def initialize(self):
if not globals.check_args(self,['watch_entity', 'topic']):
if not globals.check_args(self,['watch_entity']):
return
self.listen_event_handle_list.append(self.listen_state(self.entity_changed, self.args['watch_entity']))
def entity_changed(self, entity, attribute, old, new, kwargs):
stete = "off"
if new == "off":
stete = "off"
if new == "on":
stete = "on"
self.call_service("mqtt/publish", topic = self.args['topic'], payload = stete)
if 'topic' in self.args:
self.call_service("mqtt/publish", topic = self.args['topic'], payload = new)
if 'control_entity' in self.args:
if new == "on":
self.turn_on(self.args['control_entity'])
if new == "off":
self.turn_off(self.args['control_entity'])