fix in layout, drop test entry

This commit is contained in:
2025-11-11 10:28:27 +01:00
parent cc3c15078c
commit 6a5f814cb4
2 changed files with 39 additions and 5 deletions

View File

@@ -341,6 +341,42 @@ def _transform_relay_zigbee2mqtt_to_abstract(payload: dict[str, Any]) -> dict[st
return abstract_payload
# ============================================================================
# HANDLER FUNCTIONS: relay - shelly technology
# ============================================================================
def _transform_relay_shelly_to_vendor(payload: dict[str, Any]) -> str:
"""Transform abstract relay payload to Shelly format.
Shelly expects plain text 'on' or 'off' (not JSON).
- power: 'on'/'off' -> 'on'/'off' (plain string)
Example:
- Abstract: {'power': 'on'}
- Shelly: 'on'
"""
power = payload.get("power", "off")
return power
def _transform_relay_shelly_to_abstract(payload: str) -> dict[str, Any]:
"""Transform Shelly relay payload to abstract format.
Shelly sends plain text 'on' or 'off' (not JSON).
- 'on'/'off' -> power: 'on'/'off'
Example:
- Shelly: 'on'
- Abstract: {'power': 'on'}
"""
# Shelly payload is a plain string, not a dict
if isinstance(payload, str):
return {"power": payload.strip()}
# Fallback if it's already a dict (shouldn't happen)
return payload
# ============================================================================
# HANDLER FUNCTIONS: max technology (Homegear MAX!)
# ============================================================================
@@ -458,6 +494,8 @@ TRANSFORM_HANDLERS: dict[tuple[str, str, str], TransformHandler] = {
# Relay transformations
("relay", "zigbee2mqtt", "to_vendor"): _transform_relay_zigbee2mqtt_to_vendor,
("relay", "zigbee2mqtt", "to_abstract"): _transform_relay_zigbee2mqtt_to_abstract,
("relay", "shelly", "to_vendor"): _transform_relay_shelly_to_vendor,
("relay", "shelly", "to_abstract"): _transform_relay_shelly_to_abstract,
}

View File

@@ -56,17 +56,13 @@ rooms:
icon: 🌡️
rank: 95
- device_id: kontakt_esszimmer_strasse_rechts
title: Kontakt Straße rechts
title: Kontakt Straße rechtsFtest
icon: 🪟
rank: 96
- device_id: kontakt_esszimmer_strasse_links
title: Kontakt Straße links
icon: 🪟
rank: 97
- device_id: test_relay_1
title: Test Relay 1
icon:
rank: 98
- name: Wohnzimmer
devices:
- device_id: lampe_naehtischchen_wohnzimmer