Hi,
Just after some assistance with my obvious loack of coding knowledge.
I have a shelly uni connected to a water level sensor. This is all run by a 12v car battery that is toppped up with a solar panel.
The device during cloudy days sucks the battery too low and then powers off making the shelly uni become unavailable as a sensor.
I had thought that I could create a ‘dummy’ retained sensor in my config and then have an automation running that would keep reading valid outputs and keep a retained value. The goal is to to use this dummy sensor to ensure that I can clearly display the last known value on a dashboard. The following is the two bits of yaml I have.
In my config is the ‘dummy’ sensor.
- platform: template
sensors:
retained_sensor_value:
value_template: "{{ states('sensor.top_tank_water_level_adc') }}"
friendly_name: "Retained top tank voltage"
In my automations I have built this
alias: update water tank sensor
description: ""
trigger:
- platform: state
entity_id:
- sensor.top_tank_water_level_adc
condition:
- condition: template
value_template: "{{ is_number(state_attr('sensor.top_tank_water_level_adc', 'state')) }}"
action:
- service: homeassistant.update_entity
data: {}
target:
entity_id: sensor.retained_sensor_value
mode: single
I’m obviously doing something wrong because the ‘dummy’ sensor doesn’t retain the last valid value.
Pat