Skons / hassio-addons

7 stars 4 forks source link

Did I miss something, sensor unavailable #60

Closed Dutchy-79 closed 11 months ago

Dutchy-79 commented 11 months ago

Hi,

I just noticed that my sensor no longer works. It says unknown for 2 days.

Automation: alias: Update gas station lpg trigger:

Logs: [2023-10-19 07:07:00] INFO : Received payload '{"station_id":3580,"fuel_type":"lpg"}' on topic 'dgp/gas_station' [2023-10-19 07:07:04] INFO : publishing station_id 3580 to mqtt [2023-10-19 07:07:05] WARNING : Unable to find sensor with url 'http://supervisor/core/api/states/sensor.gas_station_3580_lpg', status code is '404' [2023-10-19 07:54:01] INFO : Received payload '{"station_id":3580,"fuel_type":"lpg"}' on topic 'dgp/gas_station' [2023-10-19 07:54:01] INFO : publishing station_id 3580 to mqtt [2023-10-19 07:54:02] WARNING : Unable to find sensor with url 'http://supervisor/core/api/states/sensor.gas_station_3580_lpg', status code is '404'

Regards,

Jasper

Skons commented 11 months ago

Can you show a screenshot of the sensor.gas_station_3580_lpg1 entity? I think you have multiple.

Dutchy-79 commented 11 months ago

Screenshot_20231019_093921_Home Assistant

Dutchy-79 commented 11 months ago

Bottom one says unknown, top probably old.

Skons commented 11 months ago

If your automation runs automatically, disable it, restart home assistant. remove the bottom one. Enable your automation and it should be working again.

Dutchy-79 commented 11 months ago

Okay, disable automation Delete sensor Reboot HA Enable automation Run automation

No new sensor

Log shows

[2023-10-19 10:21:36] INFO : Received payload '{"station_id":3580,"fuel_type":"lpg"}' on topic 'dgp/gas_station' [2023-10-19 10:21:39] INFO : publishing station_id 3580 to mqtt [2023-10-19 10:21:40] WARNING : Unable to find sensor with url 'http://supervisor/core/api/states/sensor.gas_station_3580_lpg', status code is '404'

Checked is station_id didn't change

Screenshot_20231019_102516_Chrome

Dutchy-79 commented 11 months ago

Restarted everything again.

Here's the log

s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service base-addon-banner: starting


Add-on: Dutch gas prices Get gas prices from dutch gas stations

Add-on version: 2023.10.15.1 You are running the latest version of this add-on. System: Home Assistant OS 11.0 (amd64 / qemux86-64) Home Assistant Core: 2023.10.3 Home Assistant Supervisor: 2023.10.0

Please, share the above information when looking for help or support in, e.g., GitHub, forums or the Discord chat.

s6-rc: info: service base-addon-banner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service base-addon-log-level: starting s6-rc: info: service fix-attrs successfully started Log level is set to INFO s6-rc: info: service base-addon-log-level successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started [11:09:26] INFO: Log_level: info [11:09:26] INFO: mqtt_host: core-mosquitto [11:09:26] INFO: mqtt_port: 1883 [11:09:26] INFO: Starting dutch gas prices... [2023-10-19 11:09:27] INFO : DGP initialized, launching client [2023-10-19 11:09:27] INFO : Connecting to mqtt host 'core-mosquitto' with clientname 'f5a8083e-dutch-gas-prices' [2023-10-19 11:09:27] INFO : Using username 'mqtt' to connect to 'core-mosquitto' [2023-10-19 11:09:27] INFO : Connected with result code '0' [2023-10-19 11:09:56] INFO : Received payload '{"station_id":3580,"fuel_type":"lpg"}' on topic 'dgp/gas_station' [2023-10-19 11:10:00] INFO : publishing station_id 3580 to mqtt [2023-10-19 11:10:01] WARNING : Unable to find sensor with url 'http://supervisor/core/api/states/sensor.gas_station_3580_lpg', status code is '404'

Skons commented 11 months ago

The problem is that Home Assistant creates sensor.gas_station_3580_lpg_2 but dgp expects sensor.gas_station_3580_lpg. The only way to fix this properly is to make sure the _2 is deleted, you can only delete that sensor if HA does not have an MQTT entry of that sensor. You said you executed these steps:

disable automation
Delete sensor
Reboot HA
Enable automation
Run automation

But deleting can only happen when HA does not know of the sensor, so rebooting should be done before deleting, then the MQTT entry is gone. Deleting is not really possible, or you have figured it out. How did you delete the entity?

Dutchy-79 commented 11 months ago

Ty, that helped me. I think I disabled the entity _2 now I renamed the _2 sensor.gas_station_3580 lpg then run the automation and I have a value again.