I have created an ultrasonic sensor which is mounted into a sewer cover and measures the amount of capacity left in the sewer tank. This sensor is based on ESPhome. This sensor gets power supply only a couple hours a day and is offline for the rest of the day. When offline, it shows up as ‘unavailable’ and displays no data on the history graph. Is there a way to make HA display the last know value instead of ‘unavailable’ (e.g. the measurement value from when the sensor has been online for the last time)?
Did you find the way ?
I try tto do the same thing :
I have 4 sensor entities to get ink levels and a 5th to get status of my printer. When my printer is on, I have the ink levels like this :
When my printer is off :
I’d like to get the last ink levels with normal color drop icon when printer is off
and the update ink levels with personalised ink color (black, yellow, magenta, cyan) drop icon when printer is on
I looked around templates and icon_color with custom UI but without success
Thanks for you help
Sorry, I’m a newbie, can you explain what you did in the example above. I have a Shelly H+T sensor that only updates once an hour and i want to display the last known temperature until it becomes available again
Exactly the same thing happened here. I added the template and it display the values correctly however as soon as the sensor becomes unavailable the template values revert to “unknown”
I hade same problem and I have the solution only if you are connected to the cloud. So if your shelly is connected to the cloud you should create REST sensor which will pull data from the cloud.
platform: rest
name: temp_cloud_db # temperature reading from shelly cloud
unit_of_measurement: ‘°C’ #added unit of measurement, °C in my case
resource: https://shelly-5-eu.shelly.cloud/device/status # my shelly cloud server
method: POST
payload: ‘auth_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ #you sholud retrieve your from the app
scan_interval: 86400
headers:
User-Agent: Home Assistant
Content-Type: application/x-www-form-urlencoded
value_template: ‘{{ value_json.data.device_status.tmp.value }}’
With this I have new sensor in HA which retrieve temperature readings from the cloud.
Next step is creating TEMPLATE sensor for temperature which will take temperature from your shelly or in other case from cloud so You will never have NaN displayed.
I’m facing a very similar issue. ESP32 board with BMP280 temperature + pressure sensor, turning on for 30 seconds and then going to deep sleep, running EspHome but communicating with HomeAssistant via MQTT. This “unavailable” is poor usability, especially on the phone where history graph is tough to hit for last recorded values.
I’m completely new to HomeAssistant so I’d be grateful for some pointers where should I click or which yaml files should I edit. As for now, I’m running an auto-generated Lovelace dashboard.
I have a similar scenario looking for a solution: A Tasmota ESP8266 reporting the readings of HC-SR04 ultrasonic distance sensor via MQTT before going into DeepSleepTime.
On going into deep sleep, Tasmota obviously sends a MQTT LWT (Last Will Testament) indicating offline, which causes a value of unavailable. Here my typical readings:
This does not solve the root issue and unfortunately is also not an option for my Tasmota setup: Sorry – I was wrong.
If I get it right, the proposal in the referred thread is to reconfigure the MQTT sensor, so that HASS it no longer reacts on offline / online messages.