Hello,
I have made a device (“wijnkoeler”) with tasmota and from time to time, it loses connection with its I2C sensor (DS18B20), which then becomes “unavailable” or disappears from the system. This is something I will address when I find time for the soldering iron, but in the meantime, my solution is to automatically cut power from the device for 10 seconds and then it comes back ok.
So I made a template sensor, called “Wijnkoeler Problem” which reliably detects both possible states of malfunctioning and which correctly triggers the power cutting automation.
When the problem occurs, as expected, I get “Wijnkoeler Problem changed to True by state of wijnkoeler DS18B20 Temperature became unavailable”, however, when the device comes back, the log entry states "Wijnkoeler Problem changed to False by state of ‘Some totally unrelated entity’ changed to ‘some value’ ".
Is there something I’m missing in my template ? Why is it mentioning an unrelated (?) entity ?
The template (returns True or False, checks whether the sensor is missing among all sensors OR, if it’s not missing, whether it is in state ‘unavailable’)
template:
- sensor:
- name: "Wijnkoeler Problem"
unique_id: wijnkoelerproblem
state: >
{{ ('sensor.wijnkoeler_ds18b20_temperature' not in (states.sensor | map(attribute='entity_id') | list)) or (states.sensor.wijnkoeler_ds18b20_temperature.state=='unavailable') }}
the automation (which, I think, is probably irrelevant. If “wijnkoeler_problem” goes True, turn of power, wait 10 seconds, turn on power again)
alias: WijnkoelerWD
description: Wijnkoeler Watchdog
trigger:
- platform: state
entity_id:
- sensor.wijnkoeler_problem
to: "True"
for:
hours: 0
minutes: 1
seconds: 0
from: "False"
condition: []
action:
- service: switch.turn_off
data: {}
target:
entity_id: switch.basic001
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: switch.turn_on
data: {}
target:
entity_id: switch.basic001
mode: single
and the logbook card
- type: logbook
entities:
- binary_sensor.wijnkoeler_door
- sensor.wijnkoeler_problem
hours_to_show: 24
title: Wijnkoeler Log