what is making me think I am missing something is that the manifest.json states that python_rako is a requirement, and I haven’t installed python_rako, or presumably that is what happens when you add the integration?
Hi.
I think that manifest.json is missing a version number. See post 82 for the resolution.
Has anyone seen this one:
Error while setting up rako platform for light
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/rako/light.py", line 47, in async_setup_entry
async for light in bridge.discover_lights(session):
File "/usr/local/lib/python3.10/site-packages/python_rako/bridge.py", line 163, in discover_lights
for light in self.get_lights_from_discovery_xml(rako_xml):
File "/usr/local/lib/python3.10/site-packages/python_rako/bridge.py", line 198, in get_lights_from_discovery_xml
room_id = int(room["@id"])
TypeError: string indices must be integers
To clarify - it see’s the bridge and integration is seen - but when trying to set up - it errors on that - and my python is pretty much non-existent - after looking through all those files / sections to see where / how things are defined.
Below is the rako.xml config - and you can see my Room ID is an integer:
<rooms>
<Room id="9">
<Type>Lights</Type>
<Title>MASTERBED</Title>
<mode>7+OFF</mode>
<Scene id="1">
<Name>All On</Name>
</Scene>
<Scene id="2">
<Name>All Lamps</Name>
</Scene>
<Scene id="3">
<Name>Open Curtain</Name>
</Scene>
<Scene id="4">
<Name>Bedtime</Name>
</Scene>
<Scene id="5">
<Name>Andrew Lamp</Name>
</Scene>
<Channel id="1">
<type>Default</type>
<Name>Pendant</Name>
<Levels>FF000000000000000000000000000000</Levels>
</Channel>
<Channel id="2">
<type>Default</type>
<Name>Kelly Bedside</Name>
<Levels>FFFF00FF000000000000000000000000</Levels>
</Channel>
<Channel id="3">
<type>Default</type>
<Name>Andrew Bedside</Name>
<Levels>FFFD00FFFFFF00000000000000000000</Levels>
</Channel>
<Channel id="4">
<type>Default</type>
<Name>Lamp</Name>
<Levels>FFA90000000000000000000000000000</Levels>
</Channel>
<Channel id="6">
<type>Default</type>
<Name>Blinds</Name>
<Levels>000054AB00005200B000000000000000</Levels>
</Channel>
</Room>
</rooms>
The XML looks very similar to mine and I can’t visually spot any problem with it. What’s in the <info>
and <config>
levels? and is it all nicely surrounded by
<rako>....</rako>
?
Full listing below:
Somewhere / somehow on setup it is not liking the string / id and thinking it’s not an integer on the auto discovery piece to populate my entities & lights from. And alas my Python is non existent to debug through all those files…
<rako>
<info>
<version>2.5.0 RA</version>
<buildDate>Sep 26 2019 16:03:54</buildDate>
<hostName>RAKOBRIDGE </hostName>
<hostIP>192.168.50.220</hostIP>
<hostMAC>00:1E:C0:97:71:C0</hostMAC>
<hwStatus>05</hwStatus>
<dbVersion>-18</dbVersion>
</info>
<config>
<requirepassword/>
<passhash>NAN</passhash>
<charset>UTF-8</charset>
</config>
<rooms>
<Room id="9">
<Type>Lights</Type>
<Title>MASTERBED</Title>
<mode>7+OFF</mode>
<Scene id="1">
<Name>All On</Name>
</Scene>
<Scene id="2">
<Name>All Lamps</Name>
</Scene>
<Scene id="3">
<Name>Open Curtain</Name>
</Scene>
<Scene id="4">
<Name>Bedtime</Name>
</Scene>
<Scene id="5">
<Name>Andrew Lamp</Name>
</Scene>
<Channel id="1">
<type>Default</type>
<Name>Pendant</Name>
<Levels>FF000000000000000000000000000000</Levels>
</Channel>
<Channel id="2">
<type>Default</type>
<Name>Kelly Bedside</Name>
<Levels>FFFF00FF000000000000000000000000</Levels>
</Channel>
<Channel id="3">
<type>Default</type>
<Name>Andrew Bedside</Name>
<Levels>FFFD00FFFFFF00000000000000000000</Levels>
</Channel>
<Channel id="4">
<type>Default</type>
<Name>Lamp</Name>
<Levels>FFA90000000000000000000000000000</Levels>
</Channel>
<Channel id="6">
<type>Default</type>
<Name>Blinds</Name>
<Levels>000054AB00005200B000000000000000</Levels>
</Channel>
</Room>
</rooms>
</rako>
Well, the XML looks good. So maybe it’s not reaching the HA host or is being corrupted in transit so that only partial XML arrives. A network problem, maybe? I hestiate to suggest it but have you tried turning it off and on again (the Bridge, I mean).
I will try the old power reboot - but it was rebooted when I upgraded the firmware (was on 2.4.4) before I moved it to 2.5.0. I will then try reload the integration and see what happens. It does SEE the bridge and I see it in the integration - that error occurs when trying to setup the various devices via auto discovery I think: Error while setting up rako platform for light
get_lights_from_discovery_xml
room_id = int(room["@id"])
TypeError: string indices must be integers
Spit balling here - but it’s trying to set room_id to = and integer parsed from it as @id - but the xml is “room id” and not “room”… again my coding and python isn’t great so trying to interpret it…
Although I went and checked your XML and it was identical on
<Room id="17">
and mine is just 9 instead…
Going in to the bridge.py in the python-rako on GitHub I see:
@staticmethod
def get_lights_from_discovery_xml(xml: str) -> Generator[Light, None, None]:
xml_dict = xmltodict.parse(xml)
for room in xml_dict["rako"]["rooms"]["Room"]:
room_id = int(room["@id"])
room_type = room.get("Type", "Lights")
if room_type != "Lights":
_LOGGER.info(
"Unsupported room type. room_id=%s room_type=%s", room_id, room_type
)
continue
room_title = room["Title"]
So reading up on the xmltodict - it parses through the rako.xml through rako/rooms/Room - then trys to pull the variable id and store it - but it’s saying it needs to be an integer if being stored in a str function… argh I wish I listened more to my programming courses haha!
SO, it views me as a new user so cannot reply to others anymore… @RichardPar I followed your changes and still no luck:
So I made the changes as you suggested in init.py to:
device_registry = dr.async_get(hass)
However I still get the same issues on startup:
Error while setting up rako platform for light
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/rako/light.py", line 47, in async_setup_entry
async for light in bridge.discover_lights(session):
File "/usr/local/lib/python3.10/site-packages/python_rako/bridge.py", line 163, in discover_lights
for light in self.get_lights_from_discovery_xml(rako_xml):
File "/usr/local/lib/python3.10/site-packages/python_rako/bridge.py", line 198, in get_lights_from_discovery_xml
room_id = int(room["@id"])
TypeError: string indices must be integers
Which I know the ID is set to 9, so don’t know why it’s not seeing as an integer…
Is this integration still working? I just upgraded HomeAssistant to 2023.5.2 and its now non-functional. Its been working -forever- until now
UPDATE :
in the components init.py
change the await async_get_registry()
to aync_get()
- Fixed
Richard
2023-05-06 11:47:42.430 WARNING (MainThread) [custom_components.rako.config_flow] Couldn't auto discover Rako bridge Couldn't interpret discovery response message: b'Rutherwyk House\r\n70-B3-D5-08-45-6B\r\n'
2023-05-06 11:48:17.148 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Rako Bridge (none) for rako
File "/config/custom_components/rako/__init__.py", line 30, in async_setup_entry
2023-05-06 12:05:05.385 WARNING (MainThread) [custom_components.rako.config_flow] Couldn't auto discover Rako bridge Couldn't interpret discovery response message: b'Rutherwyk House\r\n70-B3-D5-08-45-6B\r\n'
2023-05-06 12:05:33.513 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Rako Bridge (ruherwyk) for rako
File "/config/custom_components/rako/__init__.py", line 30, in async_setup_entry
Thanks for that, @RichardPar. I got the same error after updating and, as a temporary measure reverted my HASSOS VM until I had time to look deeper. So, I look forward to trying your fix.
I’m not sure if its being maintained now but It ought to go into the repo.
Hiya,
Thought I’d put my head above the parapet and voice my appreciation of the Rako integration. And also to mention it’s been working well since it appeared, and I’m now suffering a similar problem.
As a hardware minded soul, I’d appreciate a software brain to look into the issue.
I had a look at my init.py file, tried tinkering, but no joy.
I’m running HA OS on a generic x86, with the original Rako bridge.
Thanks in advance, and if there’s any other information I can provide to help…
Andy
Update: After much reading and some trial and error the results are in:
Original line 30 of init.py:
device_registry = await dr.async_get_registry(hass)
Edited to:
device_registry = dr.async_get(hass)
I’m no software specialist, but this seems to have retored functionality. For now at least!
A
Thanks @loosleyandy . So it would seem that a method has been renamed in the core! I’m betting that will break other integrations too.
Thanks for doing this. I havent updated to HA 2023.5 yet, apologies for silly question but where is the init.py file that needs to be edited?
Found at:
/config/custom_components/rako/__init__.py
A
Thank you very much Andy. I updated and don’t seem to have the problem. Maybe it’s only an issue with HA OS? I run HA on docker.
Sorry to wade back in since the broken aync_get fix. But has anyone else tried to setup Rako and get the following in logs about not being able to start:
Error while setting up rako platform for light
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/rako/light.py", line 47, in async_setup_entry
async for light in bridge.discover_lights(session):
File "/usr/local/lib/python3.10/site-packages/python_rako/bridge.py", line 163, in discover_lights
for light in self.get_lights_from_discovery_xml(rako_xml):
File "/usr/local/lib/python3.10/site-packages/python_rako/bridge.py", line 198, in get_lights_from_discovery_xml
room_id = int(room["@id"])
TypeError: string indices must be integers
I even asked ChatGPT for help and it stated:
Based on the error message, it seems that the code is trying to access a string using a non-integer index. Specifically, the line of code
room_id = int(room["@id"])
is causing the error.This suggests that the variable
room
is a string and not a dictionary or another type of object that can be indexed with a string. This could happen if the input data is not formatted as expected or if there is an issue with the code that is generating the input data.
However, that error is on the python_rako/bridge.py which I don’t know where that’s maintained or how to update that!
@loosleyandy Thanks, again for your hack of init.py after 2023.5.2. I have just upgraded to 2023.6.1 and implemented your fix - Life saver!
Sadly, it looks like the integration will need workarounds like this going forward. There are not enough rako users to generate devs who can take on the excellent work that @marengaz has done for us.