Skip to content

Commit 54f68ca

Browse files
committed
feat: Updated update config service to re-evaluate straight away (5 minutes dev time)
1 parent 4ff880e commit 54f68ca

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

_docs/services.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ The following services are available if you have set up at least one [target tim
5454

5555
For updating a given [target timeframe's](./setup/target_timeframe.md) config. This allows you to change target timeframes sensors dynamically based on other outside criteria (e.g. you need to adjust the target hours to top up home batteries).
5656

57+
!!! warning
58+
59+
This will cause the sensor to re-evaluate the target times, which may result in different times being picked.
60+
5761
| Attribute | Optional | Description |
5862
| ------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------- |
5963
| `target.entity_id` | `no` | The name of the target sensor whose configuration is to be updated. |
@@ -126,6 +130,10 @@ The following services are available if you have set up at least one [rolling ta
126130
127131
For updating a given [rolling target timeframe's](./setup/rolling_target_timeframe.md) config. This allows you to change rolling target timeframes sensors dynamically based on other outside criteria (e.g. you need to adjust the target hours to top up home batteries).
128132
133+
!!! warning
134+
135+
This will cause the sensor to re-evaluate the target times, which may result in different times being picked.
136+
129137
| Attribute | Optional | Description |
130138
| ------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------- |
131139
| `target.entity_id` | `no` | The name of the target sensor whose configuration is to be updated. |

custom_components/target_timeframes/entities/rolling_target_timeframe.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ async def async_update_rolling_target_timeframe_config(self, target_hours=None,
297297
self._config = config
298298
self._attributes = self._config.copy()
299299
self._target_timeframes = []
300+
await self.async_update()
300301
self.async_write_ha_state()
301302

302303
if persist_changes:

custom_components/target_timeframes/entities/target_timeframe.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ async def async_update_target_timeframe_config(self, target_start_time=None, tar
329329
self._config = config
330330
self._attributes = self._config.copy()
331331
self._target_timeframes = []
332+
await self.async_update()
332333
self.async_write_ha_state()
333334

334335
if persist_changes:

0 commit comments

Comments
 (0)