Hi,
I have a PTLevel water level indicator that I’ve recently implemented in my home assistant configuration using the below code
sensor:
- platform: rest
name: waterlevel
resource: http://192.168.1.56/get_sensors
scan_interval: 60
value_template: '{{ (value_json.local_s | regex_findall_index("1\":(-?\d+\.?\d+)") | float - 65) | multiply(0.6289308176100629) | round(0) }}'
unit_of_measurement: "%"
It’s a rough one, so any suggestions to improve it is more than welcome. Anyway, the code works, I get the value correctly and display them correctly. I have one issue: when there is a power outage (frequent where I live), I get the below error (obviously) in the logs and the value in history shows as 0 (also triggers automation because tank is empty) before it recovers:
2021-06-25 12:00:29 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.56/get_sensors failed with
So how can I avoid the 0’s in my graph and tell the sensor to skip recording 0 when it fails to connect?
I also want to have a long history of the data stored, what’s the easiest and most straightforward way?