4444 SensorType ,
4545 ThermoLoc ,
4646 ToggleNameType ,
47+ WeatherType ,
4748)
4849from plugwise .exceptions import (
4950 ConnectionFailedError ,
@@ -527,7 +528,12 @@ def _get_measurement_data(self, entity_id: str) -> GwEntityData:
527528
528529 Collect the appliance-data based on entity_id.
529530 """
530- data : GwEntityData = {"binary_sensors" : {}, "sensors" : {}, "switches" : {}}
531+ data : GwEntityData = {
532+ "binary_sensors" : {},
533+ "sensors" : {},
534+ "switches" : {},
535+ "weather" : {},
536+ }
531537 # Get P1 smartmeter data from LOCATIONS
532538 entity = self .gw_entities [entity_id ]
533539 # !! DON'T CHANGE below two if-lines, will break stuff !!
@@ -771,29 +777,33 @@ def _get_gateway_measurements(self, entity_id: str, data: GwEntityData) -> None:
771777 """
772778 measurements = DEVICE_MEASUREMENTS
773779 if self ._is_thermostat and entity_id == self .gateway_id :
774- data ["weather" ] = {}
775780 for measurement , attrs in measurements .items ():
776781 value = self ._object_value (self ._home_location , measurement , attrs )
777782 if value is not None :
778783 if measurement == "wind_vector" :
779- value = value .split ("," )
784+ value_list : list [ str ] = str ( value ) .split ("," )
780785 data ["weather" ]["wind_speed" ] = format_measure (
781- value [0 ].strip ("(" ), getattr (attrs , ATTR_UNIT_OF_MEASUREMENT )
786+ value_list [0 ].strip ("(" ),
787+ getattr (attrs , ATTR_UNIT_OF_MEASUREMENT ),
782788 )
783789 data ["weather" ]["wind_bearing" ] = format_measure (
784- value [1 ].strip (")" ), getattr (attrs , ATTR_UNIT_OF_MEASUREMENT )
790+ value_list [1 ].strip (")" ),
791+ getattr (attrs , ATTR_UNIT_OF_MEASUREMENT ),
785792 )
786793 self ._count += 2
787794 else :
788- data ["weather" ][measurement ] = value
795+ key = cast (WeatherType , measurement )
796+ data ["weather" ][key ] = value
789797 self ._count += 1
790798
791- def _object_value (self , obj_id : str , measurement : str , attrs : str ) -> float | int | str | None :
799+ def _object_value (
800+ self , obj_id : str , measurement : str , attrs : DATA | UOM
801+ ) -> float | int | str | None :
792802 """Helper-function for smile.py: _get_entity_data().
793803
794804 Obtain the value/state for the given object from a location in DOMAIN_OBJECTS
795805 """
796- value : float | int | str | None = None
806+ value : str = ""
797807 search = self ._domain_objects
798808 locator = f'./location[@id="{ obj_id } "]/logs/point_log[type="{ measurement } "]/period/measurement'
799809 if (found := search .find (locator )) is not None :
@@ -802,14 +812,20 @@ def _object_value(self, obj_id: str, measurement: str, attrs: str) -> float | in
802812 case "humidity" :
803813 return int (float (value ))
804814 case "outdoor_temperature" :
805- return format_measure (value , getattr (attrs , ATTR_UNIT_OF_MEASUREMENT ))
815+ return format_measure (
816+ value , getattr (attrs , ATTR_UNIT_OF_MEASUREMENT )
817+ )
806818 case "solar_irradiance" :
807- return format_measure (value , getattr (attrs , ATTR_UNIT_OF_MEASUREMENT ))
819+ return format_measure (
820+ value , getattr (attrs , ATTR_UNIT_OF_MEASUREMENT )
821+ )
808822 case "weather_description" :
809823 return value
810824 case "wind_vector" :
811825 return value
812826
827+ return None
828+
813829 def _process_c_heating_state (self , data : GwEntityData ) -> None :
814830 """Helper-function for _get_measurement_data().
815831
0 commit comments