Chapter: Configuration Change Notification and Logging
The Configuration Change Notification and Logging (Config Log Archive) feature allows the tracking of configuration changes entered on a per-session and per-user basis by implementing an archive function. This archive saves configuration logs that track each configuration command that is applied, who applied the command, the parser return code (PRC) for the command, and the time the command was applied. This feature also adds a notification mechanism that sends asynchronous notifications to registered applications whenever the configuration log changes. Before the introduction of the Configuration Change Notification and Logging feature, the only way to determine if the Cisco software configuration had changed was to save a copy of the running and startup configurations to a local computer and do a line-by-line comparison. This comparison method can identify changes that occurred, but does not specify the sequence in which the changes occurred, or the person responsible for the changes.
SELECT
states.state
FROM
states
WHERE
metadata_id = (
SELECT
metadata_id
FROM
states_meta
WHERE
entity_id = '<your_entity_id>'
)
AND FROM_UNIXTIME(last_updated_ts) >= DATE_SUB(NOW(), INTERVAL 30 DAY)
ORDER BY
last_updated_ts ASC
LIMIT
1;
Home Assistant在保存數值是放入states資料表,而state透過metadata_id去對應entity_id,因此需要先從states_meta去找到entity_id對應的metadata_id,然後再從states找metadata_id符合的記錄。