shelly
This commit is contained in:
@@ -181,9 +181,10 @@ async def handle_abstract_set(
|
|||||||
# Transform abstract payload to vendor-specific format
|
# Transform abstract payload to vendor-specific format
|
||||||
vendor_payload = transform_abstract_to_vendor(device_type, device_technology, abstract_payload)
|
vendor_payload = transform_abstract_to_vendor(device_type, device_technology, abstract_payload)
|
||||||
|
|
||||||
# For MAX! thermostats, vendor_payload is a plain string (integer temperature)
|
# For MAX! thermostats and Shelly relays, vendor_payload is a plain string
|
||||||
# For other devices, it's a dict that needs JSON encoding
|
# For other devices, it's a dict that needs JSON encoding
|
||||||
if device_technology == "max" and device_type == "thermostat":
|
if (device_technology == "max" and device_type == "thermostat") or \
|
||||||
|
(device_technology == "shelly" and device_type == "relay"):
|
||||||
vendor_message = vendor_payload # Already a string
|
vendor_message = vendor_payload # Already a string
|
||||||
else:
|
else:
|
||||||
vendor_message = json.dumps(vendor_payload)
|
vendor_message = json.dumps(vendor_payload)
|
||||||
@@ -339,9 +340,21 @@ async def mqtt_worker(config: dict[str, Any], redis_client: aioredis.Redis) -> N
|
|||||||
max_device_type = device["type"]
|
max_device_type = device["type"]
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Check for Shelly relay (also sends plain text)
|
||||||
|
is_shelly_relay = False
|
||||||
|
shelly_device_id = None
|
||||||
|
shelly_device_type = None
|
||||||
|
for device_id, device in devices.items():
|
||||||
|
if device.get("technology") == "shelly" and device.get("type") == "relay":
|
||||||
|
if topic == device["topics"]["state"]:
|
||||||
|
is_shelly_relay = True
|
||||||
|
shelly_device_id = device_id
|
||||||
|
shelly_device_type = device["type"]
|
||||||
|
break
|
||||||
|
|
||||||
# Parse payload based on device technology
|
# Parse payload based on device technology
|
||||||
if is_max_device:
|
if is_max_device or is_shelly_relay:
|
||||||
# MAX! sends plain integer/string, not JSON
|
# MAX! and Shelly send plain text, not JSON
|
||||||
payload = payload_str.strip()
|
payload = payload_str.strip()
|
||||||
else:
|
else:
|
||||||
# All other technologies use JSON
|
# All other technologies use JSON
|
||||||
@@ -377,6 +390,14 @@ async def mqtt_worker(config: dict[str, Any], redis_client: aioredis.Redis) -> N
|
|||||||
client, redis_client, max_device_id, max_device_type,
|
client, redis_client, max_device_id, max_device_type,
|
||||||
device_technology, payload, redis_channel
|
device_technology, payload, redis_channel
|
||||||
)
|
)
|
||||||
|
# For Shelly relay devices, we already identified them above
|
||||||
|
elif is_shelly_relay:
|
||||||
|
device = devices[shelly_device_id]
|
||||||
|
device_technology = device.get("technology", "unknown")
|
||||||
|
await handle_vendor_state(
|
||||||
|
client, redis_client, shelly_device_id, shelly_device_type,
|
||||||
|
device_technology, payload, redis_channel
|
||||||
|
)
|
||||||
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():
|
||||||
|
|||||||
Reference in New Issue
Block a user