From 386756b5872c93a2e542b479c07fa1d03b9f4c77 Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 12 Oct 2023 19:32:50 +1000 Subject: [PATCH 1/4] Added 90 second delay before checking lock command --- custom_components/fordpass/fordpass_new.py | 1 + custom_components/fordpass/lock.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/custom_components/fordpass/fordpass_new.py b/custom_components/fordpass/fordpass_new.py index c63e736..2a8e856 100644 --- a/custom_components/fordpass/fordpass_new.py +++ b/custom_components/fordpass/fordpass_new.py @@ -585,6 +585,7 @@ def __request_and_poll_command(self, command, vin=None): _LOGGER.debug(r.status_code) _LOGGER.debug(r.text) if r.status_code == 201: + time.sleep(90) return True return False diff --git a/custom_components/fordpass/lock.py b/custom_components/fordpass/lock.py index 1a500a4..3d574b0 100644 --- a/custom_components/fordpass/lock.py +++ b/custom_components/fordpass/lock.py @@ -33,7 +33,7 @@ def __init__(self, coordinator): async def async_lock(self, **kwargs): """Locks the vehicle.""" - # self._attr_is_locking = True + self._attr_is_locking = True self.async_write_ha_state() _LOGGER.debug("Locking %s", self.coordinator.vin) status = await self.coordinator.hass.async_add_executor_job( @@ -42,20 +42,20 @@ async def async_lock(self, **kwargs): _LOGGER.debug(status) await self.coordinator.async_request_refresh() _LOGGER.debug("Locking here") - # self._attr_is_locking = False + self._attr_is_locking = False self.async_write_ha_state() async def async_unlock(self, **kwargs): """Unlocks the vehicle.""" _LOGGER.debug("Unlocking %s", self.coordinator.vin) - # self._attr_is_unlocking = True + self._attr_is_unlocking = True self.async_write_ha_state() status = await self.coordinator.hass.async_add_executor_job( self.coordinator.vehicle.unlock ) _LOGGER.debug(status) await self.coordinator.async_request_refresh() - # self._attr_is_unlocking = False + self._attr_is_unlocking = False self.async_write_ha_state() @property From 04ab7702fc9c74b0fce7af5777c2d22e95265a17 Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 12 Oct 2023 20:00:17 +1000 Subject: [PATCH 2/4] Add diesel system status support --- custom_components/fordpass/const.py | 4 ++-- custom_components/fordpass/sensor.py | 33 ++++++++++++++++++---------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/custom_components/fordpass/const.py b/custom_components/fordpass/const.py index 40a3b45..d136a47 100644 --- a/custom_components/fordpass/const.py +++ b/custom_components/fordpass/const.py @@ -55,8 +55,8 @@ "remoteStartStatus": {"icon": "mdi:remote"}, # "zoneLighting": {"icon": "mdi:spotlight-beam"}, "messages": {"icon": "mdi:message-text"}, - # "dieselSystemStatus": {"icon": "mdi:smoking-pipe"}, - # "exhaustFluidLevel": {"icon": "mdi:barrel"} + "dieselSystemStatus": {"icon": "mdi:smoking-pipe"}, + "exhaustFluidLevel": {"icon": "mdi:barrel"} } SWITCHES = {"ignition": {"icon": "hass:power"}, "guardmode": {"icon": "mdi:shield-key"}} diff --git a/custom_components/fordpass/sensor.py b/custom_components/fordpass/sensor.py index bb876f6..818c9c3 100644 --- a/custom_components/fordpass/sensor.py +++ b/custom_components/fordpass/sensor.py @@ -35,13 +35,11 @@ async def async_setup_entry(hass, config_entry, async_add_entities): if "xevBatteryChargeEvent" in sensor.coordinator.data["events"]: sensors.append(sensor) elif key == "dieselSystemStatus": - if sensor.coordinator.data.get("dieselSystemStatus", {}): - if sensor.coordinator.data.get("dieselSystemStatus", {}).get("filterRegenerationStatus"): - sensors.append(sensor) + if "dieselExhaustFilterStatus" in sensor.coordinator.data["metrics"]: + sensors.append(sensor) elif key == "exhaustFluidLevel": - if sensor.coordinator.data.get("dieselSystemStatus", {}): - if sensor.coordinator.data.get("dieselSystemStatus", {}).get("exhaustFluidLevel"): - sensors.append(sensor) + if "dieselExhaustFluidLevel" in sensor.coordinator.data["metrics"]: + sensors.append(sensor) else: sensors.append(sensor) async_add_entities(sensors, True) @@ -185,12 +183,12 @@ def get_value(self, ftype): return None return len(self.coordinator.data["messages"]) if self.sensor == "dieselSystemStatus": - if self.data["dieselSystemStatus"]["filterRegenerationStatus"] is not None: - return self.data["dieselSystemStatus"]["filterRegenerationStatus"] + if "dieselExhaustFilterStatus" in self.data: + return self.data["dieselExhaustFilterStatus"]["value"] return "Not Supported" if self.sensor == "exhaustFluidLevel": - if "value" in self.data["dieselSystemStatus"]["exhaustFluidLevel"]: - return self.data["dieselSystemStatus"]["exhaustFluidLevel"]["value"] + if "dieselExhaustFluidLevel" in self.data: + return self.data["dieselExhaustFluidLevel"]["value"] return "Not Supported" if self.sensor == "speed": return self.data[self.sensor]["value"] @@ -473,9 +471,20 @@ def get_value(self, ftype): messages[value["messageSubject"]] = value["createdDate"] return messages if self.sensor == "dieselSystemStatus": - return self.data["dieselSystemStatus"] + if "dieselExhaustOverTemp" in self.data["indicators"]: + return { + "Diesel Exhaust Over Temp": self.data["indicators"]["dieselExhaustOverTemp"]["value"] + } + return None if self.sensor == "exhaustFluidLevel": - return self.data["dieselSystemStatus"] + exhaustdata = {} + if "dieselExhaustFluidLevelRangeRemaining" in self.data: + exhaustdata["Exhaust Fluid Range"] = self.data["dieselExhaustFluidLevelRangeRemaining"]["value"] + if "dieselExhaustFluidLow" in self.data["indicators"]: + exhaustdata["Exhaust Fluid Low"] = self.data["indicators"]["dieselExhaustFluidLow"]["value"] + if "dieselExhaustFluidSystemFault" in self.data["indicators"]: + exhaustdata["Exhaust Fluid System Fault"] = self.data["indicators"]["dieselExhaustFluidSystemFault"]["value"] + return exhaustdata if self.sensor == "speed": return None return None From 588e066022219b94efdeeab19dee5a21534d6798 Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 12 Oct 2023 20:10:21 +1000 Subject: [PATCH 3/4] Add indicators/warning sensor --- custom_components/fordpass/const.py | 1 + custom_components/fordpass/sensor.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/custom_components/fordpass/const.py b/custom_components/fordpass/const.py index d136a47..a9093a4 100644 --- a/custom_components/fordpass/const.py +++ b/custom_components/fordpass/const.py @@ -44,6 +44,7 @@ "elVeh": {"icon": "mdi:ev-station"}, "elVehCharging": {"icon": "mdi:ev-station"}, "speed": {"icon": "mdi:speedometer"}, + "indicators": {"icon": "mdi:engine-outline"}, # "deepSleepInProgress": { # "icon": "mdi:power-sleep", # "name": "Deep Sleep Mode Active", diff --git a/custom_components/fordpass/sensor.py b/custom_components/fordpass/sensor.py index 818c9c3..54a6775 100644 --- a/custom_components/fordpass/sensor.py +++ b/custom_components/fordpass/sensor.py @@ -192,6 +192,13 @@ def get_value(self, ftype): return "Not Supported" if self.sensor == "speed": return self.data[self.sensor]["value"] + if self.sensor == "indicators": + alerts = 0 + for indicator in self.data["indicators"]: + if "value" in indicator: + if indicator["value"] == True: + alert +=1 + return alerts return None if ftype == "measurement": if self.sensor == "odometer": @@ -487,6 +494,12 @@ def get_value(self, ftype): return exhaustdata if self.sensor == "speed": return None + if self.sensor == "indicators": + alerts = {} + for key, value in self.data["indicators"].items(): + if "value" in value: + alerts[key] = value["value"] + return alerts return None return None From 90210fb75c289f863a6173a953645c06ccba46f9 Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 12 Oct 2023 20:12:18 +1000 Subject: [PATCH 4/4] update versioning --- custom_components/fordpass/manifest.json | 2 +- info.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/fordpass/manifest.json b/custom_components/fordpass/manifest.json index a02b2cd..ccc9e92 100644 --- a/custom_components/fordpass/manifest.json +++ b/custom_components/fordpass/manifest.json @@ -12,6 +12,6 @@ "loggers": ["custom_components.fordpass"], "requirements": [], "ssdp": [], - "version": "0.1.53", + "version": "0.1.54", "zeroconf": [] } \ No newline at end of file diff --git a/info.md b/info.md index 1261184..6995b00 100644 --- a/info.md +++ b/info.md @@ -1,4 +1,8 @@ ## **Changelog** +### Version 1.54 +- Fixed lock/unlock status (Waits 90seconds before checking command has completed) +- Added back diesel sensors +- Added indicator/warning sensor (Shows any faults on the vehicle) ### Version 1.53 - Updated vehicle endpoint to use new Autonomics API - Added secondary Autonomic token