poniedziałek, 17 lutego 2020

Setup openHAB 2.5 + Mosquitto MQTT + SONOFF ESPurna + Google Home

Since gbridge.io is shutting down i needed to move to different platform.
openHAB cloud started to be stable so it's good time to move my smart home to it.

This is fast tutorial and does not explains everything exactly, serves only to facilitate the work of a person who knows a little about it :)

1. First install Mosquitto server on your raspberry. It's way more stable than openHAB Moquette broker.
sudo apt-get install mosquitto mosquitto-clients
2. Then install newest stable openHAB
wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add -
sudo apt-get install apt-transport-https

echo 'deb https://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list

sudo apt-get update
sudo apt-get install openhab2

sudo systemctl start openhab2.service
sudo systemctl status openhab2.service

sudo systemctl daemon-reload
sudo systemctl enable openhab2.service
3. In openHAB install MQTT Binding addon and openHAB Cloud Connector

4. Create config files for your SONOFF's:
(off course with your mqtt names)

/etc/openhab2/items/default.items
Switch BedTV "Bed TV" { channel="mqtt:topic:BedTV:switch", ga="Outlet"}
Switch BedLight "Bed Light" { channel="mqtt:topic:BedLight:switch", ga="Light"}

/etc/openhab2/sitemap/default.sitemap
sitemap default label="Dom"
{
     Switch item=BedTV label="Bed TV"
     Switch item=BedLight label="Bed Light"
}

/etc/openhab2/things/default.things
Bridge mqtt:broker:myUnsecureBroker "Mosquitto MQTT Broker" [ host="localhost", secure=false ]
{
     // Bed TV
     Thing mqtt:topic:BedTV "Bed TV" {
          Channels:
          Type switch : switch "Power Switch" [
          stateTopic="ESPURNA-Bed-TV/relay/0",
          commandTopic="ESPURNA-Bed-TV/relay/0/set",
          on="1",
          off="0"
          ]
     } 
     // Bed Light
     Thing mqtt:topic:BedLight "Bed Light" {
          Channels:
          Type switch : switch "Power Switch" [
          stateTopic="ESPURNA-Bed-Light/relay/0",
          commandTopic="ESPURNA-Bed-Light/relay/0/set",
          on="1",
          off="0"
          ]     }
}

5. Configure your SONOFF ESPurna to connect to your MQTT Mosquitto server.
(i like ESPurna soft becouse for me it's way more stable that Tasmota)
6. Configure openHAB Cloud Connector
cat /var/lib/openhab2/uuid ; echo
cat /var/lib/openhab2/openhabcloud/secret ; echo

6.1 Create account with this data on https://myopenhab.org/

6.2 Add openHAB on your phone in your google assistant.




Brak komentarzy:

Prześlij komentarz