Skip to content

Commit 4ff880e

Browse files
committed
feat: Added data source attribute to sensors
1 parent 127d3ad commit 4ff880e

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

custom_components/target_timeframes/entities/rolling_target_timeframe.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def __init__(self, hass: HomeAssistant, data_source_id: str, config_entry, confi
6868
self._attributes = self._config.copy()
6969
self._last_evaluated = None
7070
self._data_source_id = data_source_id
71+
self._attributes["data_source_id"] = self._data_source_id
7172

7273
is_rolling_target = True
7374
if CONFIG_TARGET_ROLLING_TARGET in self._config:
@@ -205,6 +206,7 @@ async def async_update(self):
205206
self._attributes["next_average_value"] = active_result["next_average_value"]
206207
self._attributes["next_min_value"] = active_result["next_min_value"]
207208
self._attributes["next_max_value"] = active_result["next_max_value"]
209+
self._attributes["data_source_id"] = self._data_source_id
208210

209211
self._state = active_result["is_active"]
210212

custom_components/target_timeframes/entities/target_timeframe.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def __init__(self, hass: HomeAssistant, data_source_id: str, config_entry, confi
7373
self._attributes = self._config.copy()
7474
self._last_evaluated = None
7575
self._data_source_id = data_source_id
76+
self._attributes["data_source_id"] = self._data_source_id
7677

7778
is_rolling_target = True
7879
if CONFIG_TARGET_ROLLING_TARGET in self._config:
@@ -86,6 +87,7 @@ def __init__(self, hass: HomeAssistant, data_source_id: str, config_entry, confi
8687

8788
self._data_source_data = initial_data if initial_data is not None else []
8889
self._target_timeframes = []
90+
8991

9092
self._hass = hass
9193
self.entity_id = generate_entity_id("binary_sensor.{}", self.unique_id, hass=hass)
@@ -230,6 +232,7 @@ async def async_update(self):
230232
self._attributes["next_average_value"] = active_result["next_average_value"]
231233
self._attributes["next_min_value"] = active_result["next_min_value"]
232234
self._attributes["next_max_value"] = active_result["next_max_value"]
235+
self._attributes["data_source_id"] = self._data_source_id
233236

234237
self._state = active_result["is_active"]
235238

0 commit comments

Comments
 (0)