Skip to content

Commit

Permalink
Merge pull request #325 from itchannel/1.54
Browse files Browse the repository at this point in the history
1.54 Changes
  • Loading branch information
itchannel authored Oct 12, 2023
2 parents 5e30114 + 90210fb commit c15e3e5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 19 deletions.
5 changes: 3 additions & 2 deletions custom_components/fordpass/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -55,8 +56,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"}}
Expand Down
1 change: 1 addition & 0 deletions custom_components/fordpass/fordpass_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions custom_components/fordpass/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion custom_components/fordpass/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"loggers": ["custom_components.fordpass"],
"requirements": [],
"ssdp": [],
"version": "0.1.53",
"version": "0.1.54",
"zeroconf": []
}
46 changes: 34 additions & 12 deletions custom_components/fordpass/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -185,15 +183,22 @@ 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"]
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":
Expand Down Expand Up @@ -473,11 +478,28 @@ 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
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

Expand Down
4 changes: 4 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit c15e3e5

Please sign in to comment.