Skip to content

Commit

Permalink
Update to new emerald_hws, use callback for update
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-w committed Apr 20, 2024
1 parent 779bc7d commit 4ce2b1b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/emerald_hws/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"homekit": {},
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/ross-w/emerald-hws-ha/issues",
"requirements": ["emerald_hws==0.0.7"],
"requirements": ["emerald_hws==0.0.9"],
"ssdp": [],
"version": "0.0.4",
"zeroconf": []
Expand Down
11 changes: 9 additions & 2 deletions custom_components/emerald_hws/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(self, hass, emerald_hws_instance, hws_uuid):
]
self._attr_icon = "mdi:water-boiler"
self._attr_precision = PRECISION_WHOLE
emerald_hws_instance.replaceCallback(self.update)

@property
def supported_features(self) -> int:
Expand Down Expand Up @@ -155,12 +156,18 @@ async def async_turn_off(self):
await self._hass.async_add_executor_job(self._emerald_hws.turnOff, self._hws_uuid)
#await self._emerald_hws.turnOff(self._hws_uuid)

async def async_update(self) -> None:
"""Update the water heater state."""
def update(self):
"""Update with values from HWS."""
state = self._emerald_hws.getFullStatus(self._hws_uuid)

if state is not None:
self._current_temperature = state.get("last_state").get("temp_current")
self._target_temperature = state.get("last_state").get("temp_set")
self._running = self._emerald_hws.isOn(self._hws_uuid)
self._current_mode = self._emerald_hws.currentMode(self._hws_uuid)

return

async def async_update(self) -> None:
"""Update the water heater state."""
await self._hass.async_add_executor_job(self.update)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ colorlog==6.8.2
homeassistant==2023.8.0
pip>=21.0,<24.1
ruff==0.3.7
emerald_hws==0.0.7
emerald_hws==0.0.9

0 comments on commit 4ce2b1b

Please sign in to comment.