diff --git a/custom_components/porscheconnect/__init__.py b/custom_components/porscheconnect/__init__.py old mode 100644 new mode 100755 index c2deb53..404cd61 --- a/custom_components/porscheconnect/__init__.py +++ b/custom_components/porscheconnect/__init__.py @@ -172,6 +172,14 @@ async def _update_data_for_vehicle(self, vehicle): for item in vdata["chargingProfiles"]["profiles"] } ) + + vdata["timersDict"] = {} + vdata["currentTimerId"] = None + for item in vdata.get("timers", []): + if item.get("active", False) and vdata["currentTimerId"] is None: + vdata["currentTimerId"] = item["timerID"] + vdata["timersDict"].update({item["timerID"]: item}) + if vdata["services"]["vehicleServiceEnabledMap"]["CF"] == "ENABLED": vdata.update(await self.controller.getPosition(vin)) return vdata @@ -225,7 +233,7 @@ async def _async_update_data(self): sensor_meta, sensor_data, ) - if sensor_data is not None: + if sensor_data is not None or len(sensor_meta.attributes) > 0: ha_type = "sensor" if isinstance(sensor_meta, SwitchMeta): ha_type = "switch" diff --git a/custom_components/porscheconnect/const.py b/custom_components/porscheconnect/const.py index 6f9709b..f490f9d 100644 --- a/custom_components/porscheconnect/const.py +++ b/custom_components/porscheconnect/const.py @@ -125,6 +125,12 @@ class SensorAttr: "mdi:battery-charging", attributes=[SensorAttr("profiles", "chargingProfilesDict")], ), + SensorMeta( + "charging timer", + "currentTimerId", + "mdi:car-clock", + attributes=[SensorAttr("timers", "timersDict")], + ), SwitchMeta( "climate", "directClimatisation.climatisationState", @@ -176,6 +182,7 @@ class SensorAttr: "remainingRanges.electricalRange.distance": "range", "chargingStatus": "charger", "chargingProfiles.currentProfileId": "charging profile", + "currentTimerId": "charging timer", "directClimatisation.climatisationState": "climatisation", "directCharge.isActive": "direct charge", "doors.overallLockStatus": "door lock",