Hello everyone,
I wanted HA to notify me when a device is no longer available. So in theory the state would change from e.g. “OK” to “unknown”.
However, I have found that my sensors’ state does not change if the device is no longer available. It remains in the last known state.
My sensor:
- platform: mqtt
state_topic: stat/EQ3/001A2208B97D
name: "eQ-3 Battery LR"
value_template: >
{{ value_json.battery }}
icon: hass:battery
My automation
- id: '1634910544401'
alias: eQ-3 Battery LOW (Living Room)
description: ''
trigger:
- platform: state
entity_id:
- sensor.eq_3_battery_lr
from: 'GOOD'
to: 'LOW'
- platform: state
entity_id:
- sensor.eq_3_battery_lr
from: 'GOOD'
to: 'unknown'
for:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- platform: state
entity_id:
- sensor.eq_3_battery_lr
from: 'LOW'
to: 'unknown'
for:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
condition: []
action:
- service: notify.mobile_app_sm_g975f
data:
message: eQ-3 Battery LOW (Living Room)
title: eQ-3 Battery LOW (Living Room)
- service: notify.discord
data:
message: eQ-3 Battery LOW (Living Room)
target: [!secret discord_target]
- service: telegram_bot.send_message
data:
message: eQ-3 Battery LOW (Living Room)
mode: parallel
max: 10
The reason for this is, that sometimes the device jumps from GOOD to dead. So the battery just dies without the state first being low.
But once this happens, there is no new data and HA retains the value.
Is there a way to make HA check the state?
The device is integrated via an ESP32 device running Tasmota. So
Thermostat → bluetooth → ESP32 dev board (Tasmota) → wifi (MQTT) → Home Assistant.