@@ -8,7 +8,8 @@ class GraphqlValueMapper:
88 """
99 A class to map GraphQL values to DeviceReading instances.
1010 """
11-
11+ OnState = "on"
12+
1213 def map_query_values (self , values : Dict [str , Any ]) -> list [Dict [str , Any ]]:
1314 readings : list [Dict [str , Any ]] = []
1415 for device in values :
@@ -358,7 +359,7 @@ def _build_charge_controller(self, device: Dict[str, Any]) -> list[Dict[str, Any
358359 )
359360 attributes .append (
360361 self .build_attribute (
361- device ["hiloId" ], "OnOff" , device ["state" ].lower () == "on"
362+ device ["hiloId" ], "OnOff" , device ["state" ].lower () == self . OnState
362363 )
363364 )
364365 return attributes
@@ -380,12 +381,12 @@ def _build_switch(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
380381 attributes .append (self ._map_power (device ))
381382 attributes .append (
382383 self .build_attribute (
383- device ["hiloId" ], "Status" , device ["state" ].lower () == "on"
384+ device ["hiloId" ], "Status" , device ["state" ].lower () == self . OnState
384385 )
385386 )
386387 attributes .append (
387388 self .build_attribute (
388- device ["hiloId" ], "OnOff" , device ["state" ].lower () == "on"
389+ device ["hiloId" ], "OnOff" , device ["state" ].lower () == self . OnState
389390 )
390391 )
391392 return attributes
@@ -402,7 +403,7 @@ def _build_dimmer(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
402403 )
403404 attributes .append (
404405 self .build_attribute (
405- device ["hiloId" ], "OnOff" , device ["state" ].lower () == "on"
406+ device ["hiloId" ], "OnOff" , device ["state" ].lower () == self . OnState
406407 )
407408 )
408409 return attributes
@@ -434,7 +435,7 @@ def _build_light(self, device: Dict[str, Any]) -> list[Dict[str, Any]]:
434435 )
435436 attributes .append (
436437 self .build_attribute (
437- device ["hiloId" ], "OnOff" , device ["state" ].lower () == "on"
438+ device ["hiloId" ], "OnOff" , device ["state" ].lower () == self . OnState
438439 )
439440 )
440441 return attributes
0 commit comments