Rako Lighting

Has anyone here got or thought about an integration with Rako lighting & control systems? There aren’t any python libraries for Rako so that’d presumably need to exist before thinking about a HASS module. There’s basic control via HTTP requests and more granular control & feedback through sockets (connection to a local Rako hardware bridge)

I’m tempted to have a play and write something, but they’ve also said there’s a new bridge with Homekit & better communication coming, so might just sit it out and wait for that.

Wanted to see if anyone else had the same ideas?

I’ve made a start on a simple Rako bridge library for python. It’s uber simple at the moment but does bridge discovery and set level commands

1 Like

That looks promising, I went for the simple solution and implemented control in HA through calling the bridge http endpoint with a shell script and the template light component. I get full on/off/dimming control, but there are a few features which I’m missing, some of them haven’t yet been implemented in HA, and some are due to Rako limitations.

Features Missing from HA

  • RGB colour picker for a LED strip light

Limitations from Rako hardware

  • 2-way feedback (so that HA can poll to get current status from the bridge) - AFAIK it’s not possible to query the bridge to get the status of a light, but it might be possible to keep a constant listening connection open to the bridge. HA could parse these and mirror the current bridge status in its DB.
  • Ability to use Rako switches as sensors in HA (related to the point above about 2-way feedback from the bridge) - if this were possible I could simplify the Rako programming and move that logic over to HA

There’s a new cloud gateway coming out soon which promises Alexa/IFTTT/API integration, but it’s £250, which seems pretty steep

Hi there, new to HA. Would you be willing to share your Rako implementation :slight_smile:

For simple on/off/brightness control I have the following bash script on my HA server (you’ll need to change the IP to that of your bridge):

#!/bin/bash

ROOM=$1
CHANNEL=$2
LEVEL=$3

curl -X POST "http://192.168.1.207/rako.cgi?room=${ROOM}&ch=${CHANNEL}&lev=${LEVEL}" > /dev/null 2>&1

I then have a HA config for shell command:

bash /home/homeassistant/.homeassistant/scripts/rako.sh {{room}} {{channel}} {{level}}

For each Rako circuit I have the following (with the room & channel changed to match the Rako config. I’m not using the Rako concept of masters):

- platform: template
  lights:
    bedroom1_ceiling:
      friendly_name: "Bedroom"
      turn_on:
        service: shell_command.rako
        data_template:
          room: 28
          channel: 1
          level: 255
      turn_off:
        service: shell_command.rako
        data_template:
           room: 28
           channel: 1
           level: 0
      set_level:
        service: shell_command.rako
        data_template:
          room: 28
          channel: 1
          level: "{{brightness}}"

This gives 1-way control, HA will update Rako and remember the state of what HA has set, but using the Rako app or a keypad means that things can get out of sync very quickly.

I’ve done some work on looking into hacking together 2-way control, but never got round to implementing it reliably, so I don’t use it.

You’ll need to check the spacing & indentation from the code snippets above, as I’ve got a lot of my config split out into separate files, it’s all up at https://github.com/anthonyangel/Home-AssistantConfig

Cheers, I’ll give that a go

Hi all,

Very new to all this. This looks ace.

How would I go about adding Rako Control to my homeassistant setup? Does this code need to be added to configuration.yarl?

Hi Anthony,

I’m new to HASS and programming in general. I have RAKO lighting system at home and would be interested in using my Harmony remote controller to assign buttons to control lights in one particular room. Are you able to advise how I might go about learning how to do this - using your github as a starting point?

Thanks in advance for any help or advice you could send my way.

Rich

helped me a lot, thnx verry much

hi all
i just published a rako light mqtt component which also watches for state updates (if you press the light switch instead of use HA to change the state of the light)


ive only implemented brightness (because thats all my rako lights can do)
happy for feedback and prs
cheers
ben

Hi Marengaz,

How do I connect this… I have had a look at your GitHub, but am not 100% sure how to implement. I have setup the MQTT integration in HA, but cannot progress beyond this point. Any assistance would be greatatefully received.

hey @Richard_Ellis

  • grab the username and password out of the mqtt settings in the hassio addon
  • set them as env vars along with all the others (see the config section of the readme)
  • use the compose file (see the Build and deploy section of the readme)
  • set up your lights in HA (see Home assistant light config section of the readme)

Thanks for coming back to me.

I’m not having much luck with this. Don’t suppose you’d be up for a remote session to get this up & running? Can pay for your time if reasonable?

hi all
i overhauled my code so it should now be very easy to install using portainer
let me know if it works in your environments!

Hi,

Thank you for this work, however I am having difficulty installing the integration based on your instructions.

After I create the container, Portainer is failing to run it. Log reports the following entry ;

standard_init_linux.go:211: exec user process caused “exec format error”

I have tested my Mosquitto MQTT which seems to be working fine, have I missed something ?

On the flip side, after manually installing the integration via “docker-compose” command it is working. Only issue is when I use the template I cannot define which channel to use for a given room id.

i.e.

  • platform: mqtt
    name: Hallway
    schema: json
    state_topic: “rako/room/42”
    command_topic: “rako/room/42/set”
    brightness: true

Where can we specify which channel to use for the above room (42) ?

Thank you!

hi erdem

sorry to hear of your portainer struggles. my code is written in python, so the go error must be somewhere else. open a issue on the github with the full logs if you’d like me to investigate further?

on the channel specification. annoyingly, i found that when i created a home assistant scene, changing multiple rako channels at the same time, the rako bridge just randomly ignores some of the commands without notice (maybe sent in too quick succession?). my work around for this was to set up 4 scenes per room in the rako app scene 1 being the brightest, 4 being the dimmest, then just map 100%-0% brightness scale to scene number. see these 2 functions for more detail. if you’d like me to consider implementing the channel granularity anyway, please open a github issue?

best regards
ben

Hi Ben,

Thank you very much for your prompt response, I have now updated the original issue to a feature request as I was able to manually install using docker-compose method.

It will be great if you can implement the possibility of controlling separate channels for a given room.

Best Regards,

Erdem

Hi Ben,

Did you had any time to see if multi channel operation can be implemented ?

Many Thanks,

Erdem

pushed a new container. let me know how you get on!

Hi Ben,

I just implemented your recent code changes, I confirm that granule control of rooms and channels is working for my requirements so a big “Thank you!” for this. However I have noticed that when I control the light switch from the physical wall plate, light states do not get updated on Home Assistant it seems it is still a one-way communication from Home Assistant to RakoBridge.

Please see below container log output for your information, I would appreciate if you can advise if this is how it was intended to work or 2-way communication is possible ?

Many Thanks

2020-05-27 22:37:33 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:38:33 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:38:33 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:38:33 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:38:33 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:39:33 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:39:33 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:39:33 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:39:33 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:40:02 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PUBLISH (d0, q0, r0, m0), ‘rako/room/9/channel/1/set’, … (15 bytes),

2020-05-27 22:40:02 DEBUG (MainThread) [commander] [rakomqtt.RakoBridge] payload {‘room’: 9, ‘ch’: 1, ‘lev’: 255},

2020-05-27 22:40:02 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 7, 0, 9, 1, 52, 1, 255, 194],

2020-05-27 22:40:02 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m1), ‘b’rako/room/9/channel/1’’, … (34 bytes),

2020-05-27 22:40:02 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/9/channel/1: {“state”: “ON”, “brightness”: 255}. response: (0, 1),

2020-05-27 22:40:07 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PUBLISH (d0, q0, r0, m0), ‘rako/room/9/channel/1/set’, … (16 bytes),

2020-05-27 22:40:07 DEBUG (MainThread) [commander] [rakomqtt.RakoBridge] payload {‘room’: 9, ‘ch’: 1, ‘lev’: 0},

2020-05-27 22:40:07 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 7, 0, 9, 1, 52, 1, 0, 193],

2020-05-27 22:40:07 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m2), ‘b’rako/room/9/channel/1’’, … (33 bytes),

2020-05-27 22:40:07 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/9/channel/1: {“state”: “OFF”, “brightness”: 0}. response: (0, 2),

2020-05-27 22:40:33 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:40:33 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:40:34 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:40:34 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:41:30 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PUBLISH (d0, q0, r0, m0), ‘rako/room/9/channel/4/set’, … (16 bytes),

2020-05-27 22:41:30 DEBUG (MainThread) [commander] [rakomqtt.RakoBridge] payload {‘room’: 9, ‘ch’: 4, ‘lev’: 0},

2020-05-27 22:41:31 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 7, 0, 9, 4, 52, 1, 0, 190],

2020-05-27 22:41:31 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m3), ‘b’rako/room/9/channel/4’’, … (33 bytes),

2020-05-27 22:41:31 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/9/channel/4: {“state”: “OFF”, “brightness”: 0}. response: (0, 3),

2020-05-27 22:41:32 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PUBLISH (d0, q0, r0, m0), ‘rako/room/17/channel/2/set’, … (16 bytes),

2020-05-27 22:41:32 DEBUG (MainThread) [commander] [rakomqtt.RakoBridge] payload {‘room’: 17, ‘ch’: 2, ‘lev’: 0},

2020-05-27 22:41:32 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 7, 0, 17, 2, 52, 1, 0, 184],

2020-05-27 22:41:32 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m4), ‘b’rako/room/17/channel/2’’, … (33 bytes),

2020-05-27 22:41:32 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/17/channel/2: {“state”: “OFF”, “brightness”: 0}. response: (0, 4),

2020-05-27 22:41:34 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:41:34 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:41:36 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:41:36 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PUBLISH (d0, q0, r0, m0), ‘rako/room/9/channel/2/set’, … (16 bytes),

2020-05-27 22:41:36 DEBUG (MainThread) [commander] [rakomqtt.RakoBridge] payload {‘room’: 9, ‘ch’: 2, ‘lev’: 0},

2020-05-27 22:41:36 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 7, 0, 9, 2, 52, 1, 0, 192],

2020-05-27 22:41:36 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m5), ‘b’rako/room/9/channel/2’’, … (33 bytes),

2020-05-27 22:41:36 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/9/channel/2: {“state”: “OFF”, “brightness”: 0}. response: (0, 5),

2020-05-27 22:41:36 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PUBLISH (d0, q0, r0, m0), ‘rako/room/17/channel/1/set’, … (16 bytes),

2020-05-27 22:41:36 DEBUG (MainThread) [commander] [rakomqtt.RakoBridge] payload {‘room’: 17, ‘ch’: 1, ‘lev’: 0},

2020-05-27 22:41:36 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 7, 0, 17, 1, 52, 1, 0, 185],

2020-05-27 22:41:36 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m6), ‘b’rako/room/17/channel/1’’, … (33 bytes),

2020-05-27 22:41:36 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/17/channel/1: {“state”: “OFF”, “brightness”: 0}. response: (0, 6),

2020-05-27 22:41:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PUBLISH (d0, q0, r0, m0), ‘rako/room/9/channel/3/set’, … (16 bytes),

2020-05-27 22:41:37 DEBUG (MainThread) [commander] [rakomqtt.RakoBridge] payload {‘room’: 9, ‘ch’: 3, ‘lev’: 0},

2020-05-27 22:41:37 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 7, 0, 9, 3, 52, 1, 0, 191],

2020-05-27 22:41:37 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m7), ‘b’rako/room/9/channel/3’’, … (33 bytes),

2020-05-27 22:41:37 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/9/channel/3: {“state”: “OFF”, “brightness”: 0}. response: (0, 7),

2020-05-27 22:41:39 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:42:34 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:42:34 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:42:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:42:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:43:34 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:43:34 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:43:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:43:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:43:39 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 10, 0, 9, 0, 49, 1, 3, 0, 0, 0, 194],

2020-05-27 22:43:39 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m8), ‘b’rako/room/9’’, … (34 bytes),

2020-05-27 22:43:39 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/9: {“state”: “ON”, “brightness”: 128}. response: (0, 8),

2020-05-27 22:44:35 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:44:35 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:44:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:44:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:45:09 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 10, 0, 9, 0, 49, 1, 4, 0, 0, 0, 193],

2020-05-27 22:45:09 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m9), ‘b’rako/room/9’’, … (33 bytes),

2020-05-27 22:45:09 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/9: {“state”: “ON”, “brightness”: 64}. response: (0, 9),

2020-05-27 22:45:11 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 10, 0, 9, 0, 50, 128, 0, 0, 1, 0, 68],

2020-05-27 22:45:11 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] unhandled bytestring: 50 is not a valid RakoCommandType,

2020-05-27 22:45:12 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 5, 0, 9, 0, 15, 232],

2020-05-27 22:45:12 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] unhandled bytestring: 15 is not a valid RakoCommandType,

2020-05-27 22:45:12 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 10, 0, 9, 0, 50, 128, 0, 0, 1, 0, 68],

2020-05-27 22:45:12 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] unhandled bytestring: 50 is not a valid RakoCommandType,

2020-05-27 22:45:12 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 5, 0, 9, 0, 15, 232],

2020-05-27 22:45:12 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] unhandled bytestring: 15 is not a valid RakoCommandType,

2020-05-27 22:45:13 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 10, 0, 9, 0, 50, 128, 0, 0, 1, 0, 68],

2020-05-27 22:45:13 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] unhandled bytestring: 50 is not a valid RakoCommandType,

2020-05-27 22:45:13 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 5, 0, 9, 0, 15, 232],

2020-05-27 22:45:13 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] unhandled bytestring: 15 is not a valid RakoCommandType,

2020-05-27 22:45:35 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:45:35 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:45:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:45:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:46:35 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:46:35 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:46:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:46:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:47:24 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 10, 0, 9, 0, 49, 1, 4, 0, 0, 0, 193],

2020-05-27 22:47:24 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m10), ‘b’rako/room/9’’, … (33 bytes),

2020-05-27 22:47:24 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/9: {“state”: “ON”, “brightness”: 64}. response: (0, 10),

2020-05-27 22:47:26 DEBUG (MainThread) [watcher] [rakomqtt.RakoBridge] received byte_list: [83, 10, 0, 9, 0, 49, 1, 3, 0, 0, 0, 194],

2020-05-27 22:47:26 DEBUG (MainThread) [watcher] [paho.mqtt.client] Sending PUBLISH (d0, q0, r0, m11), ‘b’rako/room/9’’, … (34 bytes),

2020-05-27 22:47:26 DEBUG (MainThread) [watcher] [rakomqtt.MQTTClient] published to rako/room/9: {“state”: “ON”, “brightness”: 128}. response: (0, 11),

2020-05-27 22:47:36 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:47:36 DEBUG (Thread-1) [watcher] [paho.mqtt.client] Received PINGRESP,

2020-05-27 22:47:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Sending PINGREQ,

2020-05-27 22:47:37 DEBUG (MainThread) [commander] [paho.mqtt.client] Received PINGRESP,’