Skip to content

Commit 8025df4

Browse files
authored
Merge pull request #743 from Michael-CGN/master
added last_reported to state attributes
2 parents be3f98e + 1de2cd8 commit 8025df4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

custom_components/pyscript/state.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
_LOGGER = logging.getLogger(LOGGER_PATH + ".state")
1515

16-
STATE_VIRTUAL_ATTRS = {"entity_id", "last_changed", "last_updated"}
16+
STATE_VIRTUAL_ATTRS = {"entity_id", "last_changed", "last_updated", "last_reported"}
1717

1818

1919
class StateVal(str):
@@ -26,6 +26,7 @@ def __new__(cls, state):
2626
new_var.entity_id = state.entity_id
2727
new_var.last_updated = state.last_updated
2828
new_var.last_changed = state.last_changed
29+
new_var.last_reported = state.last_reported
2930
return new_var
3031

3132

docs/reference.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,13 @@ Here's an example using ``input_number``, assuming it has been configured to cre
262262
input_number.test.set_value(value=13)
263263
input_number.test.set_value(13)
264264
265-
Three additional virtual attribute values are available when you use a variable directly as
265+
Four additional virtual attribute values are available when you use a variable directly as
266266
``DOMAIN.entity.attr`` or call ``state.get("DOMAIN.entity.attr")``:
267267

268268
- ``entity_id`` is the DOMAIN.entity as string
269269
- ``last_changed`` is the last UTC time the state value was changed (not the attributes)
270270
- ``last_updated`` is the last UTC time the state entity was updated
271+
- ``last_reported``is the last UTC time the integration set the state of an entity, regardless of whether it changed or not
271272
272273
If you need to compute how many seconds ago the ``binary_sensor.test1`` state changed, you could
273274
do this:

0 commit comments

Comments
 (0)