updating configuration
This commit is contained in:
@@ -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'])
|
||||
@@ -8,3 +8,11 @@ kitchen_led_controller:
|
||||
topic: home/kitchen-led/kitchen-led/state/set
|
||||
global_dependencies:
|
||||
- globals
|
||||
|
||||
bath_led_controller:
|
||||
module: kitchen_led_controller
|
||||
class: KitchenLedController
|
||||
watch_entity: light.bath
|
||||
control_entity: light.philips_led
|
||||
global_dependencies:
|
||||
- globals
|
||||
Reference in New Issue
Block a user