Skip to content

Commit ae2f463

Browse files
Merge pull request #12 from PineappleEmperor/PineappleDev
fix: total sensor functionality restored
2 parents b7b60b0 + 856e3dc commit ae2f463

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

custom_components/ocado/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
"python-dateutil==2.9.0"
1515
],
1616
"single_config_entry": true,
17-
"version": "1.0.6"
17+
"version": "1.0.7"
1818
}

custom_components/ocado/sensor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ def _handle_coordinator_update(self) -> None:
376376
order = ocado_data.get("total")
377377
if order is not None:
378378
result = set_total(self, order, now) # noqa: F841
379+
_LOGGER.debug("Set_total returned %s", result)
379380
else:
380381
self._attr_state = None
381382
self._attr_icon = "mdi:help-circle"
@@ -385,10 +386,16 @@ def _handle_coordinator_update(self) -> None:
385386
}
386387
if self.entity_id is not None:
387388
current = self.hass.states.get(self.entity_id)
389+
new = self._hass_custom_attributes
388390

389391
if current is None:
390392
self.async_write_ha_state()
391393
return
394+
395+
old = current.attributes
396+
if detect_attr_changes(new, old): # type: ignore
397+
_LOGGER.debug("Updating due to new attributes")
398+
self.async_write_ha_state()
392399

393400

394401
class OcadoUpcoming(CoordinatorEntity, SensorEntity): # type: ignore

0 commit comments

Comments
 (0)