HASwitchPlate / openHASP-custom-component

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

Power Relays are not instantiated in Home Assistant #95

Closed kquinsland closed 2 years ago

kquinsland commented 2 years ago

Version of the custom_component

The latest as of yesterday. HACS prompted me to update on 2022.04.14.

Configuration


N/A

Describe the bug

I have a L8 3 relay variant. Two of the three relays are configured as "light" and one as "power":

Pin Type Group Default
12 Power Relay 2 Normal  
14 Light Relay 1 Normal  
26 Mood Red 1 Normal  
27 Light Relay 3 Normal  
32 Mood Green 2 Normal  
33 Mood Blue 3 Normal 

The custom component does configure the light..... entities in HA, but there is no switch for the power relay. I have been able to confirm the correct GPIO in the discovery payload:

{"node":"bathroom","mdl":"Lanbon L8","mf":"openHASP","hwid":"nah","pages":12,"sw":"0.7.0","uri":"http://nah","input":{},"power":[12],"light":[14,27],"dim":[]}
fvanroie commented 2 years ago

I tested this setup and I have the same issue. In the log file I see this error:

2022-04-15 21:04:35 ERROR (MainThread) [homeassistant.components.switch] Error while setting up openhasp platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/openhasp/switch.py", line 35, in async_setup_entry
    [
  File "/config/custom_components/openhasp/switch.py", line 36, in <listcomp>
    HASPSwitch(
  File "/config/custom_components/openhasp/switch.py", line 62, in __init__
    self._attr_name = f"{name} switch {self._gpio}"
AttributeError: 'HASPSwitch' object has no attribute '_gpio'
dgomes commented 2 years ago

pushed a commit that should fix this

fvanroie commented 2 years ago

I removed the plate, updated the CC, rediscovered the plate and now it's OK