Skip to content

Commit fcc525f

Browse files
Add support for whitebulb and normalize OnOff attribute state
1 parent e8c4706 commit fcc525f

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

pyhilo/device/graphql_value_mapper.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def _map_devices_values(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
5757
attributes.extend(self._build_gateway(device))
5858
case "colorbulb":
5959
attributes.extend(self._build_light(device))
60+
case "whitebulb":
61+
attributes.extend(self._build_light(device))
6062
case "dimmer":
6163
attributes.extend(self._build_dimmer(device))
6264
case "switch":
@@ -354,6 +356,11 @@ def _build_charge_controller(self, device: Dict[str, Any]) -> list[Dict[str, Any
354356
attributes.append(
355357
self.build_attribute(device["hiloId"], "CcrMode", device["ccrMode"])
356358
)
359+
attributes.append(
360+
self.build_attribute(
361+
device["hiloId"], "OnOff", device["state"].lower() == "on"
362+
)
363+
)
357364
return attributes
358365

359366
def _build_charging_point(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
@@ -372,10 +379,14 @@ def _build_switch(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
372379
if device.get("power") is not None:
373380
attributes.append(self._map_power(device))
374381
attributes.append(
375-
self.build_attribute(device["hiloId"], "Status", device["state"])
382+
self.build_attribute(
383+
device["hiloId"], "Status", device["state"].lower() == "on"
384+
)
376385
)
377386
attributes.append(
378-
self.build_attribute(device["hiloId"], "OnOff", device["state"])
387+
self.build_attribute(
388+
device["hiloId"], "OnOff", device["state"].lower() == "on"
389+
)
379390
)
380391
return attributes
381392

@@ -390,7 +401,9 @@ def _build_dimmer(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
390401
)
391402
)
392403
attributes.append(
393-
self.build_attribute(device["hiloId"], "OnOff", device["state"])
404+
self.build_attribute(
405+
device["hiloId"], "OnOff", device["state"].lower() == "on"
406+
)
394407
)
395408
return attributes
396409

@@ -420,7 +433,9 @@ def _build_light(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
420433
)
421434
)
422435
attributes.append(
423-
self.build_attribute(device["hiloId"], "OnOff", device["state"])
436+
self.build_attribute(
437+
device["hiloId"], "OnOff", device["state"].lower() == "on"
438+
)
424439
)
425440
return attributes
426441

0 commit comments

Comments
 (0)