|
|
|
|
@@ -375,10 +375,10 @@ def _transform_relay_shelly_to_abstract(payload: str) -> dict[str, Any]:
|
|
|
|
|
return {"power": payload.strip()}
|
|
|
|
|
|
|
|
|
|
# ============================================================================
|
|
|
|
|
# HANDLER FUNCTIONS: relay - hottis_modbus technology
|
|
|
|
|
# HANDLER FUNCTIONS: relay - hottis_pv_modbus technology
|
|
|
|
|
# ============================================================================
|
|
|
|
|
|
|
|
|
|
def _transform_relay_hottis_modbus_to_vendor(payload: dict[str, Any]) -> str:
|
|
|
|
|
def _transform_relay_hottis_pv_modbus_to_vendor(payload: dict[str, Any]) -> str:
|
|
|
|
|
"""Transform abstract relay payload to Hottis Modbus format.
|
|
|
|
|
|
|
|
|
|
Hottis Modbus expects plain text 'on' or 'off' (not JSON).
|
|
|
|
|
@@ -392,26 +392,32 @@ def _transform_relay_hottis_modbus_to_vendor(payload: dict[str, Any]) -> str:
|
|
|
|
|
return power
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _transform_relay_hottis_modbus_to_abstract(payload: str) -> dict[str, Any]:
|
|
|
|
|
def _transform_relay_hottis_pv_modbus_to_abstract(payload: str) -> dict[str, Any]:
|
|
|
|
|
def _transform_relay_hottis_pv_modbus_to_abstract(payload: str) -> dict[str, Any]:
|
|
|
|
|
"""Transform Hottis Modbus relay payload to abstract format.
|
|
|
|
|
|
|
|
|
|
Hottis Modbus sends plain text 'on' or 'off' (not JSON).
|
|
|
|
|
- 'on'/'off' -> power: 'on'/'off'
|
|
|
|
|
Hottis Modbus sends JSON like:
|
|
|
|
|
{"status": "Ok", "timestamp": "...", "state": false, "cnt": 528}
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
- Hottis Modbus: 'on'
|
|
|
|
|
- Abstract: {'power': 'on'}
|
|
|
|
|
We only care about the 'state' field:
|
|
|
|
|
- state: true -> power: 'on'
|
|
|
|
|
- state: false -> power: 'off'
|
|
|
|
|
"""
|
|
|
|
|
data = json.loads(payload)
|
|
|
|
|
|
|
|
|
|
state = data.get("state", False)
|
|
|
|
|
power = "on" if bool(state) else "off"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {"power": payload.strip()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ============================================================================
|
|
|
|
|
# HANDLER FUNCTIONS: three_phase_powermeter - hottis_modbus technology
|
|
|
|
|
# HANDLER FUNCTIONS: three_phase_powermeter - hottis_pv_modbus technology
|
|
|
|
|
# ============================================================================
|
|
|
|
|
|
|
|
|
|
def _transform_three_phase_powermeter_hottis_modbus_to_vendor(payload: dict[str, Any]) -> dict[str, Any]:
|
|
|
|
|
"""Transform abstract three_phase_powermeter payload to hottis_modbus format.
|
|
|
|
|
|
|
|
|
|
def _transform_three_phase_powermeter_hottis_pv_modbus_to_vendor(payload: dict[str, Any]) -> dict[str, Any]:
|
|
|
|
|
"""Transform abstract three_phase_powermeter payload to hottis_pv_modbus format.
|
|
|
|
|
energy: float = Field(..., description="Total energy in kWh")
|
|
|
|
|
total_power: float = Field(..., description="Total power in W")
|
|
|
|
|
phase1_power: float = Field(..., description="Power for phase 1 in W")
|
|
|
|
|
@@ -444,14 +450,14 @@ def _transform_three_phase_powermeter_hottis_modbus_to_vendor(payload: dict[str,
|
|
|
|
|
return vendor_payload
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _transform_three_phase_powermeter_hottis_modbus_to_abstract(payload: str) -> dict[str, Any]:
|
|
|
|
|
"""Transform hottis_modbus three_phase_powermeter payload to abstract format.
|
|
|
|
|
def _transform_three_phase_powermeter_hottis_pv_modbus_to_abstract(payload: str) -> dict[str, Any]:
|
|
|
|
|
"""Transform hottis_pv_modbus three_phase_powermeter payload to abstract format.
|
|
|
|
|
|
|
|
|
|
Transformations:
|
|
|
|
|
- Direct mapping of all power meter fields
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
- hottis_modbus: {'energy': 123.45, 'total_power': 1500.0, 'phase1_power': 500.0, ...}
|
|
|
|
|
- hottis_pv_modbus: {'energy': 123.45, 'total_power': 1500.0, 'phase1_power': 500.0, ...}
|
|
|
|
|
- Abstract: {'energy': 123.45, 'total_power': 1500.0, 'phase1_power': 500.0, ...}
|
|
|
|
|
"""
|
|
|
|
|
payload = json.loads(payload)
|
|
|
|
|
@@ -579,12 +585,12 @@ TRANSFORM_HANDLERS: dict[tuple[str, str, str], TransformHandler] = {
|
|
|
|
|
("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,
|
|
|
|
|
("relay", "hottis_modbus", "to_vendor"): _transform_relay_hottis_modbus_to_vendor,
|
|
|
|
|
("relay", "hottis_modbus", "to_abstract"): _transform_relay_hottis_modbus_to_abstract,
|
|
|
|
|
("relay", "hottis_pv_modbus", "to_vendor"): _transform_relay_hottis_pv_modbus_to_vendor,
|
|
|
|
|
("relay", "hottis_pv_modbus", "to_abstract"): _transform_relay_hottis_pv_modbus_to_abstract,
|
|
|
|
|
|
|
|
|
|
# Three-Phase Powermeter transformations
|
|
|
|
|
("three_phase_powermeter", "hottis_modbus", "to_vendor"): _transform_three_phase_powermeter_hottis_modbus_to_vendor,
|
|
|
|
|
("three_phase_powermeter", "hottis_modbus", "to_abstract"): _transform_three_phase_powermeter_hottis_modbus_to_abstract,
|
|
|
|
|
("three_phase_powermeter", "hottis_pv_modbus", "to_vendor"): _transform_three_phase_powermeter_hottis_pv_modbus_to_vendor,
|
|
|
|
|
("three_phase_powermeter", "hottis_pv_modbus", "to_abstract"): _transform_three_phase_powermeter_hottis_pv_modbus_to_abstract,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|