Sunday, 13 November 2016

HomeKit for Telldus Live


Do You have Telldus devices up and running and want them to be visible and used in Apples Home app ?

Another thought is that there are not so many native devices available for Apples HomeKit and also why throw away all the devices You have integrated with Your Telldus controller when they can appear in the HomeKit environment ?

If You have Z-wave products there is a parallel solution found in this post.

If You have both Z-wave and Telldus devices at home there is no problem running them at the same time, on the same Raspberry Pi, RPi, and also together with native devices.

Out there on the web there are several smart guys who seems to think the same and are very great in programming. So they have fixed applications running on RPi which emulates a HomeKit device and on the same time bridges the functions to Telldus live registered devices.

And now over to the software and installation which assumes that You have a RPi up and running with Debian or want to start up fresh



The software to be installed is Hombridge, emulating HomeKit, and a Telldus Live plugin. It is also where I picked up the following installing instructions

So log on to the updated RPi and issue the following command to installing some tools

$ sudo apt-get install git make

Then install Node, a JavaScript engine and NPM a package manager.

$ curl deb.nodesource.com/setup_6.x | sudo bash
$ sudo apt-get install nodejs

Check if everything is OK, by showing respective installed version

$ node -v
v6.7.0
$ npm -v
3.10.3

Install Avahi and other dependencies

$ sudo apt-get install libavahi-compat-libdnssd-dev screen

Install Homebridge and other dependencies

$ sudo npm install -g --unsafe-perm homebridge hap-nodejs node-gyp
$ cd /usr/lib/node_modules/homebridge/
$ sudo npm install --unsafe-perm bignum
$ cd /usr/lib/node_modules/hap-nodejs/node_modules/mdns
$ sudo node-gyp BUILDTYPE=Release rebuild
$ cd /

And then Homebridge

$ sudo npm install -g --unsafe-perm homebridge

To check that Homebridge is correct installed, without the Plugin, run the commando

$ homebridge

At the end of the log You will se 

[10/7/2016, 7:13:52 PM] No plugins found. See the README... on installing plugins.
[10/7/2016, 7:13:52 PM] config.json (/home/pi/.homebridge/config.json) not found.
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ 031-45-154 │     
    └────────────┘     
                       

[10/7/2016, 7:13:52 PM] Homebridge is running on port 34442.

At this moment You can start Your HomeKit iOS app and check that Hombridge is discovered. Terminate the process and install the plugin

$ sudo npm install -g homebridge-telldus

Now You have to fetch some keys from Your Telldus live account. These are used for the plugin so the RPi can log on and fetch the device info.

Go to https://api.telldus.com

and then click on "Your keys" then login.
After the login click "Generate a private token for my user only"
Then click "Do You accept? Yes"
The next screen will show 4 rows of i keys and tokens, which will be used in the configuration file for the plugin.

If it is Your first HomeKit plugin copy the config file to the .homebridge/ folder,  edit it so it matches the requirements for the plugin. Something like this,

{                                             
    "bridge": {                               
        "name": "Homebridge",                 
        "username": "CC:22:3D:E3:CE:30",      
        "port": 51826,                        
        "pin": "031-45-154"                   
    },                                        
    "description": "Telldus plugin",          
    "platforms": [                            
      {                                       
       "platform" : "Telldus",                
       "name" : "Telldus Liv!e",              
       "public_key" : "Telldus public key",   
       "private_key" : "Telldus private key", 
       "token" : "Telldus token",             
       "token_secret" : "Telldus token secret"
      }                                       
    ]                                         
}                                             

where You have copied the 4 keys and tokens You got from the Telldus website.

Start hombridge

$ homebridge

and if everything goes right it will show

*** WARNING *** The program 'nodejs' uses the Apple Bonjour compatibility ......
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat......
*** WARNING *** The program 'nodejs' called 'DNSServiceRegister()' whic.....
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat......
[11/11/2016, 11:35:14 PM] Loaded plugin: homebridge-telldus
[11/11/2016, 11:35:14 PM] Registering platform 'homebridge-telldus.Telldus'
[11/11/2016, 11:35:16 PM] ---
[11/11/2016, 11:35:16 PM] Loaded config.json with 0 accessories and 1 platforms.
[11/11/2016, 11:35:16 PM] ---
[11/11/2016, 11:35:16 PM] Loading 1 platforms....
[11/11/2016, 11:35:16 PM] [Telldus Liv!e] Initializing Telldus platform...
[11/11/2016, 11:35:16 PM] [Telldus Liv!e] Loading accessories...
[11/11/2016, 11:35:17 PM] [Telldus Liv!e] Logged in with user: XXXXXXXXX@xxxx.com
[11/11/2016, 11:35:17 PM] [Telldus Liv!e] Found 3 sensors in telldus live.
[11/11/2016, 11:35:17 PM] [Telldus Liv!e] Filtered out 0 sensor due to empty name.
[11/11/2016, 11:35:17 PM] [Telldus Liv!e] Found 5 devices in telldus live.
[11/11/2016, 11:35:18 PM] [Telldus Liv!e] Initializing..accessory 'Framledning 11'...
[11/11/2016, 11:35:18 PM] [Telldus Liv!e] Initializing....accessory 'Köket 61'...
[11/11/2016, 11:35:18 PM] [Telldus Liv!e] Initializing.....accessory 'Ute 183'...
[11/11/2016, 11:35:18 PM] [Telldus Liv!e] Initializing...accessory 'Brasrum B'...
[11/11/2016, 11:35:18 PM] [Telldus Liv!e] Initializing......accessory 'Fläkt C'...
[11/11/2016, 11:35:18 PM] [Telldus Liv!e] Initializing..accessory 'Köket väster'...
[11/11/2016, 11:35:18 PM] [Telldus Liv!e] Initializing....accessory 'Vardagsrum A'...
[11/11/2016, 11:35:18 PM] [Telldus Liv!e] Initializing.. accessory 'Vardagsrum Ö'...
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:
                       
    ┌────────────┐     
    │ 031-45-154 │     
    └────────────┘     
                       

[11/11/2016, 11:35:19 PM] Homebridge is running on port 51826.

You can ignore the warnings in the beginning.
Run Your iOS App and check that Homebridge and the accessories appears.

Then configure autostart at power on with this post or the simple but not so good

$ sudo nano /etc/rc.local

And add this line before the exit 0 line:

su -c "screen -dmS homebridge homebridge" -s /bin/sh pi

Restart the RPi

$ sudo reboot

and now all should be up and running.
If You are adding new devices You have to reboot the RPi for a new initialization.

If You are having Z-Way devices here is a congfig.json for both plugins. Telldus Live and the Z-Wave together.

Instructions updating the installation is found here

Interested in the ultimate Weather WEB-site ? 

32 comments:

  1. Worked great. Thank you!

    I had to manually configure the Nexa switches in config.json to get them to be recognized.

    "unknown_accessories": [
    {
    "id": 12345,
    "model": "selflearning-switch",
    "manufacturer": "Nexa"
    },
    {
    "id": 23456,
    "model": "selflearning-switch",
    "manufacturer": "Nexa"
    },
    {
    "id": 78901,
    "model": "selflearning-switch",
    "manufacturer": "Nexa"
    },
    {
    "id": 234567,
    "model": "selflearning-switch",
    "manufacturer": "Nexa"
    }
    ]

    ReplyDelete
  2. Thank you so much! This is the first, simple, up to date, guide I have found for this. I had my Homebridge up and running but the autostart on boot was new to me. Thanks!

    ReplyDelete
  3. Hi,
    Everything works fine, but i dont get the autostart to work.
    The file looks like this.
    # Print the IP address
    _IP=$(hostname -I) || true
    if [ "$_IP" ]; then
    printf "My IP address is %s\n" "$_IP"
    fi

    su -c "screen -dmS homebridge homebridge" -s /bin/sh pi

    exit 0

    Have any idea about why it dont work?

    ReplyDelete
    Replies
    1. Hi, updated the post with second way to autostart

      Delete
  4. Awesome write-up, so simple to follow, thanks a million!

    Is there any way to expose it to the outside, so that I can use it while away from home?

    God fortsättning!

    ReplyDelete
    Replies
    1. Hi ! Setting up a ATV4 or a iPad as a hub will solve the problem. The first link in this post"Apples HomeKit" will guide You, Mats

      Delete
  5. Thanks for great guidance. I have noticed another way to autostart, that is to use systems. Have you considered it? The advantage of that method is that home bridge would autostart by itself in case of a crash.

    ReplyDelete
  6. sorry, it should be systemd instead of systems above.

    ReplyDelete
    Replies
    1. HI! I'm not that familiar to systemd, but maybe You can add info which I can publish ? Mats

      Delete
  7. Here is a link to a guide to get systemd working:
    https://timleland.com/setup-homebridge-to-start-on-bootup/

    And here is the link to Homebridge github page where they discuss different ways to autostart homebridge on boot.
    https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi

    ReplyDelete
    Replies
    1. New post, systemd and homebridge
      http://pysselilivet.blogspot.com/2017/01/homebridge-autostart-with-systemd.html

      Delete
  8. Om jag redan har en fungerande homekit men vill lägga till telldus hur gör jag då den jag redan har ser ut såhär
    -----------------------------------------

    {
    "bridge": {
    "name": "Homebridge",
    "username": "CC:21:3E:E4:DE:33",
    "port": 51826,
    "pin": "031-45-154"
    },
    "description": "Configuration file for (e)xtended Domoticz platform.",
    "platforms": [
    {
    "platform": "eDomoticz",
    "name": "eDomoticz",
    "server": "127.0.0.1",
    "port": "8080",
    "ssl": 0,
    "roomid": 0,
    "mqttenable": 1,
    "mqttserver": "127.0.0.1",
    "mqttport": "1883",
    "mqttauth": 0,
    "mqttuser": "",
    "mqttpass": ""
    }
    ],
    "accessories": []
    }
    ----------------------------------

    ReplyDelete
  9. Test the config.json file at the link below but change to Your own Telldus Live keys/token. https://gist.github.com/MatsA/59526d2be3ea12bf4d04d6374ec0ed50

    ReplyDelete
  10. Stort tack, detta hjälpte verkligen!
    Dock får jag ingen av mina accessories att initialize utan tvingas sätta samtliga under unknown_accessories. Alla är z-wave, vet du om det ska vara så? Är alla dina 433? Tack på förhand, Johan

    ReplyDelete
  11. OK, thanks. I'm just having 433 devices via TellstickNet HW. Z-wave devices is connected via a Razberry card on the same RPi. Have not done any extra configuration.

    ReplyDelete
  12. Hi! I have followed all the steps but in my Apple Homekit-app onlys the sensors works, all my ON/OFF-connecteros says not supported (Stöds ej), any idea what could be wrong?

    ReplyDelete
    Replies
    1. Hi ! check the log with "less /var/log/syslog" to see if there are any hints, q= quit. Or maybe You have to configure them manually. Check the first comment in this post

      Delete
    2. It works after I configured them manually, thanks for the help and and good guide :)

      Delete
  13. I used this tutorial to make the devices controlled by my Tellstick NET visible in the iOS Home app. No issues with that. Thanks!

    However, I have two "locations" on the same Telldus account, the other one being in a completely different physical place (and different network too, of course).

    Any ideas what would be the best way to get that one into HomeKit too? A second RPi at the other location? Or should I setup a VPN between the two local networks?

    I see all the 2nd location remote switches in HomeKit but they are shown as "Not supported" at the moment.

    ReplyDelete
  14. Hi ! a very god question. I have no distinct answer but the VPN solution seems nice to avoid another RPi. Especially if You also have enabled remote access via an Apple TV or iPad, in this case You should only need one for both places. Would appreciate feedback how You solved it./Mats

    ReplyDelete
    Replies
    1. It seems that since Bonjour is used to advertise the service on the RPi, it's not that easy because Bonjour services aren't visible across a VPN. I'm definitely a newbie on stuff like this, so I may be wrong, but no success so far.

      I now have 1st location with [Tellstick NET, RPi w/homebridge, OpenVPN server], and 2nd location with [OpenVPN client, Tellstick ZNet Lite v1].

      Delete
    2. One way is to create an "Issue" on https://github.com/jchnlemon/homebridge-telldus/issues so smarter guys than me could answer/Mats

      Delete
  15. Great instruction!. Many thanks.
    Works perfect for me (without any previous skills).

    However I can not get my rain sensor (Oregon PCR800) and UV Sensor (UVN800) to work. Is it possible. It says not supported (stöds ej). However they work with tells and are supported on the tells live-homepage and app.

    Any suggestions to fix it?

    Many thanks!

    ReplyDelete
  16. Hi and thanks !
    Check the log when Homebridge is starting up and then manually configure, as done in the first comment in this post. That should help. /Mats

    ReplyDelete
    Replies
    1. Hi,

      Thank you for your quick answer. I am a complete rookie on this.

      Tried to paste this at the end of the config.json file



      {
      "bridge": {
      "name": "Homebridge",
      "username": "CC:22:3D:E3:CE:30",
      "port": 51826,
      "pin": "031-45-154"
      },
      "description": "Telldus plugin",
      "platforms": [
      {
      "platform" : "Telldus",
      "name" : "Telldus Liv!e",
      "public_key" : "Telldus public key",
      "private_key" : "Telldus private key",
      "token" : "Telldus token",
      "token_secret" : "Telldus token secret"
      }
      ]
      }


      "unknown_accessories": [
      {
      "id": 12345,
      "model": "rain",
      "manufacturer": "Oregon"
      }
      ]


      Should I place elsewhere? Within some other parenthesis?

      Should I specify more? How?

      Is the rain sensor implemented in the tells plugin? Do it have to be that for it to work?

      Best regards,

      Delete
    2. I also tried to place it just before the last parenthesis } (so the file ends with } but that did not help.

      Delete
  17. This comment has been removed by the author.

    ReplyDelete
  18. PS. Of course I changed the id 12345 to the correct id.
    Maybe model should state something different?

    ReplyDelete
  19. Sorry, on Holiday, so can’t help You in another 10 days ....

    ReplyDelete