Skip to content

Commit

Permalink
Added data update after set_peak shaving (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
io-debug authored Oct 20, 2023
1 parent 52af6c1 commit 6f991e2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions custom_components/senec/service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
""" Services for SENEC Device"""

from datetime import datetime
from homeassistant.util import slugify
from homeassistant.config_entries import ConfigEntry


class SenecService():
Expand All @@ -26,11 +28,8 @@ async def set_peakshaving(self, call):
new_peak_shaving = {"mode": mode, "capacity": capacity, "end_time": end_time}
await self._coordinator.senec.set_peak_shaving(new_peak_shaving)

# Force update
# registry = entity_registry.async_get(self._hass)
# peakshaving_mode_key = f"sensor.{slugify(ConfigEntry.title)}_peakshaving_mode".lower()
# entity = registry.async_get(peakshaving_mode_key)
# entity.async_schedule_update_ha_state(force_refresh=True)
# Force update of data
await self._coordinator.async_refresh()

return True
except ValueError:
Expand Down

0 comments on commit 6f991e2

Please sign in to comment.