HASwitchPlate / openHASP-custom-component

Home Assistant custom component for openHASP
https://www.openhasp.com
MIT License
49 stars 9 forks source link

`Error adding entities for domain switch with platform openhasp` after upgrading to HA 2022.4.0 #94

Closed adorobis closed 2 years ago

adorobis commented 2 years ago

After upgrading HA to 2022.4.0 release I'm receiving the following errors in the log:

2022-04-07 08:06:19 ERROR (MainThread) [homeassistant.components.switch] Error adding entities for domain switch with platform openhasp
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 510, in _async_add_entity
    entry = entity_registry.async_get_or_create(
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_registry.py", line 345, in async_get_or_create
    return self.async_update_entity(
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_registry.py", line 529, in async_update_entity
    raise ValueError("entity_category must be a valid EntityCategory instance")
ValueError: entity_category must be a valid EntityCategory instance

Any hints if a config change would resolve it or rather a bug in openHASP integration? Other than the error in the log it seems that the plate works ok. Below is my entire config for openHASP in HA:

hasp_1:
  objects:
    # - obj: "p0b1"  # temperature label on all pages
      # properties:
        # "text": '{{ states("sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2") }}°C'
    - obj: "p0b1"  # time label on all pages
      properties:
        "text": '{{ states("sensor.time") }}'
    - obj: "p0b2"  # date label on all pages
      properties:
        "text": '{{ states("sensor.date") }}'
    - obj: "p0b3"
      properties:
        "text_color": "{% if -30 <= state_attr('openhasp.hasp_1','rssi') |int %}green{% elif -31 > state_attr('openhasp.hasp_1','rssi') |int >= -50 %}orange{% elif -51 > state_attr('openhasp.hasp_1','rssi') |int >= -80 %}tomato{% else %}red{% endif %}"

    - obj: "p1b2"  # Temperatura południe
      properties:
        "text": '{{ states("sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2") | round(1) }}°C'
        "bg_color": "{% if states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 0  %}blue{% elif 0 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 4 %}Aqua{% elif 4 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 15 %}Khaki{% elif 15 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 25 %}green{% elif 25 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 30 %}yellow{% else %}red{% endif %}"
        "bg_grad_color": "{% if states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 0  %}blue{% elif 0 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 4 %}Aqua{% elif 4 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 15 %}Khaki{% elif 15 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 25 %}green{% elif 25 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 30 %}yellow{% else %}red{% endif %}"
        "text_color": "{% if states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 0  %}#FFFFFF{% elif 0 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 4 %}#000000{% elif 4 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 15 %}#000000{% elif 15 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 25 %}#FFFFFF{% elif 25 < states('sensor.qubino_goap_zmnhbdx_flush_2_relays_temperature_2') |int <= 30 %}#000000{% else %}#FFFFFF{% endif %}"
    - obj: "p1b3"  # Temperatura stacja pogodowa
      properties:
        "text": '{{ states("sensor.outdoor_temperature") | round(1) }}°C'
        "bg_color": "{% if states('sensor.outdoor_temperature') |int <= 0  %}blue{% elif 0 < states('sensor.outdoor_temperature') |int <= 4 %}Aqua{% elif 4 < states('sensor.outdoor_temperature') |int <= 15 %}Khaki{% elif 15 < states('sensor.outdoor_temperature') |int <= 25 %}green{% elif 25 < states('sensor.outdoor_temperature') |int <= 30 %}yellow{% else %}red{% endif %}"
        "bg_grad_color": "{% if states('sensor.outdoor_temperature') |int <= 0  %}blue{% elif 0 < states('sensor.outdoor_temperature') |int <= 4 %}Aqua{% elif 4 < states('sensor.outdoor_temperature') |int <= 15 %}Khaki{% elif 15 < states('sensor.outdoor_temperature') |int <= 25 %}green{% elif 25 < states('sensor.outdoor_temperature') |int <= 30 %}yellow{% else %}red{% endif %}"
        "text_color": "{% if states('sensor.outdoor_temperature') |int <= 0  %}#FFFFFF{% elif 0 < states('sensor.outdoor_temperature') |int <= 4 %}#000000{% elif 4 < states('sensor.outdoor_temperature') |int <= 15 %}#000000{% elif 15 < states('sensor.outdoor_temperature') |int <= 25 %}#FFFFFF{% elif 25 < states('sensor.outdoor_temperature') |int <= 30 %}#000000{% else %}#FFFFFF{% endif %}"
    - obj: "p1b4"  # Brama
      properties:
        "val": '{{ 1 if states("cover.brama") == "closed" else 0 }}'
        "text": '{{ "\uF2D3" if is_state("cover.brama", "closed") else "\uF2D4" | e }}'
        "bg_color": '{{ "Red" if is_state("cover.brama", "open") else "Green" | e }}'
        "bg_grad_color": '{{ "Red" if is_state("cover.brama", "open") else "Green" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "cover.brama"
    - obj: "p1b5"  # Wszystkie światła
      properties:
        "val": '{{ 1 if states("group.all_lights") == "on" else 0 }}'
        "text": '{{ "\uE6E8" if is_state("group.all_lights", "on") else "\uE335" | e }}'
        "bg_color": '{{ "Gray" if is_state("group.all_lights", "off") else "Green" | e }}'
        "bg_grad_color": '{{ "Gray" if is_state("group.all_lights", "off") else "Green" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "switch.all_lights"
    - obj: "p1b6"  # Światła - drzewa
      properties:
        "val": '{{ 1 if states("switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2") == "on" else 0 }}'
        "text": '{{ "\uF054" if is_state("switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2", "on") else "\uF054" | e }}'
        "bg_color": '{{ "Gray" if is_state("switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2", "off") else "Green" | e }}'
        "bg_grad_color": '{{ "Gray" if is_state("switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2", "off") else "Green" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "switch.qubino_goap_zmnhbdx_flush_2_relays_switch_2"
    - obj: "p1b7"  # Światła - ogród front
      properties:
        "val": '{{ 1 if states("switch.outdoor_front_lights") == "on" else 0 }}'
        "text": '{{ "\uE8DD" if is_state("switch.outdoor_front_lights", "on") else "\uE8DD" | e }}'
        "bg_color": '{{ "Gray" if is_state("switch.outdoor_front_lights", "off") else "Green" | e }}'
        "bg_grad_color": '{{ "Gray" if is_state("switch.outdoor_front_lights", "off") else "Green" | e }}'
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "switch.outdoor_front_lights"
    - obj: "p1b10"  # Pogoda ikona
      properties:
        "text": "{% if states('weather.home')  == 'clear_night'  %}\uE594{% elif states('weather.home')  == 'cloudy' %}\uE590{% elif states('weather.home')  == 'fog'  %}\uE591{% elif states('weather.home')  == 'lightning_rainy'  %}\uE67E{% elif states('weather.home')  == 'partlycloudy'  %}\uE595{% elif states('weather.home')  == 'pouring'  %}\uE596{% elif states('weather.home')  == 'rainy'  %}\uE597{% elif states('weather.home')  == 'snowy'  %}\uE598{% elif states('weather.home')  == 'snowy_rainy'  %}\uE67F{% else %}\uE599{% endif %}"
    - obj: "p1b12"  # Stan alarmu
      properties:
        "text": "{% if states('binary_sensor.alarm_armed') == 'on' %}\uEFC6{% else %}\uE33E{% endif %}"
        "text_color": "{% if states('group.allpersons')  == 'home' %}White{% elif states('binary_sensor.alarm_armed') == 'on' %}Green{% else %}Red{% endif %}"
        "bg_color": "{% if states('group.allpersons')  == 'not_home'  %}Gray{% elif states('binary_sensor.alarm_armed') == 'on' %}Green{% else %}Red{% endif %}"
        "bg_grad_color": "{% if states('group.allpersons')  == 'not_home'  %}Gray{% elif states('binary_sensor.alarm_armed') == 'on' %}Green{% else %}Red{% endif %}"
      event:
        "up":
          - service: homeassistant.toggle
            entity_id: "switch.alarm_armed"
adorobis commented 2 years ago

Btw, it looks like above issue is impacting the antiburn switch - it is unavailable now: image

juan11perez commented 2 years ago

I have also lost all antiburn switches. I have 24 lanbon l8 in my system.

dgomes commented 2 years ago

@adorobis which version of the custom_component are you using ? I'm not able to reproduce that error :(

juan11perez commented 2 years ago

I'm on 0.6.4 with this error

dgomes commented 2 years ago

Could @juan11perez and @adorobis check the master branch version ? I think I covered everything but would like some beta testers before I release a new version ;)

juan11perez commented 2 years ago

@dgomes Perfect!. Installed 'main' from hacs and antiburn is working again. Moreover 2 new entities added (page number and restart)

Thank you very much.

dgomes commented 2 years ago

Fixed in 0.6.5

adorobis commented 2 years ago

Works for me as well, many thanks!