Sensor suddenly stops working until I restart HA

My ultrasonic sensor jsn-sr04t is working but its integration ESPHome / HA seems to have an issue. Suddenly it gets stuck in the same value. At that time I have 2 choices. Either I can use SQL and delete all the entries from that sensor or I can just restart HA. And then it will start updating the values again.

ESPHome logs always show the correct values, so the sensor is working properly.

Sem título

Configurarion.yaml:

sensor:
  - platform: filter
    name: "Nível da Caixa d'Água Ajustado"
    entity_id: sensor.sensor_nivel_caixa_superior_nivel_em_litros
    filters:
      - filter: outlier
        window_size: 4
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2
        
  - platform: filter
    name: "Nível Percentual da Caixa d'Água Ajustado"
    entity_id: sensor.sensor_nivel_caixa_superior_nivel_percentual
    filters:
      - filter: outlier
        window_size: 4
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2

Has anyone experienced this anomaly?

What do your esphome logs say?

INFO Reading configuration /config/esphome/sensor_nivel_caixa_superior.yaml...
INFO Detected timezone 'TZ' with UTC offset -3
INFO Starting log output from sensor_nivel_caixa_superior.local using esphome API
INFO Connecting to sensor_nivel_caixa_superior.local:6053 (xxxxxxxxxxxxxxx)
INFO Successfully connected to sensor_nivel_caixa_superior.local
[12:43:28][I][app:105]: ESPHome version 1.15.3 compiled on Dec  1 2020, 20:16:51
[12:43:28][C][wifi:443]: WiFi:
[12:43:28][C][wifi:303]:   SSID: [redacted]
[12:43:28][C][wifi:304]:   IP Address: xxxxxxxxxxxxxxx
[12:43:28][C][wifi:306]:   BSSID: [redacted]
[12:43:28][C][wifi:307]:   Hostname: 'sensor_nivel_caixa_superior'
[12:43:28][C][wifi:311]:   Signal strength: -75 dB ▂▄▆█
[12:43:28][C][wifi:315]:   Channel: 7
[12:43:28][C][wifi:316]:   Subnet: xxxxxxxxxxxxxxx
[12:43:28][C][wifi:317]:   Gateway: xxxxxxxxxxxxxxx
[12:43:28][C][wifi:318]:   DNS1: xxxxxxxxxxxxxxx
[12:43:28][C][wifi:319]:   DNS2: xxxxxxxxxxxxxxx
[12:43:28][C][uptime.sensor:030]: Uptime Sensor 'sensor_nivel_caixa_superior Uptime'
[12:43:28][C][uptime.sensor:030]:   Unit of Measurement: 's'
[12:43:28][C][uptime.sensor:030]:   Accuracy Decimals: 0
[12:43:28][C][uptime.sensor:030]:   Icon: 'mdi:timer-outline'
[12:43:28][C][logger:185]: Logger:
[12:43:28][C][logger:186]:   Level: DEBUG
[12:43:28][C][logger:187]:   Log Baud Rate: 115200
[12:43:28][C][logger:188]:   Hardware UART: UART0
[12:43:28][C][restart:021]: Restart Switch 'sensor_nivel_caixa_superior Restart'
[12:43:28][C][restart:021]:   Icon: 'mdi:restart'
[12:43:28][C][ultrasonic.sensor:035]: Ultrasonic Sensor 'sensor_nivel_caixa_superior Nível percentual'
[12:43:28][C][ultrasonic.sensor:035]:   Unit of Measurement: '%'
[12:43:28][C][ultrasonic.sensor:035]:   Accuracy Decimals: 0
[12:43:28][C][ultrasonic.sensor:035]:   Icon: 'mdi:arrow-expand-vertical'
[12:43:28][C][ultrasonic.sensor:036]:   Echo Pin: GPIO4 (Mode: INPUT)
[12:43:28][C][ultrasonic.sensor:037]:   Trigger Pin: GPIO5 (Mode: OUTPUT)
[12:43:28][C][ultrasonic.sensor:038]:   Pulse time: 10 µs
[12:43:28][C][ultrasonic.sensor:039]:   Timeout: 11661 µs
[12:43:28][C][ultrasonic.sensor:040]:   Update Interval: 10.0s
[12:43:29][C][ultrasonic.sensor:035]: Ultrasonic Sensor 'sensor_nivel_caixa_superior Nível em cm'
[12:43:29][C][ultrasonic.sensor:035]:   Unit of Measurement: 'cm'
[12:43:29][C][ultrasonic.sensor:035]:   Accuracy Decimals: 2
[12:43:29][C][ultrasonic.sensor:035]:   Icon: 'mdi:arrow-expand-vertical'
[12:43:29][C][ultrasonic.sensor:036]:   Echo Pin: GPIO4 (Mode: INPUT)
[12:43:29][C][ultrasonic.sensor:037]:   Trigger Pin: GPIO5 (Mode: OUTPUT)
[12:43:29][C][ultrasonic.sensor:038]:   Pulse time: 10 µs
[12:43:29][C][ultrasonic.sensor:039]:   Timeout: 11661 µs
[12:43:29][C][ultrasonic.sensor:040]:   Update Interval: 10.0s
[12:43:29][C][ultrasonic.sensor:035]: Ultrasonic Sensor 'sensor_nivel_caixa_superior Nível em litros'
[12:43:29][C][ultrasonic.sensor:035]:   Unit of Measurement: 'l'
[12:43:29][C][ultrasonic.sensor:035]:   Accuracy Decimals: 0
[12:43:29][C][ultrasonic.sensor:035]:   Icon: 'mdi:arrow-expand-vertical'
[12:43:29][C][ultrasonic.sensor:036]:   Echo Pin: GPIO4 (Mode: INPUT)
[12:43:29][C][ultrasonic.sensor:037]:   Trigger Pin: GPIO5 (Mode: OUTPUT)
[12:43:29][C][ultrasonic.sensor:038]:   Pulse time: 10 µs
[12:43:29][C][ultrasonic.sensor:039]:   Timeout: 11661 µs
[12:43:29][C][ultrasonic.sensor:040]:   Update Interval: 10.0s
[12:43:29][C][ultrasonic.sensor:035]: Ultrasonic Sensor 'sensor_nivel_caixa_superior Medição absoluta em cm'
[12:43:29][C][ultrasonic.sensor:035]:   Unit of Measurement: 'cm'
[12:43:29][C][ultrasonic.sensor:035]:   Accuracy Decimals: 2
[12:43:29][C][ultrasonic.sensor:035]:   Icon: 'mdi:arrow-expand-vertical'
[12:43:29][C][ultrasonic.sensor:036]:   Echo Pin: GPIO4 (Mode: INPUT)
[12:43:29][C][ultrasonic.sensor:037]:   Trigger Pin: GPIO5 (Mode: OUTPUT)
[12:43:29][C][ultrasonic.sensor:038]:   Pulse time: 10 µs
[12:43:29][C][ultrasonic.sensor:039]:   Timeout: 11661 µs
[12:43:29][C][ultrasonic.sensor:040]:   Update Interval: 10.0s
[12:43:29][C][homeassistant.time:010]: Home Assistant Time:
[12:43:29][C][homeassistant.time:011]:   Timezone: 'TZ3'
[12:43:29][C][version.text_sensor:021]: Version Text Sensor 'sensor_nivel_caixa_superior ESPHome Version'
[12:43:29][C][version.text_sensor:021]:   Icon: 'mdi:new-box'
[12:43:29][C][web_server:131]: Web Server:
[12:43:29][C][web_server:132]:   Address: sensor_nivel_caixa_superior.local:80
[12:43:29][C][ota:029]: Over-The-Air Updates:
[12:43:29][C][ota:030]:   Address: sensor_nivel_caixa_superior.local:8266
[12:43:29][C][api:095]: API Server:
[12:43:29][C][api:096]:   Address: sensor_nivel_caixa_superior.local:6053
[12:43:29][C][wifi_info:009]: WifiInfo IPAddress 'sensor_nivel_caixa_superior IP'
[12:43:29][C][wifi_signal.sensor:009]: WiFi Signal 'sensor_nivel_caixa_superior WiFi Signal'
[12:43:29][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dB'
[12:43:29][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[12:43:29][C][wifi_signal.sensor:009]:   Icon: 'mdi:wifi'
[12:43:29][C][wifi_info:010]: WifiInfo SSID 'sensor_nivel_caixa_superior SSID'
[12:43:29][C][wifi_info:011]: WifiInfo BSSID 'sensor_nivel_caixa_superior BSSID'
[12:43:34][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível em litros' - Got distance: 0.35 m
[12:43:34][D][sensor:092]: 'sensor_nivel_caixa_superior Nível em litros': Sending state 1898.42993 l with 0 decimals of accuracy
[12:43:34][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível percentual' - Got distance: 0.35 m
[12:43:34][D][sensor:092]: 'sensor_nivel_caixa_superior Nível percentual': Sending state 82.32227 % with 0 decimals of accuracy
[12:43:35][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Medição absoluta em cm' - Got distance: 0.35 m
[12:43:35][D][sensor:092]: 'sensor_nivel_caixa_superior Medição absoluta em cm': Sending state 34.90025 cm with 2 decimals of accuracy
[12:43:35][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível em cm' - Got distance: 0.35 m
[12:43:35][D][sensor:092]: 'sensor_nivel_caixa_superior Nível em cm': Sending state 62.51690 cm with 2 decimals of accuracy
[12:43:44][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível em litros' - Got distance: 0.35 m
[12:43:44][D][sensor:092]: 'sensor_nivel_caixa_superior Nível em litros': Sending state 1898.95093 l with 0 decimals of accuracy
[12:43:44][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível percentual' - Got distance: 0.35 m
[12:43:44][D][sensor:092]: 'sensor_nivel_caixa_superior Nível percentual': Sending state 82.36746 % with 0 decimals of accuracy
[12:43:45][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Medição absoluta em cm' - Got distance: 0.35 m
[12:43:45][D][sensor:092]: 'sensor_nivel_caixa_superior Medição absoluta em cm': Sending state 34.88310 cm with 2 decimals of accuracy
[12:43:45][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível em cm' - Got distance: 0.35 m
[12:43:45][D][sensor:092]: 'sensor_nivel_caixa_superior Nível em cm': Sending state 62.46545 cm with 2 decimals of accuracy
[12:43:48][D][sensor:092]: 'sensor_nivel_caixa_superior Uptime': Sending state 59076.81250 s with 0 decimals of accuracy
[12:43:54][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível em litros' - Got distance: 0.35 m
[12:43:54][D][sensor:092]: 'sensor_nivel_caixa_superior Nível em litros': Sending state 1898.42993 l with 0 decimals of accuracy
[12:43:54][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível percentual' - Got distance: 0.35 m
[12:43:54][D][sensor:092]: 'sensor_nivel_caixa_superior Nível percentual': Sending state 82.36746 % with 0 decimals of accuracy
[12:43:55][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Medição absoluta em cm' - Got distance: 0.35 m
[12:43:55][D][sensor:092]: 'sensor_nivel_caixa_superior Medição absoluta em cm': Sending state 34.93455 cm with 2 decimals of accuracy
[12:43:55][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível em cm' - Got distance: 0.35 m

It reads a totally different value than the one shown in lovelace. It will work properly after restarting HA. This problem occurs probably once a week.

So the esphome log shows the correct value, but it is not being reported correctly in home assistant?

What value is showing in states in dev tools?

Exactly!

About the value showed in dev tool, I will have to wait untill the problem happens again (maybe next week :wink: haha )

I have same problem

1 Like

So Here I am again with thse same problem and the logs.

This is my ESPHome log:

INFO Reading configuration /config/esphome/sensor_nivel_caixa_superior.yaml...
INFO Detected timezone 'TZ' with UTC offset -3
INFO Starting log output from sensor_nivel_caixa_superior.local using esphome API
INFO Connecting to sensor_nivel_caixa_superior.local:6053 (192.168.68.129)
INFO Successfully connected to sensor_nivel_caixa_superior.local
[11:53:03][I][app:105]: ESPHome version 1.15.3 compiled on Dec  1 2020, 20:16:51
[11:53:03][C][wifi:443]: WiFi:
[11:53:03][C][wifi:303]:   SSID: [redacted]
[11:53:03][C][wifi:304]:   IP Address: 192.168.68.129
[11:53:03][C][wifi:306]:   BSSID: [redacted]
[11:53:03][C][wifi:307]:   Hostname: 'sensor_nivel_caixa_superior'
[11:53:03][C][wifi:311]:   Signal strength: -71 dB ▂▄▆█
[11:53:03][C][wifi:315]:   Channel: 9
[11:53:03][C][wifi:316]:   Subnet: 255.255.255.0
[11:53:03][C][wifi:317]:   Gateway: 192.168.68.1
[11:53:03][C][wifi:318]:   DNS1: 181.213.132.4
[11:53:03][C][wifi:319]:   DNS2: 181.213.132.5
[11:53:03][C][uptime.sensor:030]: Uptime Sensor 'sensor_nivel_caixa_superior Uptime'
[11:53:03][C][uptime.sensor:030]:   Unit of Measurement: 's'
[11:53:03][C][uptime.sensor:030]:   Accuracy Decimals: 0
[11:53:03][C][uptime.sensor:030]:   Icon: 'mdi:timer-outline'
[11:53:03][C][logger:185]: Logger:
[11:53:03][C][logger:186]:   Level: DEBUG
[11:53:03][C][logger:187]:   Log Baud Rate: 115200
[11:53:03][C][logger:188]:   Hardware UART: UART0
[11:53:03][C][restart:021]: Restart Switch 'sensor_nivel_caixa_superior Restart'
[11:53:03][C][restart:021]:   Icon: 'mdi:restart'
[11:53:03][C][ultrasonic.sensor:035]: Ultrasonic Sensor 'sensor_nivel_caixa_superior Nível percentual'
[11:53:03][C][ultrasonic.sensor:035]:   Unit of Measurement: '%'
[11:53:03][C][ultrasonic.sensor:035]:   Accuracy Decimals: 0
[11:53:03][C][ultrasonic.sensor:035]:   Icon: 'mdi:arrow-expand-vertical'
[11:53:03][C][ultrasonic.sensor:036]:   Echo Pin: GPIO4 (Mode: INPUT)
[11:53:03][C][ultrasonic.sensor:037]:   Trigger Pin: GPIO5 (Mode: OUTPUT)
[11:53:03][C][ultrasonic.sensor:038]:   Pulse time: 10 µs
[11:53:03][C][ultrasonic.sensor:039]:   Timeout: 11661 µs
[11:53:03][C][ultrasonic.sensor:040]:   Update Interval: 10.0s
[11:53:03][C][ultrasonic.sensor:035]: Ultrasonic Sensor 'sensor_nivel_caixa_superior Nível em cm'
[11:53:03][C][ultrasonic.sensor:035]:   Unit of Measurement: 'cm'
[11:53:03][C][ultrasonic.sensor:035]:   Accuracy Decimals: 2
[11:53:03][C][ultrasonic.sensor:035]:   Icon: 'mdi:arrow-expand-vertical'
[11:53:03][C][ultrasonic.sensor:036]:   Echo Pin: GPIO4 (Mode: INPUT)
[11:53:03][C][ultrasonic.sensor:037]:   Trigger Pin: GPIO5 (Mode: OUTPUT)
[11:53:03][C][ultrasonic.sensor:038]:   Pulse time: 10 µs
[11:53:03][C][ultrasonic.sensor:039]:   Timeout: 11661 µs
[11:53:03][C][ultrasonic.sensor:040]:   Update Interval: 10.0s
[11:53:03][C][ultrasonic.sensor:035]: Ultrasonic Sensor 'sensor_nivel_caixa_superior Nível em litros'
[11:53:03][C][ultrasonic.sensor:035]:   Unit of Measurement: 'l'
[11:53:03][C][ultrasonic.sensor:035]:   Accuracy Decimals: 0
[11:53:03][C][ultrasonic.sensor:035]:   Icon: 'mdi:arrow-expand-vertical'
[11:53:03][C][ultrasonic.sensor:036]:   Echo Pin: GPIO4 (Mode: INPUT)
[11:53:03][C][ultrasonic.sensor:037]:   Trigger Pin: GPIO5 (Mode: OUTPUT)
[11:53:03][C][ultrasonic.sensor:038]:   Pulse time: 10 µs
[11:53:03][C][ultrasonic.sensor:039]:   Timeout: 11661 µs
[11:53:03][C][ultrasonic.sensor:040]:   Update Interval: 10.0s
[11:53:03][C][ultrasonic.sensor:035]: Ultrasonic Sensor 'sensor_nivel_caixa_superior Medição absoluta em cm'
[11:53:03][C][ultrasonic.sensor:035]:   Unit of Measurement: 'cm'
[11:53:03][C][ultrasonic.sensor:035]:   Accuracy Decimals: 2
[11:53:03][C][ultrasonic.sensor:035]:   Icon: 'mdi:arrow-expand-vertical'
[11:53:03][C][ultrasonic.sensor:036]:   Echo Pin: GPIO4 (Mode: INPUT)
[11:53:03][C][ultrasonic.sensor:037]:   Trigger Pin: GPIO5 (Mode: OUTPUT)
[11:53:03][C][ultrasonic.sensor:038]:   Pulse time: 10 µs
[11:53:03][C][ultrasonic.sensor:039]:   Timeout: 11661 µs
[11:53:03][C][ultrasonic.sensor:040]:   Update Interval: 10.0s
[11:53:03][C][homeassistant.time:010]: Home Assistant Time:
[11:53:03][C][homeassistant.time:011]:   Timezone: 'TZ3'
[11:53:03][C][version.text_sensor:021]: Version Text Sensor 'sensor_nivel_caixa_superior ESPHome Version'
[11:53:03][C][version.text_sensor:021]:   Icon: 'mdi:new-box'
[11:53:03][C][web_server:131]: Web Server:
[11:53:03][C][web_server:132]:   Address: sensor_nivel_caixa_superior.local:80
[11:53:04][C][ota:029]: Over-The-Air Updates:
[11:53:04][C][ota:030]:   Address: sensor_nivel_caixa_superior.local:8266
[11:53:04][C][api:095]: API Server:
[11:53:04][C][api:096]:   Address: sensor_nivel_caixa_superior.local:6053
[11:53:04][C][wifi_info:009]: WifiInfo IPAddress 'sensor_nivel_caixa_superior IP'
[11:53:04][C][wifi_signal.sensor:009]: WiFi Signal 'sensor_nivel_caixa_superior WiFi Signal'
[11:53:04][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dB'
[11:53:04][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[11:53:04][C][wifi_signal.sensor:009]:   Icon: 'mdi:wifi'
[11:53:04][C][wifi_info:010]: WifiInfo SSID 'sensor_nivel_caixa_superior SSID'
[11:53:04][C][wifi_info:011]: WifiInfo BSSID 'sensor_nivel_caixa_superior BSSID'
[11:53:08][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível em cm' - Got distance: 0.57 m
[11:53:08][D][sensor:092]: 'sensor_nivel_caixa_superior Nível em cm': Sending state 40.51345 cm with 2 decimals of accuracy
[11:53:09][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível percentual' - Got distance: 0.57 m
[11:53:09][D][sensor:092]: 'sensor_nivel_caixa_superior Nível percentual': Sending state 53.44519 % with 0 decimals of accuracy
[11:53:10][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível em litros' - Got distance: 0.57 m
[11:53:10][D][sensor:092]: 'sensor_nivel_caixa_superior Nível em litros': Sending state 1230.59595 l with 0 decimals of accuracy
[11:53:11][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Medição absoluta em cm' - Got distance: 0.57 m
[11:53:11][D][sensor:092]: 'sensor_nivel_caixa_superior Medição absoluta em cm': Sending state 56.85225 cm with 2 decimals of accuracy
[11:53:11][I][ota:046]: Boot seems successful, resetting boot loop counter.
[11:53:11][D][sensor:092]: 'sensor_nivel_caixa_superior WiFi Signal': Sending state -67.00000 dB with 0 decimals of accuracy
[11:53:18][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível em cm' - Got distance: 0.57 m
[11:53:18][D][sensor:092]: 'sensor_nivel_caixa_superior Nível em cm': Sending state 40.54775 cm with 2 decimals of accuracy
[11:53:19][D][ultrasonic.sensor:030]: 'sensor_nivel_caixa_superior Nível percentual' - Got distance: 0.57 m
[11:53:19][D][sensor:092]: 'sensor_nivel_caixa_superior Nível percentual': Sending state 53.44519 % with 0 decimals of accuracy

And this is the value in DEV tools:

Sem título

Sem título

You can notice the state was last updated 2 days ago! So…there is something happening here that prevents the states from being updated to the correct value.

I have a few sensors and some of them are receiving values each 10s/30s/60s. So… it is a lot a new rows being added all the time. Is the a limit of rows in the database table that collects all the data?

Its like a cliff hanger…lol
maybe they all died when the all important sensor was showing the wrong value