Compare commits
3 Commits
0.10.2
...
0.10.4-con
| Author | SHA1 | Date | |
|---|---|---|---|
|
fb828c9a2c
|
|||
|
064ee6bbed
|
|||
|
d39bcfce26
|
@@ -48,11 +48,11 @@ class HeatingControlRequest(BaseModel):
|
|||||||
target: float # Target temperature
|
target: float # Target temperature
|
||||||
|
|
||||||
|
|
||||||
def get_room_devices(room_name: str) -> list[dict[str, Any]]:
|
def get_room_devices(room_id: str) -> list[dict[str, Any]]:
|
||||||
"""Get all devices in a specific room from layout.
|
"""Get all devices in a specific room from layout.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
room_name: Name of the room
|
room_id: ID of the room
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
List of device dicts with device_id, title, icon, rank, excluded
|
List of device dicts with device_id, title, icon, rank, excluded
|
||||||
@@ -63,7 +63,7 @@ def get_room_devices(room_name: str) -> list[dict[str, Any]]:
|
|||||||
layout = load_layout()
|
layout = load_layout()
|
||||||
|
|
||||||
for room in layout.rooms:
|
for room in layout.rooms:
|
||||||
if room.name == room_name:
|
if room.id == room_id:
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"device_id": device.device_id,
|
"device_id": device.device_id,
|
||||||
@@ -77,16 +77,16 @@ def get_room_devices(room_name: str) -> list[dict[str, Any]]:
|
|||||||
|
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
detail=f"Room '{room_name}' not found"
|
detail=f"Room '{room_id}' not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/rooms/{room_name}/lights", status_code=status.HTTP_202_ACCEPTED)
|
@router.post("/rooms/{room_id}/lights", status_code=status.HTTP_202_ACCEPTED)
|
||||||
async def control_room_lights(room_name: str, request: LightsControlRequest) -> dict[str, Any]:
|
async def control_room_lights(room_id: str, request: LightsControlRequest) -> dict[str, Any]:
|
||||||
"""Control all lights (light and relay devices) in a room.
|
"""Control all lights (light and relay devices) in a room.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
room_name: Name of the room
|
room_id: ID of the room
|
||||||
request: Light control parameters
|
request: Light control parameters
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@@ -95,7 +95,7 @@ async def control_room_lights(room_name: str, request: LightsControlRequest) ->
|
|||||||
from apps.api.main import load_devices, publish_abstract_set
|
from apps.api.main import load_devices, publish_abstract_set
|
||||||
|
|
||||||
# Get all devices in room
|
# Get all devices in room
|
||||||
room_devices = get_room_devices(room_name)
|
room_devices = get_room_devices(room_id)
|
||||||
|
|
||||||
# Filter out excluded devices
|
# Filter out excluded devices
|
||||||
room_device_ids = {d["device_id"] for d in room_devices if not d.get("excluded", False)}
|
room_device_ids = {d["device_id"] for d in room_devices if not d.get("excluded", False)}
|
||||||
@@ -112,7 +112,7 @@ async def control_room_lights(room_name: str, request: LightsControlRequest) ->
|
|||||||
if not light_devices:
|
if not light_devices:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
detail=f"No light devices found in room '{room_name}'"
|
detail=f"No light devices found in room '{room_id}'"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Build payload
|
# Build payload
|
||||||
@@ -141,7 +141,7 @@ async def control_room_lights(room_name: str, request: LightsControlRequest) ->
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"room": room_name,
|
"room": room_id,
|
||||||
"command": "lights",
|
"command": "lights",
|
||||||
"payload": payload,
|
"payload": payload,
|
||||||
"affected_devices": affected_ids,
|
"affected_devices": affected_ids,
|
||||||
@@ -151,12 +151,12 @@ async def control_room_lights(room_name: str, request: LightsControlRequest) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@router.post("/rooms/{room_name}/heating", status_code=status.HTTP_202_ACCEPTED)
|
@router.post("/rooms/{room_id}/heating", status_code=status.HTTP_202_ACCEPTED)
|
||||||
async def control_room_heating(room_name: str, request: HeatingControlRequest) -> dict[str, Any]:
|
async def control_room_heating(room_id: str, request: HeatingControlRequest) -> dict[str, Any]:
|
||||||
"""Control all thermostats in a room.
|
"""Control all thermostats in a room.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
room_name: Name of the room
|
room_id: ID of the room
|
||||||
request: Heating control parameters
|
request: Heating control parameters
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@@ -165,7 +165,7 @@ async def control_room_heating(room_name: str, request: HeatingControlRequest) -
|
|||||||
from apps.api.main import load_devices, publish_abstract_set
|
from apps.api.main import load_devices, publish_abstract_set
|
||||||
|
|
||||||
# Get all devices in room
|
# Get all devices in room
|
||||||
room_devices = get_room_devices(room_name)
|
room_devices = get_room_devices(room_id)
|
||||||
|
|
||||||
# Filter out excluded devices
|
# Filter out excluded devices
|
||||||
room_device_ids = {d["device_id"] for d in room_devices if not d.get("excluded", False)}
|
room_device_ids = {d["device_id"] for d in room_devices if not d.get("excluded", False)}
|
||||||
@@ -209,7 +209,7 @@ async def control_room_heating(room_name: str, request: HeatingControlRequest) -
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"room": room_name,
|
"room": room_id,
|
||||||
"command": "heating",
|
"command": "heating",
|
||||||
"payload": payload,
|
"payload": payload,
|
||||||
"affected_devices": affected_ids,
|
"affected_devices": affected_ids,
|
||||||
|
|||||||
@@ -898,3 +898,13 @@ devices:
|
|||||||
set: "zigbee2mqtt/0x842e14fffea72027/set"
|
set: "zigbee2mqtt/0x842e14fffea72027/set"
|
||||||
|
|
||||||
|
|
||||||
|
- device_id: keller_flur_licht
|
||||||
|
name: Keller Flur Licht
|
||||||
|
type: relay
|
||||||
|
cap_version: "relay@1.0.0"
|
||||||
|
technology: hottis_wago_modbus
|
||||||
|
features:
|
||||||
|
power: true
|
||||||
|
topics:
|
||||||
|
set: "pulsegen/command/10/21"
|
||||||
|
state: "pulsegen/status/10"
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
rooms:
|
rooms:
|
||||||
- id: Schlafzimmer
|
- id: schlafzimmer
|
||||||
name: Schlafzimmer
|
name: Schlafzimmer
|
||||||
devices:
|
devices:
|
||||||
- device_id: bettlicht_patty
|
- device_id: bettlicht_patty
|
||||||
@@ -34,7 +34,7 @@ rooms:
|
|||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 47
|
rank: 47
|
||||||
- id: Esszimmer
|
- id: esszimmer
|
||||||
name: Esszimmer
|
name: Esszimmer
|
||||||
devices:
|
devices:
|
||||||
- device_id: deckenlampe_esszimmer
|
- device_id: deckenlampe_esszimmer
|
||||||
@@ -81,7 +81,7 @@ rooms:
|
|||||||
title: Kontakt Straße links
|
title: Kontakt Straße links
|
||||||
icon: 🪟
|
icon: 🪟
|
||||||
rank: 97
|
rank: 97
|
||||||
- id: Wohnzimmer
|
- id: wohnzimmer
|
||||||
name: Wohnzimmer
|
name: Wohnzimmer
|
||||||
devices:
|
devices:
|
||||||
- device_id: lampe_naehtischchen_wohnzimmer
|
- device_id: lampe_naehtischchen_wohnzimmer
|
||||||
@@ -124,7 +124,7 @@ rooms:
|
|||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 138
|
rank: 138
|
||||||
- id: Küche
|
- id: kueche
|
||||||
name: Küche
|
name: Küche
|
||||||
devices:
|
devices:
|
||||||
- device_id: kueche_deckenlampe
|
- device_id: kueche_deckenlampe
|
||||||
@@ -168,7 +168,7 @@ rooms:
|
|||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 155
|
rank: 155
|
||||||
- id: Arbeitszimmer Patty
|
- id: arbeitszimmer_patty
|
||||||
name: Arbeitszimmer Patty
|
name: Arbeitszimmer Patty
|
||||||
devices:
|
devices:
|
||||||
- device_id: leselampe_patty
|
- device_id: leselampe_patty
|
||||||
@@ -211,7 +211,7 @@ rooms:
|
|||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 189
|
rank: 189
|
||||||
- id: Arbeitszimmer Wolfgang
|
- id: arbeitszimmer_wolfgang
|
||||||
name: Arbeitszimmer Wolfgang
|
name: Arbeitszimmer Wolfgang
|
||||||
devices:
|
devices:
|
||||||
- device_id: thermostat_wolfgang
|
- device_id: thermostat_wolfgang
|
||||||
@@ -230,7 +230,7 @@ rooms:
|
|||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 202
|
rank: 202
|
||||||
- id: Flur
|
- id: flur
|
||||||
name: Flur
|
name: Flur
|
||||||
devices:
|
devices:
|
||||||
- device_id: deckenlampe_flur_oben
|
- device_id: deckenlampe_flur_oben
|
||||||
@@ -257,7 +257,7 @@ rooms:
|
|||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 235
|
rank: 235
|
||||||
- id: Sportzimmer
|
- id: sportzimmer
|
||||||
name: Sportzimmer
|
name: Sportzimmer
|
||||||
devices:
|
devices:
|
||||||
- device_id: sportlicht_regal
|
- device_id: sportlicht_regal
|
||||||
@@ -276,7 +276,7 @@ rooms:
|
|||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 265
|
rank: 265
|
||||||
- id: Bad Oben
|
- id: bad_oben
|
||||||
name: Bad Oben
|
name: Bad Oben
|
||||||
devices:
|
devices:
|
||||||
- device_id: thermostat_bad_oben
|
- device_id: thermostat_bad_oben
|
||||||
@@ -291,7 +291,7 @@ rooms:
|
|||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 272
|
rank: 272
|
||||||
- id: Bad Unten
|
- id: bad_unten
|
||||||
name: Bad Unten
|
name: Bad Unten
|
||||||
devices:
|
devices:
|
||||||
- device_id: thermostat_bad_unten
|
- device_id: thermostat_bad_unten
|
||||||
@@ -306,14 +306,14 @@ rooms:
|
|||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 282
|
rank: 282
|
||||||
- id: Waschküche
|
- id: waschkueche
|
||||||
name: Waschküche
|
name: Waschküche
|
||||||
devices:
|
devices:
|
||||||
- device_id: sensor_waschkueche
|
- device_id: sensor_waschkueche
|
||||||
title: Temperatur & Luftfeuchte
|
title: Temperatur & Luftfeuchte
|
||||||
icon: 🌡️
|
icon: 🌡️
|
||||||
rank: 290
|
rank: 290
|
||||||
- id: Outdoor
|
- id: outdoor
|
||||||
name: Outdoor
|
name: Outdoor
|
||||||
devices:
|
devices:
|
||||||
- device_id: licht_terasse
|
- device_id: licht_terasse
|
||||||
@@ -324,7 +324,7 @@ rooms:
|
|||||||
title: Gartenlicht vorne
|
title: Gartenlicht vorne
|
||||||
icon: 💡
|
icon: 💡
|
||||||
rank: 291
|
rank: 291
|
||||||
- id: Garage
|
- id: garage
|
||||||
name: Garage
|
name: Garage
|
||||||
devices:
|
devices:
|
||||||
- device_id: power_relay_caroutlet
|
- device_id: power_relay_caroutlet
|
||||||
@@ -339,5 +339,13 @@ rooms:
|
|||||||
title: Messwerte
|
title: Messwerte
|
||||||
icon: 📊
|
icon: 📊
|
||||||
rank: 320
|
rank: 320
|
||||||
|
- id: keller
|
||||||
|
name: Keller
|
||||||
|
devices:
|
||||||
|
- device_id: keller_flur_licht
|
||||||
|
title: Keller Flur Licht
|
||||||
|
icon: 💡
|
||||||
|
rank: 330
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user