Skip to content

Commit

Permalink
Add DPF status
Browse files Browse the repository at this point in the history
  • Loading branch information
itchannel committed Jan 6, 2023
1 parent dc5904a commit 06cebfe
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions custom_components/fordpass/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"remoteStartStatus": {"icon": "mdi:remote"},
"zoneLighting": {"icon": "mdi:spotlight-beam"},
"messages": {"icon": "mdi:message-text"},
"dieselSystemStatus": {"icon": "mdi:smoking-pipe"},
"exhaustFluidLevel": {"icon": "mdi:barrel"}
}

SWITCHES = {"ignition": {"icon": "hass:power"}, "guardmode": {"icon": "mdi:shield-key"}}
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 @@ -5,7 +5,7 @@
"integration_type": "device",
"documentation": "https://github.com/itchannel/fordpass-ha",
"issue_tracker": "https://github.com/itchannel/fordpass-ha/issues",
"version": "0.1.42",
"version": "0.1.43",
"requirements": [],
"ssdp": [],
"zeroconf": [],
Expand Down
32 changes: 27 additions & 5 deletions custom_components/fordpass/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,25 @@
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Add the Entities from the config."""
entry = hass.data[DOMAIN][config_entry.entry_id]

sensors = []
for key, value in SENSORS.items():
sensor = CarSensor(entry, key, config_entry.options)
# Add support for only adding compatible sensors for the given vehicle
if key == "zoneLighting":
if "zoneLighting" in sensor.coordinator.data:
async_add_entities([sensor], True)
sensors.append(sensor)
elif key == "elVeh":
if sensor.coordinator.data["elVehDTE"] != None:
async_add_entities([sensor], True)
sensors.append(sensor)
elif key == "dieselSystemStatus":
if "dieselSystemStatus" in sensor.coordinator.data and sensor.coordinator.data["dieselSystemStatus"]["filterRegenerationStatus"] != None:
sensors.append(sensor)
elif key == "exhaustFluidLevel":
if "exhaustFluidLevel" in sensor.coordinator.data and sensor.coordinator.data["dieselSystemStatus"]["exhaustFluidLevel"] != None:
sensors.append(sensor)
else:
async_add_entities([sensor], True)

sensors.append(sensor)
async_add_entities(sensors, True)

class CarSensor(
FordPassEntity,
Expand Down Expand Up @@ -143,6 +149,16 @@ def get_value(self, ftype):
return None
else:
return len(self.coordinator.data["messages"])
elif self.sensor == "dieselSystemStatus":
if self.coordinator.data["dieselSystemStatus"]["filterRegenerationStatus"] != None:
return self.coordinator.data["dieselSystemStatus"]["filterRegenerationStatus"]
else:
return "Not Supported"
elif self.sensor == "exhaustFluidLevel":
if "value" in self.coordinator.data["dieselSystemStatus"]["exhaustFluidLevel"]:
return self.coordinator.data["dieselSystemStatus"]["exhaustFluidLevel"]["value"]
else:
return "Not Supported"
elif ftype == "measurement":
if self.sensor == "odometer":
if self.fordoptions[CONF_DISTANCE_UNIT] == "mi":
Expand Down Expand Up @@ -179,6 +195,8 @@ def get_value(self, ftype):
return None
elif self.sensor == "messages":
return "Messages"
elif self.sensor == "exhaustFluidLevel":
return "%"
elif ftype == "attribute":
if self.sensor == "odometer":
return self.coordinator.data[self.sensor].items()
Expand Down Expand Up @@ -392,6 +410,10 @@ def get_value(self, ftype):

messages[value["messageSubject"]] = value["createdDate"]
return messages
elif self.sensor == "dieselSystemStatus":
return self.coordinator.data["dieselSystemStatus"]
elif self.sensor == "exhaustFluidLevel":
return self.coordinator.data["dieselSystemStatus"]

@property
def name(self):
Expand Down
2 changes: 2 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## **Changelog**
### Version 1.43
- Add DPF status on supported vehicles
### Version 1.42
- Fix incorrect tire pressure units (Thanks @costr for debugging)
### Version 1.41
Expand Down

0 comments on commit 06cebfe

Please sign in to comment.