Rako Lighting

Yes indeed, I fully understand that without a Rako installation @marengaz will not be able to test any changes - sorry for not mentioning that previously.

I am quite happy to hack at the code myself and try things out. Any hints gratefully received.

Rako tech support told me they don’t know of any reason why the bridge would stop sending UDP updates when status changes. I’ve upgraded to Bridge firmware v2.5.0 and the problem has not gone away.

@marengaz - I see you have the full core as a repo but do you have a repo of just the integration files that I can fork?

hi all
the error with the scenes outside the range 0-4 can be very naively worked around. try bumping the version of python-rako in you manifest.json to 0.0.14. hopefully that will at least save you from rebooting the whole time.

a repo of just the integration files that I can fork?

with hindsight, i probably should have done this from the beginning and matured the integration in HACS before adding to hass core. no, i havent done this yet, or really figured out how HACS works! is it just a case of copying the code into a new repo or is there more involved? ill try and read up about it

Thanks for that. I will give it a try.

I found the python-rako library on pypi and had a good read in conjunction with the Home Assistant integration code. Sadly, my feeble brain can’t hold that many levels of abstraction all at once (object oriented programming often defies my attempts at comprehension).

I have discovered the selenium python library which looks very promising for automating a bridge reboot. Also, I’m looking into matching log entries against commands sent - to see when there was no response detected from the bridge and automate a reload of the integration. If the integration created two sensors - time last command sent & time last status received, it would be a perfect way to do this. Once again my OOP skills let me down.

As ever, thanks for the response. What lighting have you got in your new place?

I was stuck at this point for some time, post number 82 stating that a version number needs to be added to the manifest.json was the solution for me.

Hi @marengaz. Many thanks for the work that you have put in here, it’s appreciated!

I stumbled for a while getting the integration working, primarily as Im a newbie to HA. But I got to the stage where I could add the integration and it detected my Rako IP address without issue.

However, after this stage, I’m left with an integration that has 1 device but no entities and no lights have turned up in the auto created dashboard.

I’ve pulled my rako.xml file from the hub, but have no way of seeing how this compares to others. Have I missed something?

<?xml version="1.0" encoding="UTF-8"?>
<rako>
<info>
<version>2.5.0 RA</version>
<buildDate>Sep 26 2019 16:03:54</buildDate>
<hostName>RAKOBRIDGE     </hostName>
<hostIP>192.168.4.65</hostIP>
<hostMAC>00:1E:C0:99:A2:A2</hostMAC>
<hwStatus>05</hwStatus>
<dbVersion>-18</dbVersion>
</info>
<config>
<requirepassword></requirepassword>
<passhash>NAN</passhash>
<charset>UTF-8</charset>
</config>
<rooms>
	<Room id="9">
		<Type>Lights</Type>
		<Title>Cinema</Title>
		<mode>7+OFF</mode>
		<Scene id="1">
			<Name>Blue</Name>
		</Scene>
		<Scene id="2">
			<Name>Green</Name>
		</Scene>
		<Scene id="3">
			<Name>Red</Name>
		</Scene>
		<Scene id="4">
			<Name>Purple</Name>
		</Scene>
		<Scene id="5">
			<Name>Yellow</Name>
		</Scene>
		<Scene id="6">
			<Name>Red Twinkle Slow</Name>
		</Scene>
		<Scene id="7">
			<Name>Green Twinkle Slow</Name>
		</Scene>
		<Scene id="8">
			<Name>Yellow Twinkle Slow</Name>
		</Scene>
		<Scene id="9">
			<Name>Purple Twinkle Slow</Name>
		</Scene>
		<Scene id="10">
			<Name>All On</Name>
		</Scene>
		<Scene id="11">
			<Name>Cinema Dim</Name>
		</Scene>
		<Scene id="12">
			<Name>Cinema Play</Name>
		</Scene>
		<Scene id="13">
			<Name>Cinema Pause</Name>
		</Scene>
		<Scene id="14">
			<Name>Cinema Stop</Name>
		</Scene>
		<Channel id="1">
			<type>Slider</type>
			<Name>Star Colour</Name>
			<Levels>623829ED4A002F467400BF0000000000</Levels>
		</Channel>
		<Channel id="2">
			<type>Default</type>
			<Name>Channel 2</Name>
			<Levels>00000000000000000000000000000000</Levels>
		</Channel>
		<Channel id="3">
			<type>Slider</type>
			<Name>Star Twinkle</Name>
			<Levels>2143D8CC6CCFE5E5E5CC00D6DBD60000</Levels>
		</Channel>
		<Channel id="4">
			<type>Slider</type>
			<Name>Star Brightness</Name>
			<Levels>6A5C7F7F601B7F7F7F7D0C0E11210000</Levels>
		</Channel>
		<Channel id="5">
			<type>Slider</type>
			<Name>Red Brightness</Name>
			<Levels>00005795650000000000000000000000</Levels>
		</Channel>
		<Channel id="6">
			<type>Default</type>
			<Name>LED Green Brightness</Name>
			<Levels>004F0000290000000000000000000000</Levels>
		</Channel>
		<Channel id="7">
			<type>Default</type>
			<Name>LED Blue Brightness</Name>
			<Levels>590000910000000000FF23000C320000</Levels>
		</Channel>
		<Channel id="8">
			<type>Default</type>
			<Name>LED White Brighness</Name>
			<Levels>00000000000000000000000000000000</Levels>
		</Channel>
		<Channel id="9">
			<type>Slider</type>
			<Name>Channel 9</Name>
			<Levels>FFBF7F3F000000000000000000000000</Levels>
		</Channel>
		<Channel id="10">
			<type>Slider</type>
			<Name>Channel 10</Name>
			<Levels>FFBF7F3F000000000000000000000000</Levels>
		</Channel>
		<Channel id="11">
			<type>Slider</type>
			<Name>Channel 11</Name>
			<Levels>FFBF7F3F000000000000000000000000</Levels>
		</Channel>
		<Channel id="12">
			<type>Slider</type>
			<Name>Channel 12</Name>
			<Levels>FFBF7F3F000000000000000000000000</Levels>
		</Channel>
	</Room>
	<Room id="10">
		<Type>Lights</Type>
		<Title>Cinema 2</Title>
	</Room>
	<Room id="17">
		<Type>Lights</Type>
		<Title>Living Room</Title>
		<Channel id="1">
			<type>Slider</type>
			<Name>Channel 1</Name>
			<Levels>FFA27F3F000000000000000000000000</Levels>
		</Channel>
		<Channel id="2">
			<type>Slider</type>
			<Name>Channel 2</Name>
			<Levels>FF007F3F000000000000000000000000</Levels>
		</Channel>
		<Channel id="3">
			<type>Slider</type>
			<Name>Channel 3</Name>
			<Levels>FFA57F3F000000000000000000000000</Levels>
		</Channel>
		<Channel id="4">
			<type>Slider</type>
			<Name>Channel 4</Name>
			<Levels>FF007F3F000000000000000000000000</Levels>
		</Channel>
	</Room>
	<Room id="13">
		<Type>Lights</Type>
		<Title>Cinema 2</Title>
		<mode>7+OFF</mode>
		<Scene id="1">
			<Name>Blue</Name>
		</Scene>
		<Scene id="2">
			<Name>Green</Name>
		</Scene>
		<Scene id="3">
			<Name>Red</Name>
		</Scene>
		<Scene id="4">
			<Name>Purple</Name>
		</Scene>
		<Scene id="5">
			<Name>Yellow</Name>
		</Scene>
		<Scene id="6">
			<Name>Orange</Name>
		</Scene>
		<Scene id="7">
			<Name>Bright Blue</Name>
		</Scene>
		<Scene id="8">
			<Name>Pale Blue</Name>
		</Scene>
		<Scene id="9">
			<Name>Mid Blue</Name>
		</Scene>
		<Scene id="10">
			<Name>Of</Name>
		</Scene>
		<Scene id="11">
			<Name>All On</Name>
		</Scene>
		<Scene id="12">
			<Name>Cinema Dim</Name>
		</Scene>
		<Scene id="13">
			<Name>Cinema Play</Name>
		</Scene>
		<Scene id="14">
			<Name>Cinema Pause</Name>
		</Scene>
		<Scene id="15">
			<Name>Cinema Stop</Name>
		</Scene>
		<Channel id="1">
			<type>Slider</type>
			<Name>Stage Red</Name>
			<Levels>0000788C63F700310000000000000000</Levels>
		</Channel>
		<Channel id="2">
			<type>Slider</type>
			<Name>Stage Green</Name>
			<Levels>007300004F3767A00000000000000000</Levels>
		</Channel>
		<Channel id="3">
			<type>Slider</type>
			<Name>Stage Blue</Name>
			<Levels>980000B300006F7F5F00FF1F00213800</Levels>
		</Channel>
		<Channel id="5">
			<type>Slider</type>
			<Name>Red</Name>
			<Levels>0000788C5EF700310000000000000000</Levels>
		</Channel>
		<Channel id="6">
			<type>Slider</type>
			<Name>Green</Name>
			<Levels>006E0000463765A00000000000000000</Levels>
		</Channel>
		<Channel id="7">
			<type>Slider</type>
			<Name>Blue</Name>
			<Levels>900000B30000717F5F00FF1F001B3800</Levels>
		</Channel>
	</Room>

</rooms>
</rako>

Anything in the HA core logs? If not, put this (or similar) in configuration.yaml and restart.

logger:
  default: warning
  logs:
    homeassistant.components.rako: debug
    python_rako: debug

So this is what’s in the log shortly after restart with the logger code in place that your suggested… I don’t see any errors though?

2022-03-10 21:53:09 WARNING (SyncWorker_5) [homeassistant.loader] We found a custom integration rako which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2022-03-10 21:53:10 DEBUG (MainThread) [python_rako.bridge] Requesting cache: RequestType.SCENE_LEVEL_CACHE
2022-03-10 21:53:10 DEBUG (MainThread) [python_rako.bridge] Cache response: {RoomChannel(room_id=9, channel_id=1): LevelCacheItem(active_deleted_reserved=128, room=9, channel=1, scene_levels={1: 98, 2: 56, 3: 41, 4: 237, 5: 74, 6: 0, 7: 47, 8: 70, 9: 116, 10: 0, 11: 191, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=2): LevelCacheItem(active_deleted_reserved=128, room=9, channel=2, scene_levels={1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=3): LevelCacheItem(active_deleted_reserved=128, room=9, channel=3, scene_levels={1: 33, 2: 67, 3: 216, 4: 204, 5: 108, 6: 207, 7: 229, 8: 229, 9: 229, 10: 204, 11: 0, 12: 214, 13: 219, 14: 214, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=4): LevelCacheItem(active_deleted_reserved=128, room=9, channel=4, scene_levels={1: 106, 2: 92, 3: 127, 4: 127, 5: 96, 6: 27, 7: 127, 8: 127, 9: 127, 10: 125, 11: 12, 12: 14, 13: 17, 14: 33, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=5): LevelCacheItem(active_deleted_reserved=128, room=9, channel=5, scene_levels={1: 0, 2: 0, 3: 87, 4: 149, 5: 101, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=6): LevelCacheItem(active_deleted_reserved=128, room=9, channel=6, scene_levels={1: 0, 2: 79, 3: 0, 4: 0, 5: 41, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=7): LevelCacheItem(active_deleted_reserved=128, room=9, channel=7, scene_levels={1: 89, 2: 0, 3: 0, 4: 145, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 255, 11: 35, 12: 0, 13: 12, 14: 50, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=8): LevelCacheItem(active_deleted_reserved=128, room=9, channel=8, scene_levels={1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=9): LevelCacheItem(active_deleted_reserved=128, room=9, channel=9, scene_levels={1: 255, 2: 191, 3: 127, 4: 63, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=10): LevelCacheItem(active_deleted_reserved=128, room=9, channel=10, scene_levels={1: 255, 2: 191, 3: 127, 4: 63, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=11): LevelCacheItem(active_deleted_reserved=128, room=9, channel=11, scene_levels={1: 255, 2: 191, 3: 127, 4: 63, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=9, channel_id=12): LevelCacheItem(active_deleted_reserved=128, room=9, channel=12, scene_levels={1: 255, 2: 191, 3: 127, 4: 63, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=17, channel_id=1): LevelCacheItem(active_deleted_reserved=128, room=17, channel=1, scene_levels={1: 255, 2: 162, 3: 127, 4: 63, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=17, channel_id=2): LevelCacheItem(active_deleted_reserved=128, room=17, channel=2, scene_levels={1: 255, 2: 0, 3: 127, 4: 63, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=17, channel_id=3): LevelCacheItem(active_deleted_reserved=128, room=17, channel=3, scene_levels={1: 255, 2: 165, 3: 127, 4: 63, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=17, channel_id=4): LevelCacheItem(active_deleted_reserved=128, room=17, channel=4, scene_levels={1: 255, 2: 0, 3: 127, 4: 63, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=13, channel_id=1): LevelCacheItem(active_deleted_reserved=128, room=13, channel=1, scene_levels={1: 0, 2: 0, 3: 120, 4: 140, 5: 99, 6: 247, 7: 0, 8: 49, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=13, channel_id=2): LevelCacheItem(active_deleted_reserved=128, room=13, channel=2, scene_levels={1: 0, 2: 115, 3: 0, 4: 0, 5: 79, 6: 55, 7: 103, 8: 160, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=13, channel_id=3): LevelCacheItem(active_deleted_reserved=128, room=13, channel=3, scene_levels={1: 152, 2: 0, 3: 0, 4: 179, 5: 0, 6: 0, 7: 111, 8: 127, 9: 95, 10: 0, 11: 255, 12: 31, 13: 0, 14: 33, 15: 56, 16: 0, 17: 0}), RoomChannel(room_id=13, channel_id=5): LevelCacheItem(active_deleted_reserved=128, room=13, channel=5, scene_levels={1: 0, 2: 0, 3: 120, 4: 140, 5: 94, 6: 247, 7: 0, 8: 49, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=13, channel_id=6): LevelCacheItem(active_deleted_reserved=128, room=13, channel=6, scene_levels={1: 0, 2: 110, 3: 0, 4: 0, 5: 70, 6: 55, 7: 101, 8: 160, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0}), RoomChannel(room_id=13, channel_id=7): LevelCacheItem(active_deleted_reserved=128, room=13, channel=7, scene_levels={1: 144, 2: 0, 3: 0, 4: 179, 5: 0, 6: 0, 7: 113, 8: 127, 9: 95, 10: 0, 11: 255, 12: 31, 13: 0, 14: 27, 15: 56, 16: 0, 17: 0})}
2022-03-10 21:53:10 DEBUG (MainThread) [python_rako.bridge] Cache response: {9: 0, 13: 0, 17: 0}

And just like that, all the lights appeared!!!?

1 Like

Don’t you just love it when that happens!?

Actually, I’m trying to debug a weird problem with the integration at the moment and I’m finding that almost always a reload of the integration solves it (for a while).

Got it working - is there away I can activate a scene which is on the RAKO box?

Not that I have seen. The real power is the ability to set new scenes and automations in HA which have non rako lights or devices. I also found that many of my Rako switches set scenes and that didn’t update the state of lights in HA.

I reprogrammed the switches to set the lights directly and now the states are updated correctly.

Yes, in this example I call the HTTP API on the bridge from node-RED to set a scene. Obviously, you can call the API using any suitable client - a browser even!

thanks… I was thinking more in HA . Something like lights.lounge_scene_0 type of entity :smiley:

Each room can have 5 fake light swithes exposed - which represent the scenes.

You might find the answer in the RESTful command in Home Assistant. I’d suggest experimenting with calling the API from here.
Another approach might be to construct a curl command and exec it on the host via the shell command..
I use HA’s node-RED integration quite a lot so it seems natural to do it that way.

that seems counter-intuative as all the scene information is on the box… also the Rako hub gives back status on it. using a CURL command seems like a hack more than a solution.

I have to agree with you there, @RichardPar. The API is intended to be properly integrated with good client software like that which @marengaz has generously provided. I suspect that he’s no longer in a position to develop it further having moved to a ‘non-Rako’ house. So, of the options left, a hack is one which consumes minimal time and requires the level of expertise that I, at least, can muster. The nice thing about HA in this respect, is that it’s built with the hacker in mind.

Thanks -

I am going to use the codebase and try make a new one. Never done python before, so learning the language.

Bravo!

In case you’ve not spotted it yet the python rako module is here:

and the HA integration makes heavy use of that.

Hi chaps, me again…

So using the custom_control integration, I have a few channels that just don’t seem to reflect / update the Rako lighting and I can’t fathom out the oddity. So I thought I would revisit and was looking at the rakomqtt solution.

Firstly, I think I must be showing signs of age as Im getting myself in a pickle, thought I’d get that out of the way first!

So I removed the custom-component integration that I downloaded previously.

I’ve then installed Marengaz’s RakoMQTT docker image and that is working nicely and using MQTT explorer I can see all the topic updates on the MQTT device as expected. So far so good.

My issue appears to be with correctly configuring a light over MQTT in HA. I’ve added the following to my configuration.yaml as a sample channel.

light:
  - platform: mqtt
    name: Cinema Stage Blue
    state_topic: "rako/room/13/channel/3"
    command_topic: "rako/room/13/channel/3/set"
    brightness_state_topic: "rako/room/13/channel/3/brightness"
    brightness_command_topic: "rako/room/13/channel/3/brightness/set"

and here you can see the MQTT explorer data for that topic…

The topic updates as soon as I adjust the light in the Rako app on my phone as expected, so I think the Docker image piece is working as advertised.

But in HA, I see the light that I added, but it doesn’t update according to the changes in the light state or brightness, so I think my yaml is incorrect. Can anyone guide me on what I am doing wrong here please?

Oh and one other query…

Are the custom component solutions and the docker / mqtt solutions mutually exclusive and just so happens that @marengaz created both?

I think this bit is confusing me as to whether I should be using both or one or the other.