deactivate cause
This commit is contained in:
@@ -24,12 +24,9 @@ class Button(Mqtt):
|
|||||||
self.log(f'"{topic}" controls app {self.app.name}')
|
self.log(f'"{topic}" controls app {self.app.name}')
|
||||||
|
|
||||||
async def handle_button(self, event_name, data, kwargs):
|
async def handle_button(self, event_name, data, kwargs):
|
||||||
topic = data['topic']
|
|
||||||
# self.log(f'Button event for: {topic}')
|
|
||||||
try:
|
try:
|
||||||
payload = json.loads(data['payload'])
|
payload = json.loads(data['payload'])
|
||||||
action = payload['action']
|
action = payload['action']
|
||||||
button = kwargs['button']
|
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
self.log(f'Error decoding JSON from {data["payload"]}', level='ERROR')
|
self.log(f'Error decoding JSON from {data["payload"]}', level='ERROR')
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
@@ -44,7 +41,7 @@ class Button(Mqtt):
|
|||||||
cause = 'button single click'
|
cause = 'button single click'
|
||||||
state = await self.get_state(entity_id=self.args['ref_entity'])
|
state = await self.get_state(entity_id=self.args['ref_entity'])
|
||||||
if state == 'on':
|
if state == 'on':
|
||||||
self.app.deactivate(cause=cause)
|
self.app.deactivate(entity='', kwargs={'cause': cause})
|
||||||
else:
|
else:
|
||||||
await self.app.activate(cause=cause)
|
await self.app.activate(cause=cause)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user