Skip to content

Commit

Permalink
schedule tasks in relay
Browse files Browse the repository at this point in the history
  • Loading branch information
steersbob committed Feb 13, 2024
1 parent 377e5d8 commit 998d1b5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions brewblox_hass/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""


import asyncio
import json
import logging
import re
Expand Down Expand Up @@ -47,7 +48,7 @@ def binary_sensor_state(value: bool):
return 'ON' if value else 'OFF'


def handle_spark_state(message: dict):
async def handle_spark_state(message: dict):
known = CV_KNOWN.get()
publisher = mqtt.CV_HASS.get()
service = message['key']
Expand Down Expand Up @@ -142,7 +143,7 @@ def handle_spark_state(message: dict):
publisher.publish(state_topic, published_state)


def handle_tilt_state(message: dict):
async def handle_tilt_state(message: dict):
known = CV_KNOWN.get()
publisher = mqtt.CV_HASS.get()
service = message['key']
Expand Down Expand Up @@ -206,7 +207,9 @@ async def on_state_message(client, topic, payload, qos, properties):
message = json.loads(payload)

if message['type'] == 'Spark.state':
return handle_spark_state(message)
asyncio.create_task(handle_spark_state(message))
return

if message['type'] == 'Tilt.state':
return handle_tilt_state(message)
asyncio.create_task(handle_tilt_state(message))
return

0 comments on commit 998d1b5

Please sign in to comment.