Compare commits
14 Commits
0.5.4
...
0.5.17-con
| Author | SHA1 | Date | |
|---|---|---|---|
|
cc342245f8
|
|||
|
50253d536d
|
|||
|
e0aa50c9d2
|
|||
|
dc20d9f4b2
|
|||
|
ffb35928b4
|
|||
|
ac84ff7103
|
|||
|
c185494da3
|
|||
|
ec4a37a268
|
|||
|
d4b1d27b81
|
|||
|
ad07bc79e2
|
|||
|
ab41e79cb2
|
|||
|
fe92d336b1
|
|||
|
0ca59896ad
|
|||
|
7858996d0f
|
@@ -351,6 +351,36 @@ def _transform_relay_shelly_to_abstract(payload: str) -> dict[str, Any]:
|
|||||||
"""
|
"""
|
||||||
return {"power": payload.strip()}
|
return {"power": payload.strip()}
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# HANDLER FUNCTIONS: relay - tasmota technology
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
def _transform_relay_tasmota_to_vendor(payload: dict[str, Any]) -> str:
|
||||||
|
"""Transform abstract relay payload to Tasmota format.
|
||||||
|
|
||||||
|
Tasmota expects plain text 'on' or 'off' (not JSON).
|
||||||
|
- power: 'on'/'off' -> 'on'/'off' (plain string)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
- Abstract: {'power': 'on'}
|
||||||
|
- Tasmota: 'on'
|
||||||
|
"""
|
||||||
|
power = payload.get("power", "off")
|
||||||
|
return power
|
||||||
|
|
||||||
|
|
||||||
|
def _transform_relay_tasmota_to_abstract(payload: str) -> dict[str, Any]:
|
||||||
|
"""Transform Tasmota relay payload to abstract format.
|
||||||
|
|
||||||
|
Tasmota sends plain text 'on' or 'off' (not JSON).
|
||||||
|
- 'on'/'off' -> power: 'on'/'off'
|
||||||
|
|
||||||
|
Example:
|
||||||
|
- Tasmota: 'ON'
|
||||||
|
- Abstract: {'power': 'on'}
|
||||||
|
"""
|
||||||
|
return {"power": payload.strip().lower()}
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# HANDLER FUNCTIONS: relay - hottis_pv_modbus technology
|
# HANDLER FUNCTIONS: relay - hottis_pv_modbus technology
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -431,27 +461,48 @@ def _transform_three_phase_powermeter_hottis_pv_modbus_to_abstract(payload: str)
|
|||||||
"""Transform hottis_pv_modbus three_phase_powermeter payload to abstract format.
|
"""Transform hottis_pv_modbus three_phase_powermeter payload to abstract format.
|
||||||
|
|
||||||
Transformations:
|
Transformations:
|
||||||
- Direct mapping of all power meter fields
|
- Map vendor field names to abstract field names
|
||||||
|
- totalImportEnergy -> energy
|
||||||
Example:
|
- powerL1/powerL2/powerL3 -> phase1_power/phase2_power/phase3_power
|
||||||
- hottis_pv_modbus: {'energy': 123.45, 'total_power': 1500.0, 'phase1_power': 500.0, ...}
|
- voltageL1/voltageL2/voltageL3 -> phase1_voltage/phase2_voltage/phase3_voltage
|
||||||
- Abstract: {'energy': 123.45, 'total_power': 1500.0, 'phase1_power': 500.0, ...}
|
- currentL1/currentL2/currentL3 -> phase1_current/phase2_current/phase3_current
|
||||||
|
- Sum of powerL1..3 -> total_power
|
||||||
"""
|
"""
|
||||||
payload = json.loads(payload)
|
data = json.loads(payload)
|
||||||
|
|
||||||
|
# Helper to read numeric values uniformly as float
|
||||||
|
def _get_float(key: str, default: float = 0.0) -> float:
|
||||||
|
return float(data.get(key, default))
|
||||||
|
|
||||||
|
# Read all numeric values via helper for consistent error handling
|
||||||
|
phase1_power = _get_float("powerL1")
|
||||||
|
phase2_power = _get_float("powerL2")
|
||||||
|
phase3_power = _get_float("powerL3")
|
||||||
|
|
||||||
|
phase1_voltage = _get_float("voltageL1")
|
||||||
|
phase2_voltage = _get_float("voltageL2")
|
||||||
|
phase3_voltage = _get_float("voltageL3")
|
||||||
|
|
||||||
|
phase1_current = _get_float("currentL1")
|
||||||
|
phase2_current = _get_float("currentL2")
|
||||||
|
phase3_current = _get_float("currentL3")
|
||||||
|
|
||||||
|
energy = _get_float("totalImportEnergy")
|
||||||
|
|
||||||
abstract_payload = {
|
abstract_payload = {
|
||||||
"energy": payload.get("energy", 0.0),
|
"energy": energy,
|
||||||
"total_power": payload.get("total_power", 0.0),
|
"total_power": phase1_power + phase2_power + phase3_power,
|
||||||
"phase1_power": payload.get("phase1_power", 0.0),
|
"phase1_power": phase1_power,
|
||||||
"phase2_power": payload.get("phase2_power", 0.0),
|
"phase2_power": phase2_power,
|
||||||
"phase3_power": payload.get("phase3_power", 0.0),
|
"phase3_power": phase3_power,
|
||||||
"phase1_voltage": payload.get("phase1_voltage", 0.0),
|
"phase1_voltage": phase1_voltage,
|
||||||
"phase2_voltage": payload.get("phase2_voltage", 0.0),
|
"phase2_voltage": phase2_voltage,
|
||||||
"phase3_voltage": payload.get("phase3_voltage", 0.0),
|
"phase3_voltage": phase3_voltage,
|
||||||
"phase1_current": payload.get("phase1_current", 0.0),
|
"phase1_current": phase1_current,
|
||||||
"phase2_current": payload.get("phase2_current", 0.0),
|
"phase2_current": phase2_current,
|
||||||
"phase3_current": payload.get("phase3_current", 0.0),
|
"phase3_current": phase3_current,
|
||||||
}
|
}
|
||||||
|
|
||||||
return abstract_payload
|
return abstract_payload
|
||||||
|
|
||||||
|
|
||||||
@@ -560,6 +611,8 @@ TRANSFORM_HANDLERS: dict[tuple[str, str, str], TransformHandler] = {
|
|||||||
("relay", "shelly", "to_abstract"): _transform_relay_shelly_to_abstract,
|
("relay", "shelly", "to_abstract"): _transform_relay_shelly_to_abstract,
|
||||||
("relay", "hottis_pv_modbus", "to_vendor"): _transform_relay_hottis_pv_modbus_to_vendor,
|
("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,
|
("relay", "hottis_pv_modbus", "to_abstract"): _transform_relay_hottis_pv_modbus_to_abstract,
|
||||||
|
("relay", "tasmota", "to_vendor"): _transform_relay_tasmota_to_vendor,
|
||||||
|
("relay", "tasmota", "to_abstract"): _transform_relay_tasmota_to_abstract,
|
||||||
|
|
||||||
# Three-Phase Powermeter transformations
|
# Three-Phase Powermeter transformations
|
||||||
("three_phase_powermeter", "hottis_pv_modbus", "to_vendor"): _transform_three_phase_powermeter_hottis_pv_modbus_to_vendor,
|
("three_phase_powermeter", "hottis_pv_modbus", "to_vendor"): _transform_three_phase_powermeter_hottis_pv_modbus_to_vendor,
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def build_bridge(driver: AccessoryDriver, api_client: ApiClient) -> Bridge:
|
|||||||
|
|
||||||
bridge.add_accessory(accessory)
|
bridge.add_accessory(accessory)
|
||||||
accessory_map[device.device_id] = accessory
|
accessory_map[device.device_id] = accessory
|
||||||
logger.info(f"Added accessory: {device.friendly_name} ({device.type}) in room: {device.room or 'Unknown'}")
|
logger.info(f"Added accessory: {device.friendly_name} ({device.type}, {accessory.__class__.__name__}) in room: {device.room or 'Unknown'}")
|
||||||
else:
|
else:
|
||||||
logger.warning(f"No accessory mapping for device: {device.name} ({device.type})")
|
logger.warning(f"No accessory mapping for device: {device.name} ({device.type})")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -241,22 +241,6 @@ devices:
|
|||||||
ieee_address: "0x0017880108a03e45"
|
ieee_address: "0x0017880108a03e45"
|
||||||
model: "929002241201"
|
model: "929002241201"
|
||||||
vendor: "Philips"
|
vendor: "Philips"
|
||||||
- device_id: haustuer
|
|
||||||
name: Haustür-Lampe
|
|
||||||
type: light
|
|
||||||
cap_version: "light@1.2.0"
|
|
||||||
technology: zigbee2mqtt
|
|
||||||
features:
|
|
||||||
power: true
|
|
||||||
brightness: true
|
|
||||||
topics:
|
|
||||||
state: "zigbee2mqtt/0xec1bbdfffea6a3da"
|
|
||||||
set: "zigbee2mqtt/0xec1bbdfffea6a3da/set"
|
|
||||||
metadata:
|
|
||||||
friendly_name: "Haustür"
|
|
||||||
ieee_address: "0xec1bbdfffea6a3da"
|
|
||||||
model: "LED1842G3"
|
|
||||||
vendor: "IKEA"
|
|
||||||
- device_id: deckenlampe_flur_oben
|
- device_id: deckenlampe_flur_oben
|
||||||
name: Deckenlampe oben
|
name: Deckenlampe oben
|
||||||
type: light
|
type: light
|
||||||
@@ -783,6 +767,88 @@ devices:
|
|||||||
topics:
|
topics:
|
||||||
set: "shellies/lichtterasse/relay/0/command"
|
set: "shellies/lichtterasse/relay/0/command"
|
||||||
state: "shellies/lichtterasse/relay/0"
|
state: "shellies/lichtterasse/relay/0"
|
||||||
|
- device_id: kugellampe_patty
|
||||||
|
name: Kugellampe Patty
|
||||||
|
type: light
|
||||||
|
cap_version: "light@1.2.0"
|
||||||
|
technology: zigbee2mqtt
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
brightness: true
|
||||||
|
topics:
|
||||||
|
state: "zigbee2mqtt/0xbc33acfffe21f547"
|
||||||
|
set: "zigbee2mqtt/0xbc33acfffe21f547/set"
|
||||||
|
- device_id: kueche_fensterbank_licht
|
||||||
|
name: Fensterbank Küche
|
||||||
|
type: light
|
||||||
|
cap_version: "light@1.2.0"
|
||||||
|
technology: zigbee2mqtt
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
brightness: true
|
||||||
|
topics:
|
||||||
|
state: "zigbee2mqtt/0xf0d1b8000017515d"
|
||||||
|
set: "zigbee2mqtt/0xf0d1b8000017515d/set"
|
||||||
|
- device_id: licht_kommode_schlafzimmer
|
||||||
|
name: Kommode Schlafzimmer
|
||||||
|
type: relay
|
||||||
|
cap_version: "relay@1.0.0"
|
||||||
|
technology: tasmota
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
topics:
|
||||||
|
set: "cmnd/tasmota/04/POWER"
|
||||||
|
state: "stat/tasmota/04/POWER"
|
||||||
|
- device_id: licht_fensterbank_esszimmer
|
||||||
|
name: Fensterbank Esszimmer
|
||||||
|
type: relay
|
||||||
|
cap_version: "relay@1.0.0"
|
||||||
|
technology: tasmota
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
topics:
|
||||||
|
set: "cmnd/tasmota/02/POWER"
|
||||||
|
state: "stat/tasmota/02/POWER"
|
||||||
|
- device_id: licht_schreibtisch_patty
|
||||||
|
name: Schreibtisch Patty
|
||||||
|
type: relay
|
||||||
|
cap_version: "relay@1.0.0"
|
||||||
|
technology: tasmota
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
topics:
|
||||||
|
set: "cmnd/tasmota/03/POWER"
|
||||||
|
state: "stat/tasmota/03/POWER"
|
||||||
|
- device_id: kugeln_regal_flur
|
||||||
|
name: Kugeln Regal Flur
|
||||||
|
type: relay
|
||||||
|
cap_version: "relay@1.0.0"
|
||||||
|
technology: tasmota
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
topics:
|
||||||
|
set: "cmnd/tasmota/01/POWER"
|
||||||
|
state: "stat/tasmota/01/POWER"
|
||||||
|
- device_id: schrank_flur_haustür
|
||||||
|
name: Schrank Flur Haustür
|
||||||
|
type: relay
|
||||||
|
cap_version: "relay@1.0.0"
|
||||||
|
technology: tasmota
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
topics:
|
||||||
|
set: "cmnd/tasmota/05/POWER"
|
||||||
|
state: "stat/tasmota/05/POWER"
|
||||||
|
- device_id: gartenlicht_vorne
|
||||||
|
name: Gartenlicht vorne
|
||||||
|
type: relay
|
||||||
|
cap_version: "relay@1.0.0"
|
||||||
|
technology: tasmota
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
topics:
|
||||||
|
set: "cmnd/tasmota/06/POWER"
|
||||||
|
state: "stat/tasmota/06/POWER"
|
||||||
|
|
||||||
- device_id: power_relay_caroutlet
|
- device_id: power_relay_caroutlet
|
||||||
name: Car Outlet
|
name: Car Outlet
|
||||||
@@ -799,8 +865,20 @@ devices:
|
|||||||
name: Car Outlet
|
name: Car Outlet
|
||||||
type: three_phase_powermeter
|
type: three_phase_powermeter
|
||||||
cap_version: "three_phase_powermeter@1.0.0"
|
cap_version: "three_phase_powermeter@1.0.0"
|
||||||
technology: hottis_modbus
|
technology: hottis_pv_modbus
|
||||||
topics:
|
topics:
|
||||||
state: "caroutlet/powermeter"
|
state: "IoT/Car/Values"
|
||||||
|
|
||||||
|
- device_id: schranklicht_flur_vor_kueche
|
||||||
|
name: Schranklicht Flur vor Küche
|
||||||
|
type: light
|
||||||
|
cap_version: "relay@1.0.0"
|
||||||
|
technology: zigbee2mqtt
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
topics:
|
||||||
|
state: "zigbee2mqtt/0xf0d1b80000155a1f"
|
||||||
|
set: "zigbee2mqtt/0xf0d1b80000155a1f/set"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ rooms:
|
|||||||
title: Medusa-Lampe Schlafzimmer
|
title: Medusa-Lampe Schlafzimmer
|
||||||
icon: 💡
|
icon: 💡
|
||||||
rank: 40
|
rank: 40
|
||||||
|
- device_id: licht_kommode_schlafzimmer
|
||||||
|
title: Kommode Schlafzimmer
|
||||||
|
icon: 💡
|
||||||
|
rank: 42
|
||||||
- device_id: thermostat_schlafzimmer
|
- device_id: thermostat_schlafzimmer
|
||||||
title: Thermostat Schlafzimmer
|
title: Thermostat Schlafzimmer
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
@@ -39,10 +43,10 @@ rooms:
|
|||||||
title: Leselampe Esszimmer
|
title: Leselampe Esszimmer
|
||||||
icon: 💡
|
icon: 💡
|
||||||
rank: 60
|
rank: 60
|
||||||
# - device_id: standlampe_esszimmer
|
- device_id: licht_fensterbank_esszimmer
|
||||||
# title: Standlampe Esszimmer
|
title: Fensterbank Esszimmer
|
||||||
# icon: 💡
|
icon: 💡
|
||||||
# rank: 70
|
rank: 70
|
||||||
- device_id: kleine_lampe_links_esszimmer
|
- device_id: kleine_lampe_links_esszimmer
|
||||||
title: kleine Lampe links Esszimmer
|
title: kleine Lampe links Esszimmer
|
||||||
icon: 💡
|
icon: 💡
|
||||||
@@ -127,6 +131,10 @@ rooms:
|
|||||||
title: Küche Putzlicht
|
title: Küche Putzlicht
|
||||||
icon: 💡
|
icon: 💡
|
||||||
rank: 143
|
rank: 143
|
||||||
|
- device_id: kueche_fensterbank_licht
|
||||||
|
title: Küche Fensterbank
|
||||||
|
icon: 💡
|
||||||
|
rank: 144
|
||||||
- device_id: thermostat_kueche
|
- device_id: thermostat_kueche
|
||||||
title: Kueche
|
title: Kueche
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
@@ -165,6 +173,14 @@ rooms:
|
|||||||
title: Schranklicht vorne Patty
|
title: Schranklicht vorne Patty
|
||||||
icon: 💡
|
icon: 💡
|
||||||
rank: 180
|
rank: 180
|
||||||
|
- device_id: kugellampe_patty
|
||||||
|
title: Kugellampe Patty
|
||||||
|
icon: 💡
|
||||||
|
rank: 181
|
||||||
|
- device_id: licht_schreibtisch_patty
|
||||||
|
title: Licht Schreibtisch Patty
|
||||||
|
icon: 💡
|
||||||
|
rank: 182
|
||||||
- device_id: thermostat_patty
|
- device_id: thermostat_patty
|
||||||
title: Thermostat Patty
|
title: Thermostat Patty
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
@@ -209,18 +225,22 @@ rooms:
|
|||||||
title: Deckenlampe Flur oben
|
title: Deckenlampe Flur oben
|
||||||
icon: 💡
|
icon: 💡
|
||||||
rank: 210
|
rank: 210
|
||||||
- device_id: haustuer
|
- device_id: kugeln_regal_flur
|
||||||
title: Haustür
|
title: Kugeln Regal
|
||||||
icon: 💡
|
|
||||||
rank: 220
|
|
||||||
- device_id: licht_flur_schrank
|
|
||||||
title: Schranklicht Flur
|
|
||||||
icon: 💡
|
icon: 💡
|
||||||
rank: 222
|
rank: 222
|
||||||
- device_id: licht_flur_oben_am_spiegel
|
- device_id: licht_flur_oben_am_spiegel
|
||||||
title: Licht Flur oben am Spiegel
|
title: Licht oben am Spiegel
|
||||||
icon: 💡
|
icon: 💡
|
||||||
rank: 230
|
rank: 230
|
||||||
|
- device_id: schrank_flur_haustür
|
||||||
|
title: Schranklicht an der Haustür
|
||||||
|
icon: 💡
|
||||||
|
rank: 231
|
||||||
|
- device_id: schranklicht_flur_vor_kueche
|
||||||
|
title: Schranklicht vor Küche
|
||||||
|
icon: 💡
|
||||||
|
rank: 232
|
||||||
- device_id: sensor_flur
|
- device_id: sensor_flur
|
||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
@@ -283,6 +303,10 @@ rooms:
|
|||||||
title: Licht Terasse
|
title: Licht Terasse
|
||||||
icon: 💡
|
icon: 💡
|
||||||
rank: 290
|
rank: 290
|
||||||
|
- device_id: gartenlicht_vorne
|
||||||
|
title: Gartenlicht vorne
|
||||||
|
icon: 💡
|
||||||
|
rank: 291
|
||||||
- name: Garage
|
- name: Garage
|
||||||
devices:
|
devices:
|
||||||
- device_id: power_relay_caroutlet
|
- device_id: power_relay_caroutlet
|
||||||
|
|||||||
Reference in New Issue
Block a user