Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
bcfc967460
|
|||
|
bd1f3bc8c9
|
|||
|
f9df70cf68
|
43
apps/abstraction/vendors/hottis_pv_modbus.py
vendored
43
apps/abstraction/vendors/hottis_pv_modbus.py
vendored
@@ -23,17 +23,40 @@ def transform_relay_to_vendor(payload: dict[str, Any]) -> str:
|
|||||||
def transform_relay_to_abstract(payload: str) -> dict[str, Any]:
|
def transform_relay_to_abstract(payload: str) -> dict[str, Any]:
|
||||||
"""Transform Hottis Modbus relay payload to abstract format.
|
"""Transform Hottis Modbus relay payload to abstract format.
|
||||||
|
|
||||||
Hottis Modbus sends JSON like:
|
Hottis Modbus sends plain text 'on' or 'off'.
|
||||||
{"status": "Ok", "timestamp": "...", "state": false, "cnt": 528}
|
Example:
|
||||||
|
- Hottis PV Modbus: 'on'
|
||||||
|
- Abstract: {'power': 'on'}
|
||||||
|
"""
|
||||||
|
return {"power": payload.strip()}
|
||||||
|
|
||||||
|
def transform_contact_sensor_to_vendor(payload: dict[str, Any]) -> str:
|
||||||
|
"""Transform abstract contact sensor payload to format.
|
||||||
|
|
||||||
|
Contact sensors are read-only.
|
||||||
|
"""
|
||||||
|
logger.warning("Contact sensors are read-only - SET commands should not be used")
|
||||||
|
return json.dumps(payload)
|
||||||
|
|
||||||
|
|
||||||
|
def transform_contact_sensor_to_abstract(payload: str) -> dict[str, Any]:
|
||||||
|
"""Transform contact sensor payload to abstract format.
|
||||||
|
|
||||||
|
MAX! sends "true"/"false" (string or bool) on STATE topic.
|
||||||
|
|
||||||
Transformations:
|
Transformations:
|
||||||
- state: true -> power: 'on'
|
- "true" or True -> "open" (window/door open)
|
||||||
- state: false -> power: 'off'
|
- "false" or False -> "closed" (window/door closed)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
- contact sensor: "off"
|
||||||
|
- Abstract: {"contact": "open"}
|
||||||
"""
|
"""
|
||||||
data = json.loads(payload)
|
contact_value = payload.strip().lower() == "off"
|
||||||
state = data.get("state", False)
|
return {
|
||||||
power = "on" if bool(state) else "off"
|
"contact": "open" if contact_value else "closed"
|
||||||
return {"power": power}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def transform_three_phase_powermeter_to_vendor(payload: dict[str, Any]) -> str:
|
def transform_three_phase_powermeter_to_vendor(payload: dict[str, Any]) -> str:
|
||||||
@@ -104,4 +127,8 @@ HANDLERS = {
|
|||||||
("relay", "to_abstract"): transform_relay_to_abstract,
|
("relay", "to_abstract"): transform_relay_to_abstract,
|
||||||
("three_phase_powermeter", "to_vendor"): transform_three_phase_powermeter_to_vendor,
|
("three_phase_powermeter", "to_vendor"): transform_three_phase_powermeter_to_vendor,
|
||||||
("three_phase_powermeter", "to_abstract"): transform_three_phase_powermeter_to_abstract,
|
("three_phase_powermeter", "to_abstract"): transform_three_phase_powermeter_to_abstract,
|
||||||
|
("contact_sensor", "to_vendor"): transform_contact_sensor_to_vendor,
|
||||||
|
("contact_sensor", "to_abstract"): transform_contact_sensor_to_abstract,
|
||||||
|
("contact", "to_vendor"): transform_contact_sensor_to_vendor,
|
||||||
|
("contact", "to_abstract"): transform_contact_sensor_to_abstract,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -860,7 +860,6 @@ devices:
|
|||||||
topics:
|
topics:
|
||||||
set: "IoT/Car/Control"
|
set: "IoT/Car/Control"
|
||||||
state: "IoT/Car/Control/State"
|
state: "IoT/Car/Control/State"
|
||||||
|
|
||||||
- device_id: powermeter_caroutlet
|
- device_id: powermeter_caroutlet
|
||||||
name: Car Outlet
|
name: Car Outlet
|
||||||
type: three_phase_powermeter
|
type: three_phase_powermeter
|
||||||
@@ -868,6 +867,13 @@ devices:
|
|||||||
technology: hottis_pv_modbus
|
technology: hottis_pv_modbus
|
||||||
topics:
|
topics:
|
||||||
state: "IoT/Car/Values"
|
state: "IoT/Car/Values"
|
||||||
|
- device_id: sensor_caroutlet
|
||||||
|
name: Car Outlet
|
||||||
|
type: contact
|
||||||
|
cap_version: contact_sensor@1.0.0
|
||||||
|
technology: hottis_pv_modbus
|
||||||
|
topics:
|
||||||
|
state: IoT/Car/Feedback/State
|
||||||
|
|
||||||
- device_id: schranklicht_flur_vor_kueche
|
- device_id: schranklicht_flur_vor_kueche
|
||||||
name: Schranklicht Flur vor Küche
|
name: Schranklicht Flur vor Küche
|
||||||
|
|||||||
@@ -321,5 +321,9 @@ rooms:
|
|||||||
title: Ladestrom
|
title: Ladestrom
|
||||||
icon: 📊
|
icon: 📊
|
||||||
rank: 320
|
rank: 320
|
||||||
|
- device_id: sensor_caroutlet
|
||||||
|
title: Ladestrom
|
||||||
|
icon: 🪟
|
||||||
|
rank: 330
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user