hardware: add Plejd to hass.io

Plejd Custom Component
Despite hass.io not having an official integration with Plejd I chose Plejd as my main system for controlling lights in my house. Not the obvious choice one could argue but I chose stability and reliability over connectivity at that point.

That limitation did not stop me from trying to integrate Plejd and hass.io though. My first attempt was with the custom integration ha-plejd by klali. Great job by klali and it showed me that integration between the two systems are possible even though ha-plejd had some limitations. I based quite a lot of my home automation functionality on that integration but was never 100% satisfied.

By coincidence I stumbled upon another integration aiming to do the same thing; hassio-plejd by icanos. I decided to give it a try and wow did I get a positive surprise! Some functionality was missing but after I made some requests to the developer they were soon included. Installation of hassio-plejd was really easy and the general stability of the component is impressive.

Figure 1. Plejd is a Swedish company that develop and sell components for home automation.

Install Mosquitto Broker
In addition to the Plejd custom component I found out that I needed an mqtt broker to translate commands between hass.io and Plejd. Before I started with the Plejd installation I therefore installed the official add-on 'Mosquitto broker' that is available through hass.io web interface > hass.io > add-on store > search for mqtt > Mosquitto broker > Install.

Figure 2. To be able to use Plejd in hass.io an mqtt broker needs to be installed.

After the installation I moved on to change to configuration of Mosquitto broker. That is done at the same page as the installation, I scrolled down to the config text input field and pasted the Mosquitto broker Config as below. All I had to change was the username and password entries that can be chosen freely.

Mosquitto broker Config
{
  "logins": [
    {
      "username": "myMosquittoUsername",
      "password": "myMosquittoPassword"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "require_certificate": false
}
I made sure to start Mosquitto broker before leaving the page.

Install Hassio-Plejd
The next step for me was to do the actual installation of the Plejd custom component (hassio-plejd) by following the instructions under 'easy installation'. No need to bother with the manual installation part. After the installation I moved on to change the configuration of hassio-plejd. That is done at the same page as the installation, I scrolled down to the config text input field and pasted the Plejd Config as below.

Plejd Config
{
  "site": "SiteNameAsInThePlejdApp",
  "username": "myPlejdAccount@UserEmail.com",
  "password": "myPlejdAccountPassword",
  "mqttBroker": "mqtt://192.168.1.242",
  "mqttUsername": "myMosquittoUsername",
  "mqttPassword": "myMosquittoPassword",
  "includeRoomsAsLights": true
}
Site, username and password data in the configuration above are the same as I use in my Plejd App while the mqttUsername and mqttPassword are what I set them to during the Mosquitto broker installation. I made sure to start Plejd before leaving the page.

Finally I also updated my configuration.yaml with the below entry.

Configuration.yaml
mqtt:
  broker: 192.168.1.242
  username: myMosquittoUsername
  password: myMosquittoPassword
  discovery: true
  discovery_prefix: homeassistant
  birth_message: 
    topic: 'hass/status'
    payload: 'online'
  will_message: 
    topic: 'hass/status'
    payload: 'offline'
The IP 192.168.1.242 in the above examples should be replaced with the IP address of your Mosquitto broker installation. If you installed Mosquitto broker on your Raspberry Pi the Mosquitto broker IP and Raspberry IP are the same.

Reboot and Test
Then I restarted hass.io and when it came back online I had all my Plejd devices available in hass.io ready to be tested. Make sure both the Plejd and Mosquitto Add-on have been started, I had to do that manually the first time. To confirm that the Plejd devices has been integrated check the states page.

Updating the hassio-Plejd component
Recently there has been a few updates to the hassio-plejd component and it took me some time to realise that the component needs to be rebuilt before working properly. To get the latest version go to Hass.io web interface > left menu > hass.io > Add-on store > Plejd > update > rebuild > Start > reboot.

Figure 3. Rebuild hassio-plejd after update and then start the component.

Recommended: All changes to configuration.yaml should be done with a proper text editor.
Recommended: After changes to configuration a Configuration Validation should be run.
Recommended: Learn how to find the IP of your Raspberry Pi/Hass.io.
Note: The above information has been confirmed to be applicable to both Raspberry Pi 3b+ and 4.
Note: There is no need to set up a specific user in hass.io for mqtt.
Wikipedia: mqtt

Let me know in the comments field if you have any questions or comments.

Comments

  1. Thanks a lot dude. Great reading, this is a very helpful guide!

    ReplyDelete
    Replies
    1. I am happy to hear that you found it useful!

      Delete
  2. Very nice addition, it is a dream come true, to get Plejd to work with above all HomeKit but also hassio. However, it is a little buggy and I get various error messages after a while. Just like there will be some kind of abundance of information for hassio, or Plejd plugin?

    ReplyDelete
    Replies
    1. Yes, the add-on is great but not perfect. If you find issues or have improvement suggestions I urge you to help the community and report them at Github: https://github.com/icanos/hassio-plejd

      Delete
  3. Hi great work , Can someone clever explain to me how mqtt communicates with played devices? Is there some kind of built in mqtt in played gateway?

    ReplyDelete

Post a Comment