Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broadlink integration error #40191

Closed
neotrunks opened this issue Sep 17, 2020 · 190 comments · Fixed by #47779
Closed

broadlink integration error #40191

neotrunks opened this issue Sep 17, 2020 · 190 comments · Fixed by #47779

Comments

@neotrunks
Copy link

The problem

I tried to use new integration for my broadlink remote (rm_pro_phicom), it worked with custom components without problems,
with new integration it fails and doesn't create new entity.

Environment

  • Home Assistant Core release with the issue: 0.115
  • Last working Home Assistant Core release (if known): 0.114
  • Operating environment (OS/Container/Supervised/Core): Core
  • Integration causing this issue: Broadlink
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/broadlink

Problem-relevant configuration.yaml

Traceback/Error logs

Logger: homeassistant.config_entries
Source: components/broadlink/updater.py:29
First occurred: 20:41:02 (2 occurrences)
Last logged: 20:42:44

Error setting up entry despacho_remote for broadlink
Error setting up entry remote_despacho for broadlink
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 228, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/broadlink/__init__.py", line 28, in async_setup_entry
    return await device.async_setup()
  File "/usr/src/homeassistant/homeassistant/components/broadlink/device.py", line 97, in async_setup
    update_manager = get_update_manager(self)
  File "/usr/src/homeassistant/homeassistant/components/broadlink/updater.py", line 29, in get_update_manager
    return update_managers[device.api.type](device)
KeyError: 'Unknown'

Additional information

@dexterddit
Copy link

Same thing happens with rm_mini3_newblackbean, no entity is created . It`s connect fine to the old rm_mini3 .

@rumney909
Copy link

same issue here rm_mini_3 no entity created this shows in logs.
ERROR (MainThread) [homeassistant.components.broadlink.updater] Error fetching device data: The device storage is full

@joten75
Copy link

joten75 commented Sep 17, 2020

same here:

Logger: homeassistant.components.broadlink
Source: components/broadlink/config_flow.py:100
Integration: Broadlink (documentation, issues)
First occurred: 22:59:27 (1 occurrences)
Last logged: 22:59:27

Failed to connect to the device at 10.0.0.x: Invalid host for this configuration flow. The MAC address should be xx:xx:xx:xx:xx:xx, but xx:xx:xx:xx:xx:xx was given

and
Logger: aiohttp.server
Source: components/broadlink/config_flow.py:47
First occurred: 22:57:33 (3 occurrences)
Last logged: 23:07:24

Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 169, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper
result = await method(view, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 106, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 156, in async_configure
result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 204, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/broadlink/config_flow.py", line 82, in async_step_user
await self.async_set_device(device)
File "/usr/src/homeassistant/homeassistant/components/broadlink/config_flow.py", line 47, in async_set_device
"model": device.model,
AttributeError: 'rm4' object has no attribute 'model'

@probot-home-assistant
Copy link

broadlink documentation
broadlink source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @Danielhiversen, @felipediel, mind taking a look at this issue as its been labeled with an integration (broadlink) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@felipediel
Copy link
Contributor

The new Blackbean will be solved with #39228.

@felipediel
Copy link
Contributor

@neotrunks Please open a terminal on your computer, install the python-broadlink library (pip install broadlink), open Python 3 and type:

import broadlink as blk

devs = blk.discover(timeout=5)
print([(d.host[0], hex(d.devtype)) for d in devs])

devs = blk.discover(discover_ip_address="192.168.0.17", timeout=5)  # Your device IP address
print([(d.host[0], hex(d.devtype)) for d in devs])

What is the output?

@felipediel
Copy link
Contributor

felipediel commented Sep 17, 2020

@joten75 Once you choose a device for the configuration flow, you can no longer change it. You need to start a new configuration flow if you want to change it. This is not a bug.

The second error is still obscure to me. Do you have any other clues? What were you doing (step by step) when this error appeared?

@felipediel
Copy link
Contributor

@neotrunks Please consider sending me your device type soon, or we will miss the next release.

@duceduc
Copy link

duceduc commented Sep 18, 2020

@felipediel
These are the devices I have in my HA.
RM4 Pro -> 0x6026
RM Mini 3 -> 0x5f36

@felipediel
Copy link
Contributor

0x6026 is working, right?

@spiro-c
Copy link

spiro-c commented Sep 18, 2020

@felipediel
i have the same problem this is the output python
[('192.168.10.101', '0x649b')]
it's RM4Pro

@felipediel
Copy link
Contributor

@spiro-c Thank you! We will support this device soon.

@duceduc
Copy link

duceduc commented Sep 18, 2020

0x6026 is working, right?

Yes, but not all my ir codes are showing up. Will need to look into that further when I get the chance.

@felipediel
Copy link
Contributor

Ok. Please read the docs first, we changed a lot of things.

@duceduc
Copy link

duceduc commented Sep 18, 2020

Post retracted.
Never mind. Not an accurate list.

@neotrunks
Copy link
Author

@neotrunks Please open a terminal on your computer, install the python-broadlink library (pip install broadlink), open Python 3 and type:

import broadlink as blk

devs = blk.discover(timeout=5)
print([(d.host[0], hex(d.devtype)) for d in devs])

devs = blk.discover(discover_ip_address="192.168.0.17", timeout=5)  # Your device IP address
print([(d.host[0], hex(d.devtype)) for d in devs])

What is the output?

[('192.168.0.136', '0x27c3')]

@felipediel
Copy link
Contributor

@neotrunks Thank you! Your device will be supported soon.

@joten75
Copy link

joten75 commented Sep 18, 2020

@felipediel i
I just tried to add a device broadlink in the ui :click on the plus sign, select broadlink, insert the ip of the broadlink then unkwno error show up and in the log the message . could it be because i have more than one broadlink?
Obviously I have deleted all the configuration in the yaml except the switch.

@felipediel
Copy link
Contributor

No. Please send me your device types so I can check.

@joten75
Copy link

joten75 commented Sep 18, 2020

type: rm_mini3_newblackbean
in the log of the error they show:
Failed to connect to the device at 10.0.0.5: Invalid host for this configuration flow. The MAC address should be 56:fd:5a:77:0f:78, but c1:17:d6:a7:df:24 was given
the second mac was the rigth one but with inverse order they must be 24:df:a7:d6:17:c1

@felipediel
Copy link
Contributor

@joten75 RM mini 3 new Blackbean (0x5f36) will be supported after this patch.

@pavoni
Copy link
Contributor

pavoni commented Sep 18, 2020

Thanks for all this work @felipediel. I think you already have my device in your PR, but I ran your code to get the info to be sure.

[('192.168.1.99', '0x5f36'), ('192.168.1.96', '0x5f36')]

You commented as I was checking!

Thanks!

@joten75
Copy link

joten75 commented Sep 18, 2020

thank @felipediel i very appreciate your help.
so i wait for the mini 3 but even the rm2 pro dont'work? i've this when try to add to config:

Logger: aiohttp.server
Source: components/broadlink/config_flow.py:47
First occurred: 11:54:00 (1 occurrences)
Last logged: 11:54:00

Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 169, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper
result = await method(view, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 106, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 156, in async_configure
result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 204, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/broadlink/config_flow.py", line 82, in async_step_user
await self.async_set_device(device)
File "/usr/src/homeassistant/homeassistant/components/broadlink/config_flow.py", line 47, in async_set_device
"model": device.model,
AttributeError: 'rm' object has no attribute 'model'

@felipediel
Copy link
Contributor

@joten75 I need to see the types (represented in hex). This is how you get them: #40191 (comment)

@felipediel
Copy link
Contributor

@paynenz Thank you! I created a PR. Is the brand correct? (Broadlink)

@paynenz
Copy link

paynenz commented Nov 25, 2020

@paynenz Thank you! I created a PR. Is the brand correct? (Broadlink)

It's an Efergy Ego smart plug. I have been using the older broadlink switch configuration with type sp2 on 0.114.4. Sorry I don't know more about the smart plug internals.
Thanks heaps!

@felipediel
Copy link
Contributor

This?

@paynenz
Copy link

paynenz commented Nov 25, 2020

This?

That's the one, I have the New Zealand outlet model but I doubt that it would matter

@felipediel
Copy link
Contributor

Thank you!

@blavak68
Copy link

blavak68 commented Dec 4, 2020

@felipediel

hi, i have the same problem (RM4c mini ver 2020)
here ist output from python:
[('192.168.x.x', '0x6539')]

can you help me?
thx

@felipediel
Copy link
Contributor

It's open: mjg59/python-broadlink#476
Thank you!

@sosolid
Copy link

sosolid commented Dec 8, 2020

Hi, I have SP4L-UK units that report back as:

[('10.0.1.126', '0xa589')]

Can you add them to the integration please?

@felipediel
Copy link
Contributor

Sure. Could you please confirm if your device works with the SP4 class? I'm pretty sure it will work, but if it doesn't work out we also have the SP4B class to test.

import broadlink as blk

d = blk.sp4(("192.168.0.16", 80), "aabbccddeeff", 0xa589)  # host, mac, devtype
d.auth()

# Test power on
d.set_power(True)

# Test power off
d.set_power(False)

# Test get state
d.get_state()

@sosolid
Copy link

sosolid commented Dec 8, 2020

HI Felipe,

Yes it works. I added a manual line into the init.py file and the integration found the devices and controls them correctly, as well as the state.

@felipediel
Copy link
Contributor

Thank you!

@occamatic
Copy link

Sure. Could you please confirm if your device works with the SP4 class? I'm pretty sure it will work, but if it doesn't work out we also have the SP4B class to test.

import broadlink as blk

d = blk.sp4(("192.168.0.16", 80), "aabbccddeeff", 0xa589)  # host, mac, devtype
d.auth()

# Test power on
d.set_power(True)

# Test power off
d.set_power(False)

# Test get state
d.get_state()

I followed these same commands with the same device and got the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python3.5/site-packages/broadlink/device.py", line 199, in auth
    check_error(response[0x22:0x24])
  File "/home/user/.local/lib/python3.5/site-packages/broadlink/exceptions.py", line 137, in check_error
    raise exception(error_code)
broadlink.exceptions.AuthenticationError: [Errno -1] Authentication failed

Anything I can try to get this working?

@felipediel
Copy link
Contributor

@occamatic Try unlocking the device with the official app first.

@occamatic
Copy link

@occamatic Try unlocking the device with the official app first.

Thank you it worked! You saved me having to return these 2 units I bought. Keep up the good work!

@felipediel
Copy link
Contributor

Thanks for reporting back!

@bulutsemih
Copy link

RM4 Pro ('192.168.1.200', '0x653c')

@pedroeched
Copy link

Hi! I have been 5 hours trying to conect my RM PRO+ to HA but it's impossible. I select de + button to add a new a integration I put the host but the issue is:

'''
Logger: homeassistant.components.broadlink.config_flow
Source: components/broadlink/config_flow.py:114
Integration: Broadlink (documentation, issues)
First occurred: 11:51:13 (1 occurrences)
Last logged: 11:51:13

Failed to connect to the device at 192.168.1.40: Device not found
'''
I tried to connect it doing a reset on broaflink device, changing the IP, and many more things, but it is impossible. Could you help me? THANKS!

@felipediel
Copy link
Contributor

Hi @pedroeched. Try unlocking the device with the official app.

@adelunaddl
Copy link

Hi this is my device:

[('192.168.16.242', '0x279d')] RM4 Pro

@felipediel
Copy link
Contributor

This is an RM pro+. It is already supported.

@adelunaddl
Copy link

adelunaddl commented Jan 7, 2021 via email

@felipediel
Copy link
Contributor

You can learn the RF codes and send them with your RM pro. See this thread.

@paynenz
Copy link

paynenz commented Jan 18, 2021

For anyone that would like to get their broadlink devices working before the broadlink integration is updated with their device code, these are the instructions I have been using after each time I update Home Assistant. I am running the Home Assistant OS.

  1. SSH into the Home Assistant host
  2. Login, type login
  3. Enter the Home Assistant Docker container, type docker exec -it homeassistant /bin/bash
  4. Edit the broadlink python package, type vi /usr/local/lib/python3.8/site-packages/broadlink/__init__.py
  5. Add your device code to the list of codes e.g. 0x271D: (sp2, "Ego", "Efergy"), (press i to start editing, Esc to stop editing, :wx to write the file and exit vi)
  6. Save the file and restart Home Assistant via the Home Assistant UI

If you're not familiar with vi, instructions can be found here

@felipediel
Copy link
Contributor

felipediel commented Mar 23, 2021

Hi @sosolid @occamatic. We will improve SP4 support in the next updates. May I see the answer to get_state() to implement the features correctly?

pip3 install broadlink
python3
>>> import broadlink as blk

>>> d = blk.hello("192.168.0.16")  # Example IP address
>>> d.auth()
>>> print(d.get_state())

@sosolid
Copy link

sosolid commented Mar 23, 2021

Here you go:

{'pwr': 1, 'ntlight': 0, 'indicator': 1, 'usbpwr': 0, 'maxworktime': 0, 'usbmaxworktime': 0, 'ntlbrightness': 100, 'current': -1, 'volt': -1, 'power': -1, 'totalconsum': -1, 'overload': -1, 'childlock': 0}

@felipediel
Copy link
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.