Page 2 of 4
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Saturday 08 December 2018 0:48
by Bradds
Nice work Ankan.
Works great, no need for ha-bridge anymore, just link openhab skill and get all the switches, lights & thermostats working on alexa as well as GH.
Had to do some tweaking on some rules for the dimmer lights and blinds, but all good.
Thanks for sharing.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Saturday 08 December 2018 1:05
by Ankan
I'am glad it helped you.
Please share your tweaks if it's something that would make it even better.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Saturday 08 December 2018 1:24
by Bradds
I have some of my dimmers in different groups (gDimmers1) ect.. as they require calcs to output correctly.
For instance when my LWRF dimmer is at 30% on GH dial, it is at 100% brightness in dom. so just convert the string into a DecimalType and divide by 3.
Code: Select all
rule "Send MQTT message on Dimmer command"
when
Member of gDimmer received command
then
var idxStartPos = triggeringItem.name.indexOf("idx") + 3
var idxStopPos = triggeringItem.name.length()
var adjust = triggeringItem.state as DecimalType
var adjusted = adjust / 3
var myString = ""
{
myString = '{\"command\": \"switchlight\", \"idx\": ' + triggeringItem.name.substring(idxStartPos,idxStopPos) + ', \"switchcmd\": \"Set Level\", \"level\": ' + adjusted + '}'
}
publish("mosquitto", "domoticz/in", myString)
end
Simple but effective.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Tuesday 11 December 2018 8:10
by ressof
Ankan wrote: ↑Thursday 06 December 2018 22:21
Okey, it's up and running. Let's see if it's possible to make it even better.
* Had Domoticz running on RPi at port 8080 (and 443)
1. Installed Mosquitto and configured Domoticz to connect to it
2. Installed zulu java for embedded as it wasn't installed in the Domoticz image
3. Installed OpenHAB and change port to 8081. After installation I had to wait 10-15 minutes before it was up and running and listening at port.
4. Installed following OpenHAB addons:
- MQTT binding
- MQTT Actions
- JSONPath, Map, Javascript and RegEx Transformation
- openHAB Cloud Connector
5. Configure MQTT binding
6. Configured rules, items and javascript as below
7. Configured openHAB Cloud Connector
8. Now, I can control my domoticz devices with my Google Home and ask for temperature. If I want I can use the openHAB webinterface as they sync with each other. I can do stuff via myopenHAB if I want to. And everything without open any ports in my firewall.
I will only add domoticz items in openHAB that I think is secure to let Google Home to have control over.
So this is how I solved it and it works for me. I would prefer to not enter idx number two times on same row in items-file, but I couldn't solve it any other way.
Items:
Code: Select all
Switch idx123 "Outdoorlamp" (gLight) [ "Lighting" ] {mqtt="<[mqttBroker:domoticz/out:state:JS(get_state.js):(?s).*idx\".?.?.?123,.*]"}
Number Outdoor_Temperature "Temperature [%.1f]" <temperature> ["CurrentTemperature"] {mqtt="<[mqttBroker:domoticz/out:state:JSONPATH($.svalue1):(?s).*idx\".?.?.?124,.*]"}
123 and 124 is device idx in Domoticz. mqttBroker is what I configured the mqtt-connection to be called in mqtt binding.
Rules:
Code: Select all
rule "Send MQTT message on Light command"
when
Member of gLight received command
then
var idxStartPos = triggeringItem.name.indexOf("idx") + 3
var idxStopPos = triggeringItem.name.length()
var myString = ""
if (triggeringItem.state.toString() == "ON" || triggeringItem.state.toString() == "OFF")
{
var cmd = triggeringItem.state.toString().toLowerCase.toFirstUpper()
// {"command": "switchlight", "idx": 2450, "switchcmd": "On" }
myString = '{\"command\": \"switchlight\", \"idx\": ' + triggeringItem.name.substring(idxStartPos,idxStopPos) + ', \"switchcmd\": \"' + cmd + '\"}'
}
else
{
// {"command": "switchlight", "idx": 2450, "switchcmd": "Set Level", "level": 100 }
myString = '{\"command\": \"switchlight\", \"idx\": ' + triggeringItem.name.substring(idxStartPos,idxStopPos) + ', \"switchcmd\": \"Set Level\", \"level\": ' + triggeringItem.state.toString() + '}'
}
publish("mqttBroker", "domoticz/in", myString)
end
get_state.js
Code: Select all
(function(i){
var parsed = JSON.parse(i);
if (parsed.nvalue == 0)
{
return "OFF"
}
else if (parsed.nvalue == 1)
{
return "ON"
}
else if (parsed.nvalue == 2)
{
return parsed.svalue1
}
})(input);
This seem to be a great way to use Google Home on domoticz.
But I'm not so familiar with OpenHab.
Do you think you can explain a bit more detailed how to setup OpenHab from scratch?
I have managed to install OpenHab docker image and installed the addons but then I'm lost:)
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Tuesday 11 December 2018 9:18
by Ankan
I guess best and easiest way would be to use the openHABian image on your raspberry and install Domoticz on that.
I used the Domoticz RPi image and installed OpenHAB by this guide:
https://www.openhab.org/docs/installation/linux.html
but it's not that easy.
If you want to run OpenHAB on Windows computer, you just download binary and run start.bat. Thats all. Then it's up and running at port 8080 by default.
I haven't used docker image so I can't help you there. Maybe I should have started there, but I didn't.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Tuesday 11 December 2018 9:46
by ressof
Where do I put get_state.js?
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Tuesday 11 December 2018 10:00
by Ankan
In the Transformation folder.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Tuesday 11 December 2018 13:05
by ressof
I cant get the MQTT to work.
I have install MQTT binding & actions
I have updated mqtt.conf with my mosquitto server ip.
Is there anything else I have to configure to get MQTT to work?
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Tuesday 11 December 2018 14:34
by Ankan
Use MQTT.fx to check if MQTT server is up and running correct and se if you get any messages from Domoticz or OpenHAB.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Tuesday 11 December 2018 22:33
by ressof
The mosquitto server is working with domoticz. But I cant get it to work with OpenHab. OpenHab doesent publish anything when I flip a switch.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Wednesday 12 December 2018 8:21
by Ankan
Then it's something about the rule. Did you save the rule file in the rules folder with the extension xxxxxx.rules ?
Then check if you used same groupname in extension and on device. In my example gLight.
The rule only works if you use the name format idx123 where 123 is your device idx number in dometicz.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Thursday 13 December 2018 9:56
by ressof
I found the problem. It was a bug in OpenHab. To get MQTT to work I had to uninstall MQTT Action and then install it again.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Thursday 13 December 2018 10:00
by Ankan
Great you found it. So now it's up and running?
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Tuesday 18 December 2018 9:29
by ressof
Yes, it's working now.
Thank you for your help.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Sunday 23 December 2018 18:09
by sincze
This looks promissing, let me check if I can setup the thing on a docker within Synology. tnx for sharing.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Sunday 23 December 2018 19:54
by Ankan
I have noticed that openhab 2.4 have a new mqtt binding that works totally different. Be sure you install the old binding if you want to follow my setup.
https://www.openhab.org/blog/2018-12-16 ... cture.html
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Thursday 03 January 2019 8:51
by Gdroos68
Is Google assistant able to process Dutch commands for openhab?
Verstuurd vanaf mijn ZTE A2017G met Tapatalk
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Thursday 03 January 2019 9:48
by Ankan
Gdroos68 wrote: ↑Thursday 03 January 2019 8:51
Is Google assistant able to process Dutch commands for openhab?
Verstuurd vanaf mijn ZTE A2017G met Tapatalk
As Dutch is supported by Google assistant, I guess it's supported by OpenHAB. I speak Swedish with my Google Home without any problems.
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Thursday 03 January 2019 10:24
by EdwinK
ressof wrote: ↑Tuesday 11 December 2018 8:10
This seem to be a great way to use Google Home on domoticz.
But I'm not so familiar with OpenHab.
Do you think you can explain a bit more detailed how to setup OpenHab from scratch?
I have managed to install OpenHab docker image and installed the addons but then I'm lost:)
I second that
Looking for something like OpenHAB for dummies or something like that
Re: Moving to OpenHAB to get Google Home support for free?
Posted: Thursday 03 January 2019 17:39
by sincze
EdwinK wrote: ↑Thursday 03 January 2019 10:24
ressof wrote: ↑Tuesday 11 December 2018 8:10
This seem to be a great way to use Google Home on domoticz.
But I'm not so familiar with OpenHab.
Do you think you can explain a bit more detailed how to setup OpenHab from scratch?
I have managed to install OpenHab docker image and installed the addons but then I'm lost:)
I second that
Looking for something like OpenHAB for dummies or something like that
+1
Have it installed on the Synology in docker.
But this is a total new world for me.