j3tang
(J Tang)
October 30, 2021, 1:34pm
1
It’s been quite a few months but I wanted to circle back on this post and take @Mariusthvdb up on his offer. Would love to see how you managed to make this happen.
I’ve got 2 use cases I would like to adapt this to:
To see how a group of (9) sensors are triggered in order (would like like to see if the same sensor is triggered multiple times).
To see the history of 1 particular sensor. This one sensor gets “text” fed to it, and would like to see what the text is, and when it occurrs.
nickrout
(Nick Rout)
October 31, 2021, 4:32am
2
Does logbook not work for that?
j3tang
(J Tang)
October 31, 2021, 2:36pm
3
Yes, it does. I’m just looking for something to be displayed on the front end in a markup card.
Would like for it to be displayed like what was created in the other thread linked to with the time, how long ago, and the actual text
sorry, been busy elsewhere in the communities… was this it? not sure if you want recently triggered automations, or last triggered sensors:
- type: custom:auto-entities
card:
type: entities
title: Running Automations
show_header_toggle: false
filter:
include:
- domain: automation
# state: 'on'
not:
attributes:
current: 0
options:
type: custom:template-entity-row
toggle: true
secondary: >
{{relative_time(state_attr(config.entity,'last_triggered'))}} ago,
{{state_attr(config.entity,'current') }} Running
hold_action: |
{
"action": "navigate",
"navigation_path": "/config/automation/trace/{{state_attr(config.entity,'friendly_name')}}"
}
sort:
method: last_triggered
reverse: true
- type: custom:auto-entities
card:
type: entities
title: Recent Automations
show_header_toggle: false
filter:
include:
- domain: automation
state: 'on'
last_triggered: '<= 5'
# not:
# attributes:
# current: 0
options:
type: custom:template-entity-row
toggle: true
secondary: >
{% if state_attr(config.entity,'last_triggered') %}
{{relative_time(state_attr(config.entity,'last_triggered'))}} ago
{% else %} Never triggered
{% endif %}
hold_action: |
{
"action": "navigate",
"navigation_path": "/config/automation/trace/{{state_attr(config.entity,'friendly_name')}}"
}
# action: navigate
# navigation_path: /config/automation/dashboard
exclude:
- attributes:
last_triggered: null
sort:
method: last_triggered
reverse: true
- type: custom:auto-entities
card:
type: entities
title: All Automations on
show_header_toggle: false
filter:
include:
- domain: automation
state: 'on'
last_triggered: '> 5'
options:
type: custom:template-entity-row
toggle: true
#active: '{{ (state_attr(config.entity, ''current'') | int) > 0 }}'
secondary: |
{%- if state_attr(config.entity, 'last_triggered') -%}
{{ relative_time(state_attr(config.entity, 'last_triggered')) }} ago
{%- else -%}
Never triggered
{%- endif -%}
hold_action: |
{
"action": "navigate",
"navigation_path": "/config/automation/trace/{{ config.entity.split('.')[1] }}"
}
exclude:
- attributes:
last_triggered: null
sort:
method: last_triggered
reverse: true
- type: custom:auto-entities
card:
type: entities
title: Automations off
show_header_toggle: false
filter:
include:
- domain: automation
state: 'off'
options:
secondary_info: last-triggered
exclude:
- attributes:
last_triggered: null
sort:
method: last_triggered
reverse: true
- type: custom:auto-entities
card:
type: entities
title: Automations off never triggered
show_header_toggle: false
filter:
include:
- domain: automation
state: 'off'
attributes:
last_triggered: null
- type: custom:auto-entities
card:
type: entities
title: Automations on never triggered
show_header_toggle: false
filter:
# template: >
# [
# {% for e in states.automation|selectattr('state','eq','on')
# |map(attribute='entity_id')|list %}
# { 'entity': '{{e}}', 'secondary_info': 'last-triggered' },
# {% endfor %}
# ]
include:
- domain: automation
state: 'on'
attributes:
last_triggered: null
options:
type: custom:template-entity-row
toggle: true
secondary: >
{% if state_attr(config.entity,'last_triggered') %}
{{relative_time(state_attr(config.entity,'last_triggered'))}} ago
{% else %} Never triggered
{% endif %}
hold_action: |
{
"action": "navigate",
"navigation_path": "/config/automation/trace/{{state_attr(config.entity,'friendly_name')}}"
}
#
# sort:
# method: last_triggered
# reverse: true
- type: custom:auto-entities
card:
type: entities
title: All Scripts
show_header_toggle: false
filter:
include:
- domain: script
options:
secondary_info: last-triggered
exclude:
- attributes:
last_triggered: null
sort:
method: attribute
attribute: last_triggered
reverse: true
j3tang
(J Tang)
November 6, 2021, 1:02pm
5
thanks Marius, I looked at the auto-entities card and still reading through the release thread and your samples above.
HarvsG
November 25, 2026, 9:40am
6
dev ← HarvsG:get-history
opened 11:22AM - 06 Oct 25 UTC
## Proposed change
Users can currently use `recorder.get_statistics` to retri… eve various summary statistics for statistics entities. However, there are valid use cases for accessing raw state history for non-statistics entities within automations and scripts.
Although this data is already available:
- via the History sidebar in the UI,
- Via the 'Download data' button in the history tab
- externally through the [/api/history REST endpoint](https://developers.home-assistant.io/docs/api/rest/#get-apihistory)
it has not previously been accessible internally within automations or scripts.
This PR introduces a new action: `recorder.get_history`.
```yaml
get_history:
fields:
start_time:
required: true
example: "2025-01-01 00:00:00"
selector:
datetime:
end_time:
required: false
example: "2025-01-02 00:00:00"
selector:
datetime:
entity_id:
required: true
example:
- sensor.hvac_action
- sensor.temperature
- input_boolean.away_mode
selector:
entity:
multiple: true
allow_truncation:
required: false
example: true
selector:
boolean:
```
Non-exhaustive list of possible uses
- Building complex conditions, e.g. abort a vacuum run if the entity has been `cleaning` more than 5 times in the past 7 days.
- Sequence detection - if specific pattern of state changes matters `home -> not_home -> work -> not_home -> home`
- Access to more than just the `old_state` and `new_state`
- Hysteresis and debouncing logic
- Conditional aggregation of statistics, e.g. summing `sensor.gas_usage` only while `sensor.hvac_action` is `heating`. (my use case)
- Providing contextual state history to LLMs or other analytic components - e.g helpful to know that it has rained recently when deciding whether to water the plants.
Opinionated implementation details:
- `state_changes_during_period()` may return “changes” where the state value is unchanged (e.g. after a device restart); these are filtered out.
- The first state segment’s `start` time is clamped to the provided `start_time`, not the time the state actually began.
- Similarly, the final state segment’s `end` time is clamped to the earlier of `end_time` and `now`, rather than being left as `None`
- The output structure mirrors `recorder.get_statistics`
- Provides explicit start and end time strings for each segment rather than just a `changed` or `start` time.
- Time strings are in UTC, not local
- Attributes are excluded.
Discussion points:
- Does this addition require an Architecture Discussion? -> Approved by core team below
- Should `start_time` be constrained based on recorder retention settings to prevent misleading or truncated results? 10 days? -> Truncated based on volume (`MAX_GET_HISTORY_RECORDS_PER_ENTITY = 1000`) fetched from the database, warning about recorder duration in the documentation
### Example usage
```yaml
action: recorder.get_history
data:
start_time: "2025-10-06 11:00:00"
entity_id:
- input_boolean.away_mode
- weather.forecast_home
```
### Example output
```yaml
history:
input_boolean.away_mode:
- start: "2025-10-06T10:00:00+00:00"
end: "2025-10-06T11:02:30.052671+00:00"
state: "off"
- start: "2025-10-06T11:02:30.052671+00:00"
end: "2025-10-06T11:03:17.792387+00:00"
state: "on"
weather.forecast_home:
- start: "2025-10-06T10:00:00+00:00"
end: "2025-10-06T10:18:35.986066+00:00"
state: partlycloudy
- start: "2025-10-06T10:18:35.986066+00:00"
end: "2025-10-06T11:03:17.792395+00:00"
state: sunny
```
## Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Additional information
- This PR fixes or closes issue: fixes #142194
- This PR is related to issue:
- Link to documentation pull request: https://github.com/home-assistant/home-assistant.io/pull/50342
- Link to developer documentation pull request:
- Link to frontend pull request:
## Checklist
- [x] I understand the code I am submitting and can explain how it works.
- [x] The code change is tested and works locally.
- [x] Local tests pass. **Your PR cannot be merged unless tests pass**
- [x] There is no commented out code in this PR.
- [x] I have followed the [development checklist][dev-checklist]
- [x] I have followed the [perfect PR recommendations][perfect-pr]
- [x] The code has been formatted using Ruff (`ruff format homeassistant tests`)
- [x] Tests have been added to verify that the new code works.
- [x] ~Any generated code has been carefully reviewed for correctness and compliance with project standards.~ NA
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated for [www.home-assistant.io][docs-repository]
If the code communicates with devices, web services, or third-party tools:
- [x] The [manifest file][manifest-docs] has all fields filled out correctly.
Updated and included derived files by running: `python3 -m script.hassfest`.
- [ ] New or updated dependencies have been added to `requirements_all.txt`.
Updated by running `python3 -m script.gen_requirements_all`.
- [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other [open pull requests][prs] in this repository.
[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure
[dev-checklist]: https://developers.home-assistant.io/docs/development_checklist/
[manifest-docs]: https://developers.home-assistant.io/docs/creating_integration_manifest/
[quality-scale]: https://developers.home-assistant.io/docs/integration_quality_scale_index/
[docs-repository]: https://github.com/home-assistant/home-assistant.io
[perfect-pr]: https://developers.home-assistant.io/docs/review-process/#creating-the-perfect-pr
A new recorder.get_history action should make it into 2026.12 as long as it survives the beta. This could allow you to fetch the history of multiple sensors and then use logic to determine the order.