Add Integration for Niko Home Control 2

Hi,

I would like to use HA with my Niko Home Control installation, it uses the TCP protocol.
I have found this Python library, so it looks like its possible to integrate it.
https://github.com/NoUseFreak/niko-home-control

Anyone else needed this integration?

Thanks!

Hi Sen,

NoUseFreak (who wrote the Python library you mention) seems to have added Niko HC platform support and did a pull request to have it merged into Home Assistant. There is some discussion to improve error handling and to add documentation. Thatā€™s just from April ago, so letā€™s hope it makes it into HA sooner or later.

Alternatively, OpenHAB2 supports Niko HC already and it works great! If you love HA and wouldnā€™t switch to something else (count me in), you could bridge HA and the Niko HC components on OH together using MQTT. It should work, but direct support in HA would be even better of course.

Niko HC is the only (but an important) part of my HA setup missing, Iā€™m gonna give the HA-MQTT-bridge-OH-NikoHC a try soon, unless that pull request is in the pipeline.

Regards,
Hannes

Hi,

I know OpenHAB2 support NHC, but its NHC 1 and I have an installation at home with HNC 2. So it doesnā€™t work for me.
I have had another look at the code of NoUseFreak and it looks like itā€™s also for NHC 1ā€¦
The biggest reason I wanted to integrate NHC into HA is for the use of google assistant. I have read on Tweakers.net that Niko is currently trying to integrate NHC 2 with Google assistant. https://gathering.tweakers.net/forum/list_messages/1800723

Regards,
Sen

For those stumbling on this thread looking for a way to integrate Niko Home Control 1: hereā€™s how I got it working :slight_smile:

Iā€™m running this for several months now, and itā€™s surprisingly stable and responsive, despite of the extra layer required due to lack of direct support for Niko HC 1.

  • Needed a little help of OpenHAB, which I run on another Pi, solely to be able to interface with Niko HC (imho this could theoretically run on the same Pi as well, but mine was overloaded already so I went for the safer / easier way of a seperate Pi). OpenHAB has Niko HC 1 integration and is fairly easy to setup. Next you need OpenHAB to publish state information and listen for commands using MQTT. I use the Hass.io MQTT addon and let OpenHAB use this as the MQTT broker. The idea for this setup comes from this thread: Home Assistant - MQTT - openHAB: Switch example, where you can find details on how to setup the OpenHAB MQTT part.
  • Next you need the MQTT broker setup in HA: https://www.home-assistant.io/components/mqtt.
  • Finally you need MQTT lights and switches configured in HA. Hereā€™s config for this (as a package). This was fairly straight forward, except for dimmable lights, as for those OpenHAB does not put any on/off state on the MQTT eventstream, only the brightness level. So I needed to derive the state from the brightness level (if brightness = 0 then state = OFF, else state = ON). This is done using state_value_template for those dimmable lights.
################################################################
## Packages / Niko I via OpenHAB MQTT
################################################################

################################################
## CUSTOMIZE
################################################

homeassistant:
  customize:

    ################################################
    ## Node Anchors
    ################################################

    package.node_anchors:
      customize:                     &customize
        package:                     'niko_mqtt'

      spot_niko:                     &spot_niko
        <<:                          *customize
        icon:                        mdi:spotlight

      dim_niko:                      &dim_niko
        <<:                          *customize

      plug_niko:                     &plug_niko
        <<:                          *customize
        icon:                        mdi:power-socket-eu

      scene_niko:                    &scene_niko
        <<:                          *customize
        icon:                        mdi:movie

    ################################################
    ## Lights
    ################################################

    light.bunker_niko_ceiling:
      <<:                            *spot_niko
      friendly_name:                 "Bunker spots"

    light.bath_niko_ceiling_shower:
      <<:                            *dim_niko
      friendly_name:                 "Shower dimmable spots"

    ################################################
    ## Switches
    ################################################

    switch.living_niko_wallplug_r:
      <<:                            *plug_niko
      friendly_name:                 "Wall plugs right"

    switch.scene_niko_bedtime:
      <<:                            *scene_niko
      friendly_name:                 "Bedtime scene"


################################################
## Lights
################################################

light:

    ## Dimmable light
  - platform:                        mqtt
    name:                            bath_niko_ceiling_shower
    state_topic:                     "openHAB/out/nikohomecontrol_dimmer_440e003a291e_54_brightness/state"
    command_topic:                   "openHAB/in/nikohomecontrol_dimmer_440e003a291e_54_brightness/command"
    on_command_type:                 brightness
    state_value_template:            >
      {% if value|int > 0 %}1{% else %}0{% endif %}
    payload_on:                      "1"
    payload_off:                     "0"
    brightness_state_topic:          "openHAB/out/nikohomecontrol_dimmer_440e003a291e_54_brightness/state"
    brightness_command_topic:        "openHAB/in/nikohomecontrol_dimmer_440e003a291e_54_brightness/command"
    brightness_scale:                100
    qos:                             1
    retain:                          true
    optimistic:                      false

    ## Non-dimmable light
  - platform:                        mqtt
    name:                            bunker_niko_ceiling
    state_topic:                     "openHAB/out/nikohomecontrol_onOff_440e003a291e_63_switch/state"
    command_topic:                   "openHAB/in/nikohomecontrol_onOff_440e003a291e_63_switch/command"
    qos:                             1
    payload_on:                      "ON"
    payload_off:                     "OFF"
    retain:                          true
    optimistic:                      false

################################################
## Switches
################################################

switch:

    ## Wall plug
  - platform:                        mqtt
    name:                            living_niko_wallplug_r
    state_topic:                     "openHAB/out/nikohomecontrol_onOff_440e003a291e_60_switch/state"
    command_topic:                   "openHAB/in/nikohomecontrol_onOff_440e003a291e_60_switch/command"
    qos:                             1
    payload_on:                      "ON"
    payload_off:                     "OFF"
    retain:                          true
    optimistic:                      false

    ## Scene
  - platform:                        mqtt
    name:                            scene_niko_bedtime
    state_topic:                     "openHAB/out/nikohomecontrol_onOff_440e003a291e_69_switch/state"
    command_topic:                   "openHAB/in/nikohomecontrol_onOff_440e003a291e_69_switch/command"
    qos:                             1
    payload_on:                      "ON"
    payload_off:                     "OFF"
    retain:                          true
    optimistic:                      false

I see that some people have found a solution for communication between NHC2 and OpenHAB:

Maybe this can be helpfull to implement this in Home Assistant

1 Like

Iā€™ve started work on a Custom Integration of NHC2 into hass.
It will take some time to get to the levels we all want it to be.
But Iā€™m searching for volunteers to help me get this done.
Level of expertise does not matter, only not giving up.
Please send me a PM with your name, native language and scope of your project.
Also what you can doā€¦ from simple testing the integration to co-authoring (code and/or docs)

will it also work on NHC1 ?
because current platform now official in HA doesnt work

I do not know howe NHC1 works, from what I understand it works different.
You can upgrade your NHC1 -> NHC2 but itā€™ll cost you and not all old devices are compatible.
Since I donā€™t have a NHC1 controller, and not a lot of time, I probably canā€™t help you :frowning_face:

You can follow my efforts on

@sen & @dstammen - working on NHC2 - willing to help me test/improve ? :slight_smile:

I donā€™t think I will use HA for my NHC2 installation. Niko is adding default google assistant integration (he only reason I wanted to use HA) and itā€™s scheduled to release this summer. I will wait and see if it meets all my needs. If not I might come back to HA.
Good luck with the development.

i know someone with NHC1 , he is on vacation now for 3 weeks, afterwards he will do upgrade to 2 to test

I your only intent is a google home integration, that probably would be the best.
The reason Iā€™m not waiting for that is, not only do I have that today, but more control, automatisation andā€¦ integrationā€¦ like, for example, soft-linking NHC2 ā€˜buttonsā€™ to IKEA smart lights/gateway (or any other smart lights). The socket always gets power (some nhc2 logic/conf) and the button actually toggles lamp through software.

seems like a expensive operation
https://www.niko.eu/enus/help-and-advice/faq/niko-home-control-ii/kan-ik-een-bestaande-niko-home-control-installatie-upgraden

No first generation touchscreens are supported on NHC2. And replacing the controller is about ā‚¬600
While, there seems to be someone who has a custom implementation of NHC1, as you can see on post nr 2 on this thread.

I would hope there are other reasons than HA integration to do the upgrade?

That seems like a nice integration. I didnā€™t know it was possible to link a IKEA smart light to a NHC2 light switch.
Maybe Iā€™ll take a look at HA. But Iā€™m completely new to HA, so it will take some time to get startedā€¦

Everything is possible once itā€™s available in HA!

Also integration in google will be much better, you can have control on your names and rooms much easier

There is no real one way to do this. But i did the following:
First I configured a ā€˜lampā€™ to aways turn on in NHC2.
29
The two conditionals: if virtuals output is true, turn on the light, if is falseā€¦ turn on the light.
Now the light is ā€œalways onā€.
In HA we ā€œseeā€ the ā€œBasic Actionā€ between the Virtual Output and the switch.
Using some config, (a group, automation, and hiding some entities,ā€¦) I made the IKEA Light(s) (through the hub they sell) follow the state of that switch.
If you use switches without LED, i would do it a bit different, use the button like a toggle signal to HA.

In theory you can link anything together. In our bathroom, we have a dumb LED bulb, controlled by NHC2. But we have a IKEA Tradfri Control outlet (203.644.76) that cuts power to the electric heater when the light is off.

yes, doing this kinde stiuff too
i have this dumb ikea smart remote controller, normally used for dimmer in the closet
in my case i use it to turn on my denon receiver/internet radio volume up/down and favorite stations :slight_smile:
https://www.ikea.com/be/nl/images/products/trƄdfri-afstandsbediening__0609380_pe684491_s4.jpg

As far as I know, you actually need a lamp for that?