@@ -9,6 +9,8 @@ class GraphqlValueMapper:
99 A class to map GraphQL values to DeviceReading instances.
1010 """
1111
12+ OnState = "on"
13+
1214 def map_query_values (self , values : Dict [str , Any ]) -> list [Dict [str , Any ]]:
1315 readings : list [Dict [str , Any ]] = []
1416 for device in values :
@@ -57,6 +59,8 @@ def _map_devices_values(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
5759 attributes .extend (self ._build_gateway (device ))
5860 case "colorbulb" :
5961 attributes .extend (self ._build_light (device ))
62+ case "whitebulb" :
63+ attributes .extend (self ._build_light (device ))
6064 case "dimmer" :
6165 attributes .extend (self ._build_dimmer (device ))
6266 case "switch" :
@@ -354,6 +358,11 @@ def _build_charge_controller(self, device: Dict[str, Any]) -> list[Dict[str, Any
354358 attributes .append (
355359 self .build_attribute (device ["hiloId" ], "CcrMode" , device ["ccrMode" ])
356360 )
361+ attributes .append (
362+ self .build_attribute (
363+ device ["hiloId" ], "OnOff" , device ["state" ].lower () == self .OnState
364+ )
365+ )
357366 return attributes
358367
359368 def _build_charging_point (self , device : Dict [str , Any ]) -> list [Dict [str , Any ]]:
@@ -372,10 +381,14 @@ def _build_switch(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
372381 if device .get ("power" ) is not None :
373382 attributes .append (self ._map_power (device ))
374383 attributes .append (
375- self .build_attribute (device ["hiloId" ], "Status" , device ["state" ])
384+ self .build_attribute (
385+ device ["hiloId" ], "Status" , device ["state" ].lower () == self .OnState
386+ )
376387 )
377388 attributes .append (
378- self .build_attribute (device ["hiloId" ], "OnOff" , device ["state" ])
389+ self .build_attribute (
390+ device ["hiloId" ], "OnOff" , device ["state" ].lower () == self .OnState
391+ )
379392 )
380393 return attributes
381394
@@ -390,7 +403,9 @@ def _build_dimmer(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
390403 )
391404 )
392405 attributes .append (
393- self .build_attribute (device ["hiloId" ], "OnOff" , device ["state" ])
406+ self .build_attribute (
407+ device ["hiloId" ], "OnOff" , device ["state" ].lower () == self .OnState
408+ )
394409 )
395410 return attributes
396411
@@ -420,7 +435,9 @@ def _build_light(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
420435 )
421436 )
422437 attributes .append (
423- self .build_attribute (device ["hiloId" ], "OnOff" , device ["state" ])
438+ self .build_attribute (
439+ device ["hiloId" ], "OnOff" , device ["state" ].lower () == self .OnState
440+ )
424441 )
425442 return attributes
426443
0 commit comments