Skons / hassio-addons

7 stars 4 forks source link

Error on startup #33

Closed Sarnog closed 2 years ago

Sarnog commented 2 years ago

Hello,

Just as i started the add-on, i received an error in the log:

ERROR   : unable to validate payload '[]' for gas_stations with error: '[] is not of type 'object'
Failed validating 'type' in schema:
    {'properties': {'friendly_name_template': {'type': 'string'},
                    'fuel_type': {'enum': ['euro95',
                                           'euro98',
                                           'diesel',
                                           'cng',
                                           'lpg'],
                                  'type': 'string'},
                    'identifier': {'pattern': '^[a-z0-9]{0,10}$',
                                   'type': 'string'},
                    'latitude': {'type': 'number'},
                    'longitude': {'type': 'number'},
                    'radius': {'maximum': 15,
                               'minimum': 1,
                               'type': 'integer'},
                    'to_publish': {'minimum': 1, 'type': 'integer'}},
     'required': ['fuel_type', 'radius', 'longitude', 'latitude'],
     'type': 'object'}
On instance:
    []'

Did i mess something up, or is the add-on broken?

BebeMischa commented 2 years ago

The addon works fine.

Post your config

Sarnog commented 2 years ago
log_level: info
ocr:
  contrast_enhance: 2
mqtt_host: 192.168.1.31
mqtt_port: 1883
mqtt_username: '!secret mosquitto_user'
mqtt_password: '!secret mosquitto_pass'
BebeMischa commented 2 years ago

post your automation, correctly tagged as code

Sarnog commented 2 years ago

This is at startup of the addon:

image

This is the automation in yaml:

image

Sarnog commented 2 years ago

This is the log after i run the automation:

image

BebeMischa commented 2 years ago

I need the automation as code, not a screenshot ;-)

Sarnog commented 2 years ago

Ow sorry, hahaha...

Here it is:

alias: 'Update: Marco Best'
description: ''
trigger:
  - platform: time_pattern
    hours: '6'
condition: []
action:
  - service: mqtt.publish
    data:
      topic: dgp/gas_stations
      payload: '{"station_id":"4121","fuel_type":"euro95"}'
mode: single
Sarnog commented 2 years ago

Unfortunatly that's not working eighter.

[2022-05-24 20:28:07] INFO    : Received payload '{"station_id":"4121","fuel_type":"euro95", "to_publish":1}' on topic 'dgp/gas_stations'
[2022-05-24 20:28:07] ERROR   : unable to validate payload '{"station_id":"4121","fuel_type":"euro95", "to_publish":1}' for gas_stations with error: ''radius' is a required property
Failed validating 'required' in schema:
    {'properties': {'friendly_name_template': {'type': 'string'},
                    'fuel_type': {'enum': ['euro95',
                                           'euro98',
                                           'diesel',
                                           'cng',
                                           'lpg'],
                                  'type': 'string'},
                    'identifier': {'pattern': '^[a-z0-9]{0,10}$',
                                   'type': 'string'},
                    'latitude': {'type': 'number'},
                    'longitude': {'type': 'number'},
                    'radius': {'maximum': 15,
                               'minimum': 1,
                               'type': 'integer'},
                    'to_publish': {'minimum': 1, 'type': 'integer'}},
     'required': ['fuel_type', 'radius', 'longitude', 'latitude'],
     'type': 'object'}
On instance:
    {'fuel_type': 'euro95', 'station_id': '4121', 'to_publish': 1}'
BebeMischa commented 2 years ago

oh, you were too fast, i deleted that post, as it was faulty...

Still, the automation code is not properly posted, like this I can't see the indentation... ;-)

Sarnog commented 2 years ago

can you explain to me how i can do that? Sorry for being noob-ish

BebeMischa commented 2 years ago

No problem

Start with these signs ``` , but only 3 of them. Go to next line. Paste you automation. Go to next line. Finish with 3 of again. Post.

The sign is on left upper corner of keyboard, next to number 1

Sarnog commented 2 years ago

Thank you for the explaination.. ;-) Here you are:

alias: 'Update: Marco Best'
description: ''
trigger:
  - platform: time_pattern
    hours: '6'
condition: []
action:
  - service: mqtt.publish
    data:
      topic: dgp/gas_stations
      payload: '{"station_id":"4121","fuel_type":"euro95", "to_publish":1}'
mode: single
BebeMischa commented 2 years ago

You can delete the "to_publish":1 part again. It looks, like your own automation was correct, according to manual. So I'm afraid, that I would not be able to help more. As I'm more familiar with the first style of getting data described in the manuals, based on location.

I can share my automation for you, which gives 10 results in near area, you can try to edit that for your needs and see, if that works. Other ways, you will have to wait for @Skons to help you more...

alias: Update gas stations
trigger:
  - platform: time_pattern
    minutes: '5'
  - platform: homeassistant
    event: start
action:
  - service: mqtt.publish
    data:
      topic: dgp/gas_stations
      payload_template: >-
        {"fuel_type":"euro98","radius":5,"latitude":{{
        state_attr("person.mischa", "latitude") }},"longitude":{{
        state_attr("person.mischa", "longitude")
        }},"friendly_name_template":"[brand] ([station_street])",
        "to_publish":10}

This one works flawlessly...

Only need to edit fuel type and person (you)

image

Sarnog commented 2 years ago

Yeah, that one i working correctly to me as well... Only the automation on station ID is not working and has never worked for me. But once i started the addon and checked the logs, i see that there's an error, without starting an automation. I think that error prevents the automation on the station ID to run...

Thanks for your help tho! I hope somebody understands the problem and know how to fix it.

image

BebeMischa commented 2 years ago

I wish you luck! ;-)

@Skons is very friendly, he will help you soon for sure ;-)

At least, today you have learned, how to post code on GitHub and HomeAssistant forum :-)

Sarnog commented 2 years ago

Thanks again Mischa! i'm sure he will... ;-)

Skons commented 2 years ago

There is an empty object or '[]' object being sent to dgp/gas_stations. Is there an automation that is doing that constantly?

Another option is that while you where playing around, the retain property was set (see https://www.home-assistant.io/docs/mqtt/service/). This can be viewed with mqtt explorer (https://mqtt-explorer.com/). If that is the case the mqtt client of dgp picks up the last setting on that topic. You can delete the retained value with mqtt explorer.

BebeMischa commented 2 years ago

According to Skons answer in the other topic, here the same fault is made, I guess?

alias: 'Update: Marco Best'
description: ''
trigger:
  - platform: time_pattern
    hours: '6'
condition: []
action:
  - service: mqtt.publish
    data:
      topic: dgp/gas_station
      payload: '{"station_id":"4121","fuel_type":"euro95"}'
mode: single

topic: dgp/gas_station, without the s ;-)

Sarnog commented 2 years ago

Yes thanks! It's working now on the station ID. The error is still there tho... I think something is wrong in this automation:

alias: 'Update: Bezinestations in de buurt'
trigger:
  - platform: state
    entity_id:
      - input_button.update_bezinestations_omgeving
  - platform: time_pattern
    minutes: '15'
  - platform: homeassistant
    event: start
action:
  - service: mqtt.publish
    data:
      topic: dgp/gas_stations
      payload_template: >-
        {"fuel_type":"euro95","radius":5,"latitude":{{
        state_attr("person.danny",
          "latitude") }},"longitude":{{ state_attr("person.danny", "longitude") }},
          "friendly_name_template":"[brand] ([station_street])",
          "to_publish":3}
mode: single
Skons commented 2 years ago

Maybe try single quotes around the json payload.

Sarnog commented 2 years ago

Solved! It was indeed a retained topic. When i deleted it with mqtt monitor, the error was gone. Thanks a lot!