thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.26k stars 116 forks source link

RESTful integration broken in HA 2022.11.2 #321

Closed droans closed 1 year ago

droans commented 1 year ago

Home Assistant now raises an invalid config error: Component rest cannot be merged. Expected a dict. Appears to have been broken with PR #81723.

All my rest: integration entities show this issue while rest_command and anything using the platform: rest are fine. My configurations appear to match the requirements based in the documentation. While I do not know HA code that well, I believe it is coming from the change here.

Example Configuration:

rest:
  - scan_interval: 3600
    resource: https://www.gasbuddy.com/graphql
    method: POST
    headers:
      Content-Type: application/json
    payload: |
      {
        "operationName": "LocationBySearchTerm",
        "variables": {
          "fuel": 1,
          "maxAge": 0,
          "search": "46038"
        },
        "query": "query LocationBySearchTerm($search: String) { locationBySearchTerm(search: $search) { trends { areaName country today todayLow } } }" }

    sensor:
      - unique_id: gasbuddy_lowest_gas_price
        name: Gasbuddy Lowest Gas Price
        icon: mdi:gas-station
        unit_of_measurement: USD
        value_template: "{{ value_json.data.locationBySearchTerm.trends.0.todayLow | float }}"

      - unique_id: gasbuddy_average_gas_price
        name: Gasbuddy Average Gas Price
        icon: mdi:gas-station
        unit_of_measurement: USD
        value_template: "{{ value_json.data.locationBySearchTerm.trends.0.today | float }}"

Edit: somehow posted in the wrong repo. Sorry - marking closed.

droans commented 1 year ago

Just to provide more information, I have found that changing to a dict instead of a list works. However, only a single rest call will be possible as you cannot use a list and it will fail to validate if you use rest: in separate packages.

rest:
  scan_interval: 3600
  resource: https://www.gasbuddy.com/graphql
  method: POST
  headers:
    Content-Type: application/json
  payload: |
    {
      "operationName": "LocationBySearchTerm",
      "variables": {
        "fuel": 1,
        "maxAge": 0,
        "search": "46038"
      },
      "query": "query LocationBySearchTerm($search: String) { locationBySearchTerm(search: $search) { trends { areaName country today todayLow } } }" }

  sensor:
    - unique_id: gasbuddy_lowest_gas_price
      name: Gasbuddy Lowest Gas Price
      icon: mdi:gas-station
      unit_of_measurement: USD
      value_template: "{{ value_json.data.locationBySearchTerm.trends.0.todayLow | float }}"

    - unique_id: gasbuddy_average_gas_price
      name: Gasbuddy Average Gas Price
      icon: mdi:gas-station
      unit_of_measurement: USD
      value_template: "{{ value_json.data.locationBySearchTerm.trends.0.today | float }}"