danka621
(Daniel)
May 19, 2026, 9:46pm
1
I have defined an mqtt platform trigger sensor like this:
- trigger:
- platform: mqtt
topic: house/watermeter
sensor:
- name: "Water Meter"
state: "{{trigger.payload}}"
unit_of_measurement: "m³"
state_class: total_increasing
device_class: water
- name: "Water Meter Latest Reading"
state: "{{as_timestamp(now())|timestamp_custom('%Y-%m-%dT%H:%M:%S')}}"
I have a mobile app where I enter a value manually and post it on the mqtt topic, hence the construction.
The sensors above stores the water meter value in one sensor and the timestamp of the reading in the other. Note that the latest reading is just the timestamp of when the topic is read by home assistant. However it works. My latest reading was 3 days ago and the timestamp also reflects that. When I reload my configuration, the timestamp is also preserved like i want. However, there is a short time span during the reloading that the latest-reading-sensor reports "null" and so any automation based on that time sensor triggers.
How can it be that the timestamp sensor report null?
danka621
(Daniel)
May 19, 2026, 10:44pm
3
Example of automation that triggers:
alias: Laundryroom
description: ""
triggers:
- trigger: state
entity_id:
- sensor.water_meter_latest_reading
actions:
- action: input_select.select_option
metadata: {}
target:
entity_id: input_select.daniels_location
data:
option: Laundryroom
mode: single
danka621
(Daniel)
May 19, 2026, 10:46pm
4
Trace for automation going from valid state to null:
this:
entity_id: automation.laundryroom
state: 'on'
attributes:
id: '1778965916131'
last_triggered: '2026-05-19T21:20:22.121102+00:00'
mode: single
current: 0
friendly_name: Laundryroom
last_changed: '2026-05-19T21:25:33.839260+00:00'
last_reported: '2026-05-19T21:25:33.839260+00:00'
last_updated: '2026-05-19T21:25:33.839260+00:00'
context:
id: 01KS122E0FAS2C80ER89HMFVWY
parent_id: null
user_id: null
trigger:
id: '0'
idx: '0'
alias: null
platform: state
entity_id: sensor.water_meter_latest_reading
from_state:
entity_id: sensor.water_meter_latest_reading
state: '2026-05-16T22:42:07'
attributes:
friendly_name: Water Meter Latest Reading
last_changed: '2026-05-19T21:20:22.096329+00:00'
last_reported: '2026-05-19T21:20:22.096329+00:00'
last_updated: '2026-05-19T21:20:22.096329+00:00'
context:
id: 01KS11RXJG02XC58G8CYE5MW4G
parent_id: null
user_id: null
to_state: null
for: null
attribute: null
description: state of sensor.water_meter_latest_reading
danka621
(Daniel)
May 19, 2026, 10:48pm
5
And the trace a tiny bit later showing state going from null to its previous value:
this:
entity_id: automation.laundryroom
state: 'on'
attributes:
id: '1778965916131'
last_triggered: '2026-05-19T21:20:22.121102+00:00'
mode: single
current: 0
friendly_name: Laundryroom
last_changed: '2026-05-19T21:25:33.839260+00:00'
last_reported: '2026-05-19T21:25:33.839260+00:00'
last_updated: '2026-05-19T21:25:33.839260+00:00'
context:
id: 01KS122E0FAS2C80ER89HMFVWY
parent_id: null
user_id: null
trigger:
id: '0'
idx: '0'
alias: null
platform: state
entity_id: sensor.water_meter_latest_reading
from_state: null
to_state:
entity_id: sensor.water_meter_latest_reading
state: '2026-05-16T22:42:07'
attributes:
friendly_name: Water Meter Latest Reading
last_changed: '2026-05-19T21:25:50.172552+00:00'
last_reported: '2026-05-19T21:25:50.172552+00:00'
last_updated: '2026-05-19T21:25:50.172552+00:00'
context:
id: 01KS122XYW02QYJFZZBV8PG2Z9
parent_id: null
user_id: null
for: null
attribute: null
description: state of sensor.water_meter_latest_reading
tom_l
May 20, 2026, 1:02am
6
Try:
triggers:
- trigger: state
entity_id:
- sensor.water_meter_latest_reading
not_to:
- unknown
- unavailable