Skip to content

Commit 4023d5c

Browse files
authored
Merge pull request #6 from Syax89/claude/code-review-testing-o31VM
Claude/code review testing o31 vm
2 parents 1fcac9b + 6eafd8c commit 4023d5c

File tree

7 files changed

+37
-8
lines changed

7 files changed

+37
-8
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project are documented in this file.
44

5+
## [1.4.8] - 2026-03-14
6+
7+
### Fixed
8+
- **Tire Pressure Sensors**: Fixed all four tire pressure sensors showing `0 PSI` instead of "unavailable" when no data is present from the vehicle.
9+
- **Circuit Breaker Recovery**: Fixed the circuit breaker not resetting its failure counter after the cooldown period, which caused it to re-open immediately on the first subsequent error.
10+
- **Entity Stability**: Fixed a `KeyError` crash that occurred when a vehicle was removed from the Geotab fleet while the integration was running. Entities now gracefully become "unavailable".
11+
- **Code Cleanup**: Removed unused `DeviceInfo` import from `device_tracker.py`.
12+
513
## [1.4.7] - 2026-03-08
614

715
### Fixed

custom_components/geotab/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ async def async_update_data():
7373
raise UpdateFailed(f"Circuit breaker open, retrying in {remaining}s")
7474
_LOGGER.info("Geotab circuit breaker: attempting reset.")
7575
circuit_open_since = None
76+
consecutive_failures = 0
7677

7778
# Determine if we should fetch trips this cycle
7879
now = dt_util.utcnow().timestamp()

custom_components/geotab/device_tracker.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from homeassistant.components.device_tracker import SourceType, TrackerEntity
88
from homeassistant.config_entries import ConfigEntry
99
from homeassistant.core import HomeAssistant, callback
10-
from homeassistant.helpers.entity import DeviceInfo
1110
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1211
from homeassistant.helpers.update_coordinator import (
1312
DataUpdateCoordinator,

custom_components/geotab/entity.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ def __init__(
2222
super().__init__(coordinator)
2323
self._device_id = device_id
2424

25+
@property
26+
def available(self) -> bool:
27+
"""Return True if the device is still present in coordinator data."""
28+
return super().available and self._device_id in self.coordinator.data
29+
2530
@property
2631
def device_data(self) -> dict:
2732
"""Return the device data for this entity."""
28-
return self.coordinator.data[self._device_id]
33+
return self.coordinator.data.get(self._device_id, {})
2934

3035
@property
3136
def device_info(self) -> DeviceInfo:

custom_components/geotab/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"iot_class": "cloud_polling",
88
"issue_tracker": "https://github.com/Syax89/geotab-hacs-integration/issues",
99
"requirements": ["mygeotab>=0.9.1,<1.0.0"],
10-
"version": "1.4.7"
10+
"version": "1.4.8"
1111
}
1212

custom_components/geotab/sensor.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ class GeotabSensorEntityDescription(SensorEntityDescription):
255255
state_class=SensorStateClass.MEASUREMENT,
256256
entity_category=EntityCategory.DIAGNOSTIC,
257257
suggested_display_precision=1,
258-
value_fn=lambda data: (data.get("tire_pressure_front_left") or 0) * PA_TO_PSI,
258+
value_fn=lambda data: (
259+
data.get("tire_pressure_front_left") * PA_TO_PSI
260+
if data.get("tire_pressure_front_left") is not None
261+
else None
262+
),
259263
),
260264
GeotabSensorEntityDescription(
261265
key="tire_pressure_front_right",
@@ -266,7 +270,11 @@ class GeotabSensorEntityDescription(SensorEntityDescription):
266270
state_class=SensorStateClass.MEASUREMENT,
267271
entity_category=EntityCategory.DIAGNOSTIC,
268272
suggested_display_precision=1,
269-
value_fn=lambda data: (data.get("tire_pressure_front_right") or 0) * PA_TO_PSI,
273+
value_fn=lambda data: (
274+
data.get("tire_pressure_front_right") * PA_TO_PSI
275+
if data.get("tire_pressure_front_right") is not None
276+
else None
277+
),
270278
),
271279
GeotabSensorEntityDescription(
272280
key="tire_pressure_rear_left",
@@ -277,7 +285,11 @@ class GeotabSensorEntityDescription(SensorEntityDescription):
277285
state_class=SensorStateClass.MEASUREMENT,
278286
entity_category=EntityCategory.DIAGNOSTIC,
279287
suggested_display_precision=1,
280-
value_fn=lambda data: (data.get("tire_pressure_rear_left") or 0) * PA_TO_PSI,
288+
value_fn=lambda data: (
289+
data.get("tire_pressure_rear_left") * PA_TO_PSI
290+
if data.get("tire_pressure_rear_left") is not None
291+
else None
292+
),
281293
),
282294
GeotabSensorEntityDescription(
283295
key="tire_pressure_rear_right",
@@ -288,7 +300,11 @@ class GeotabSensorEntityDescription(SensorEntityDescription):
288300
state_class=SensorStateClass.MEASUREMENT,
289301
entity_category=EntityCategory.DIAGNOSTIC,
290302
suggested_display_precision=1,
291-
value_fn=lambda data: (data.get("tire_pressure_rear_right") or 0) * PA_TO_PSI,
303+
value_fn=lambda data: (
304+
data.get("tire_pressure_rear_right") * PA_TO_PSI
305+
if data.get("tire_pressure_rear_right") is not None
306+
else None
307+
),
292308
),
293309
GeotabSensorEntityDescription(
294310
key="accelerator_pos",

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async def test_api_get_data(mock_geotab_api):
6161
assert "device1" in data
6262
assert data["device1"]["name"] == "Test Vehicle"
6363
assert data["device1"]["isDriving"] is True
64-
assert data["device1"]["odometer"] == 100000
64+
assert data["device1"]["odometer"] == 53203700
6565

6666

6767
@pytest.mark.asyncio

0 commit comments

Comments
 (0)