refactored 7
This commit is contained in:
@@ -330,36 +330,36 @@ async def mqtt_worker(config: dict[str, Any], redis_client: aioredis.Redis) -> N
|
|||||||
retain = getattr(message, 'retain', None)
|
retain = getattr(message, 'retain', None)
|
||||||
logger.debug(f"MQTT message received on ({retain=}) {topic}: {payload_str}")
|
logger.debug(f"MQTT message received on ({retain=}) {topic}: {payload_str}")
|
||||||
|
|
||||||
# # Check if this is an abstract SET message
|
# Check if this is an abstract SET message
|
||||||
# if topic.startswith("home/") and topic.endswith("/set"):
|
if topic.startswith("home/") and topic.endswith("/set"):
|
||||||
#
|
|
||||||
# payload = json.loads(payload_str)
|
payload = json.loads(payload_str)
|
||||||
#
|
|
||||||
# # Extract device_type and device_id from topic
|
# Extract device_type and device_id from topic
|
||||||
# parts = topic.split("/")
|
parts = topic.split("/")
|
||||||
# if len(parts) == 4: # home/<type>/<id>/set
|
if len(parts) == 4: # home/<type>/<id>/set
|
||||||
# device_type = parts[1]
|
device_type = parts[1]
|
||||||
# device_id = parts[2]
|
device_id = parts[2]
|
||||||
#
|
|
||||||
# if device_id in devices:
|
if device_id in devices:
|
||||||
# device = devices[device_id]
|
device = devices[device_id]
|
||||||
# vendor_topic = device["topics"]["set"]
|
vendor_topic = device["topics"]["set"]
|
||||||
# device_technology = device.get("technology", "unknown")
|
device_technology = device.get("technology", "unknown")
|
||||||
# await handle_abstract_set(
|
await handle_abstract_set(
|
||||||
# client, device_id, device_type, device_technology, vendor_topic, payload
|
client, device_id, device_type, device_technology, vendor_topic, payload
|
||||||
# )
|
)
|
||||||
#
|
|
||||||
# # Check if this is a vendor STATE message
|
# Check if this is a vendor STATE message
|
||||||
# else:
|
else:
|
||||||
# # Find device by vendor state topic for other technologies
|
# Find device by vendor state topic for other technologies
|
||||||
# for device_id, device in devices.items():
|
for device_id, device in devices.items():
|
||||||
# if topic == device["topics"]["state"]:
|
if topic == device["topics"]["state"]:
|
||||||
# device_technology = device.get("technology", "unknown")
|
device_technology = device.get("technology", "unknown")
|
||||||
# await handle_vendor_state(
|
await handle_vendor_state(
|
||||||
# client, redis_client, device_id, device["type"],
|
client, redis_client, device_id, device["type"],
|
||||||
# device_technology, payload_str, redis_channel
|
device_technology, payload_str, redis_channel
|
||||||
# )
|
)
|
||||||
# break
|
break
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
logger.error(f"Failed to decode JSON payload on topic {topic}: {payload_str}")
|
logger.error(f"Failed to decode JSON payload on topic {topic}: {payload_str}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user