3

I would like to know if anyone has been able to take control over 'Niko Home Control' with a PC or microcontroller (arduino)?

I Googled, but can't find much on this topic. Is it even possible? I guess it's not really open-source.

Things like:

  • Control the lights
  • Monitoring which lights are on/off

I'm planning on using the 'Niko Home Control' in my house, but like to use our own interface (Arduimotic).

Think Graphical
  • 163
  • 1
  • 8
  • It sounds like the PC software and smartphone app connect over a TCP/IP connection, you might be able to use a program like Wireshark to examine the protocol. It could vary though from fairly easy to understand to extremely difficult if it's obfuscated and/or encrypted. – PeterJ Mar 19 '14 at 10:53
  • With very little knowledge about this "Niko" project I do advice against closed protocols. They can change at any time and you have to play "catch up". So even if you figured out how it works today, will it work tomorrow? Why do you want to use it? – Johan Mar 19 '14 at 13:06
  • I'm currently building a new house and want I've always wanted some sort of automation. I've build a prototype with arduino and some relais connected trough RF/ethernet to a webserver. But my girlfriend doesn't trust it enough to be implemented in our new house. So Niko seemed to be a (relatively) low-cost option. The plus side is that it's a stable system with stylish switches/push buttons and will still work when my webserver is down (for whatever reason) or while having a bug. Disclaimer: I'm more of a webdeveloper and have very little experience with micro-controllers. – Think Graphical Mar 19 '14 at 19:08
  • @PeterJ Didn't know about Wireshark, it sure seems to be an option. Thanks for the suggestion! – Think Graphical Mar 19 '14 at 19:21
  • Did you manage to control your Niko HC eventually? Kind Regards, Piet –  Mar 23 '15 at 14:43
  • I've managed to get the device list from my HC & was able to control the lights with a PacketSender app. I've installed a Android Emulator on my mac & then I was able to sniff the communication. Just like @wouter said. The next step for me now is to send such packet with PHP or Javascript. I'll keep you guys posted. Thanks a lot! – Think Graphical Apr 08 '15 at 10:18
  • Realy like this! I have Niko HC too and wondered if it was possible to tweek it. I'l defenitely try it! –  Dec 18 '15 at 23:24

2 Answers2

3

Update

I was able to control Niko HC with help from @wouter.

I've installed a Android Emulator on my mac. Then with Wireshark I was able to sniff the communication.

Once you find the IP of the controller it's relatively simple:

First you need to send a TCP command: {"cmd": "startevents"}. This enables you to get feedback from the controller (to verify if the light turned on or it failed)

Then you can send a new TCP command: {"cmd": "listactions"}. This give you an overview of the available "actions" and their status (lights, actions,...)

If you want to know which rooms are available you'll need following command: {"cmd":"listlocations"} (Thanks to @Wim Deblauwe)

If you want to control an action you'll need following command:
{"cmd": "executeactions", id="{ID}", "value1" = "{VALUE}"}

People with the energy module can use following TCP command: {"cmd": "listenergy"}. This should give you an overview of the energy consumption (I don't own this module so I'm not 100% sure).

If you want info about the system, then you can use following TCP command: {"cmd": "systeminfo"}. This gives you information like language, currency, api version,...

With Laravel I've build a little API which allows me to call an simple URL to control the lights: /api/lights/{LIGHT}/{VALUE}

This calls following function:

Route::get('/api/lights/{light}/{value}', function($light, $value){

$service_port = 8000;
$address = '192.168.0.233';

/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
    return "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
}

$result = socket_connect($socket, $address, $service_port);
if ($result === false) {
    return "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n";
}

$in = json_encode(array(
    'cmd' => 'executeactions',
    'id' => intval($light),
    'value1' => intval($value)
));

socket_write($socket, $in, strlen($in));
$message = socket_read($socket,1000000);
socket_close($socket);

return $message;
});

Then I've build a little interface to easily turn on/off the lights:

Arduimotic Home Control

Next steps

  • a custom 'presence simulation'.
  • add some more 'house data' with the help of Arduino (waterlevel status, weather station, ...)
  • ...

Again, thanks @wouter for the provided information!

Think Graphical
  • 163
  • 1
  • 8
2

I dont know if this still applies or if U found the solution for the Niko Home Control yet, i managed to control en get feedback from Niko Home control through an external application

an example of a Niko tcp command : {"cmd":"executeactions","id":0,"value1":100} this gives an id (for niko this is an action programmed in the controller, in my case a lightcircuit at my frontdoor) a value where 0 is off and 100 is on, feedback from the niko controller gives {"event":"listactions","data":[{"id":0,"value1":100}]} those commands can be tested by using a simple packetsender tot the ip of the niko controller on port 8000.

wouter
  • 36
  • 3
  • Niko network commands are tcp strings containing a datafield where every circuit or action programmed in the Niko controller has an id with a value, those tcp commands can be read by using Wireshark, the easiest part to do that is by running the original Niko application on an android emulator on the wired desktop becaus this way its much easier to run wireshark at the same time with a filter on the IP of the desktop, when u follow the tcp stream in wireshark u get a nice view of commands and feedback from the Niko controller – wouter Feb 21 '15 at 21:35
  • Thanks @wouter Yes, this still applies. My Niko home control system is installed in the house. And I will be moving within a month. Then I'll have the time to try this out. Thanks for sharing this info! – Think Graphical Feb 23 '15 at 20:00
  • I have tried these commands and can confirm that these work! It takes some time to figure out the addresses but once you found them it's easy to develop an application to control your Niko home control from outside your house. :) –  Feb 23 '15 at 21:07
  • there's only one tricky part i encountered so far, in order to be able to get feedback from the niko HC u have to send a list of commands to the niko at startup of your own application in order to get the rights to receive feedback. if not, the only feedback u get is an error feedback. U can check this again by monitoring through wireshark at startup of the original application – wouter Feb 24 '15 at 07:04
  • to avoid the time to find out what id is connected to a specific action, once u have connection and u receive feedback u can use the command {"cmd":"listactions"} feedback to this command gives u full list as feedback with extra data field the name programmed in the Niko controller. feedback example : {"cmd":"listactions","data":[ {"id":0,"name":"licht inkom","type":1,"location":1,"value1":0},{"id":1,"name":"licht toilet beneden","type":1,"location":1,"value1":0},{"id":2,"name":"licht bureau","type":1,"location":2,"value1":0},{"id":4,"name":"ALL OFF","type":1,"location":8,"value1":0}]} – wouter Feb 24 '15 at 19:36
  • Did you find some commands to retreive other information ? Like virtual variable status for example ? That would give much more perspective to interact with home control and be able to automate stuff more easily than the niko home control programmer. For example, maybe we could allow a feature: switches with 'simple click' and 'long click'; which is disabled by the manufacturer.. – Xavier Aug 23 '15 at 21:43
  • 1
    @XSA No, I did not. But that would be very interesting, indeed! I'll try to look into that. If you find something, please share! – Think Graphical Aug 24 '15 at 12:34
  • @ThinkGraphical I started playing with Niko HC yesterday, but i'm thinking about a way to retreive all available commands. I've been using the "Niko user settings" on Windows with wireshark; but i know that the HC can send message/notification to the LCD screens (which i do not have). I think this is possible with Android App also, and i'll test with Android emulator + wireshark. – Xavier Aug 24 '15 at 13:57