thomasloven / hass-plejd

🔹 Plejd BLE integration for Home Assistant
81 stars 10 forks source link

Switch as light #35

Closed ricmik closed 4 months ago

ricmik commented 10 months ago

Hi,

I see in the const.py file of the pyplejd package that relays like REL-01-2P are defined as switches. However, in Home Assistant the REL-01-2P is shown as a light. Is this because the device was created with an earlier version of hass_plejd, or are relays created as lights from the hass_plejd integration?

My point is that relays should be created as switches in Home Assistant. If the switch then actually controls a light, "Switch as X" should be used in Home Assistant to replace the switch with a light device. :)

thomasloven commented 5 months ago

Hi. Is this still an issue? Relays should report as switches unless you have selected a light as their load setting in the Plejd app.

ricmik commented 5 months ago

Hi, that makes sense. I tried reconfiguring the output on my relay from light to "other". The light device in HA stopped working, I deleted the non-working light in HA and expected the Plejd integration to present the switch entity instead.

Now the REL-01-2P device is still in HA, but there are no switches or light entities on it. How can I delete or refresh the device with the new configuration from Plejd? A restart of HA does not help.

ricmik commented 5 months ago

@thomasloven Any advice to how I can get the controls back for this device after I have changed the type from Light to Switch in the Plejd-app?

image

thomasloven commented 5 months ago

Could you please send me your diagnostics data?

ricmik commented 5 months ago

I tried to download the diagnostics data, but I get an error in the log file:

Logger: aiohttp.server
Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:421
First occurred: 12:17:51 PM (1 occurrences)
Last logged: 12:17:51 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 233, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 149, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/diagnostics/__init__.py", line 249, in get
    data = await info.config_entry_diagnostics(hass, config_entry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/plejd/diagnostics.py", line 83, in async_get_config_entry_diagnostics
    site: PlejdSite = get_plejd_site_from_config_entry(config_entry)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: get_plejd_site_from_config_entry() missing 1 required positional argument: 'config_entry'
thomasloven commented 5 months ago

If the problem is not fixed already, version 0.8.0 should at least fix the diagnostics problem.

ricmik commented 5 months ago

Hi, I was able to download the diagnostics file with 0.8.0. The device in question is named "Speil Badet" config_entry-plejd-55f44f24c59b1c39068b6883956b8fcd.json.txt

thomasloven commented 5 months ago

It seems you have chosen to hide that device in the Plejd app.

ricmik commented 4 months ago

You're right. Making the device visible in the Plejd app made it appear in Home Assistant. Thanks! :)