Entering the domotic game

Wednesday, March 15, 2017

kalliopehome-automationdomoticz

Introduction

So far, most of the things I do with Kalliope could be considered as not really domitic (maybe more domogeek ^^).

Indeed, so far I use Kalliope to:

The last 2 items could be considered as domotic, but I consider them as media management, but the line is grey :)

Domotic

what for?

Usage are legions and I don’t intend to describe all of them here, just the one I’m going to use. Bear in mind than I’m just starting so my knowledge is limited and the devices I have are not numerous :).

I have several ideas to start with, like managing internal sensors (temp, light, motion detector, …) or managing switches (Lamp, electric plug, …)

How:

The protocol: Z-wave

But first, I needed to find the basic of all this: How to manage these devices from a central control point. I read online some documentation, about protocol and devices and finally end up choosing device compatible with the z-wave protocol, as there is the openzwave opensource lib that seems to work well. Main issue of Z-wave is that the company behind it are owner of the z-wave chip.

I let you read online additional info on z-wave if you wish, there are a lot about it.

The main controller: Domoticz

So I ended up buying a usb stick z-wave controller and a z-wave multi sensor (temp/hum, light, motion detection) to start poking at it. But I still needed an app to manage all the z-wave devices.

For this, 2 solutions:

  • Create a neuron that leverage the openzwave python library
  • Use a tool that manage domotic devices

I think that the simplest, yet most powerful approach was to choose the 2nd option, and choose a software that was exactly meant to manage domotic device. I could have choose several: jeedom, openhab, <Home-Assistant.io>, …

I ended up choosing Domoticz, very light and powerful app in C++ with a web app and a mobile app. It was very easy to install on an old rpiB+ and to setup my z-wave sensor.

It also provide APIs to do a lot of actions so that kalliope could send action :)

APIs provide options to (non exhaustive, go to their doc page for full API endpoints):

  • Get device status (and value): Important for me to get metric from sensor
  • Set on/off on device: I’ll soon have a zwave electrig plug, and I want to be able to switch it on and off via kalliope
  • Get / Set scene/groups state: Scene and groups are option in domoticz to regroup devices together (group mean all device has same state (on or off) and group state can be change. Scene has only one state, but devices can have different states).

That’s the main I’ll start poking at, in that order!

Kalliope integration

  • Pymoticz

    I did find online an old python code to manage domoticz. I also found a more recent fork of it here that worked well.

    Only issue is that is was forcing the use of http and didn’t allow https. So I forked it to add https support. There is pull request here to merge it.

  • Kalliope Neuron

    As you would have guess, a neuron is coming up. You can find it in a draft mode on github. For now, it is very limited but in development. It does include directly the pymoticz library so no manual addition needed there.

    For now, you can only request data value from a device. So for example, I can retrieve the temperature and the light level from the sensor.

    Brain example

          ---
            - name: "domoticz-get-temp-living-room"
              signals:
                - order: "living room temperature"
              neurons:
                - domoticz:
                    host: "{{domoticz_host}}"
                    action: "get_device"
                    device: "6"
                    ssl_verify: "False"
                    say_template: "Living temperature is {{devices[0]['Temp'] | safe}} degrees and humidity is {{devices[0]['Humidity'] | safe}} %"
            - name: "domoticz-get-lux-living-room"
              signals:
                - order: "brightness in living room"
              neurons:
                - domoticz:
                    host: "{{domoticz_host}}"
                    action: "get_device"
                    device: "5"
                    ssl_verify: "False"
                    say_template: "Living room brightness is {{devices[0]['Data'] | safe}}"
    

What’s next

As I said above, there are a lot to be able to do: set on/off devices, get / set scenes and groups, … A lot of fun to have marrying Kalliopé and domoticz :)

Stay tuned!


Contact

If you find any issue or have any question about this article, feel free to reach out to me via email, mastodon, matrix or even IRC, see the About Me page for details.

See Also

Managing a shopping list with Kalliope

Update linux clock when travelling