Page 1 of 4

Moving to OpenHAB to get Google Home support for free?

Posted: Sunday 21 October 2018 12:10
by Ankan
My Domoticz installation running great but I would like to get Google Home support without paying for that service like with Controlicz and also without exposing my installation to internet.
I have tried to use IFTTT but it doesn't have support for the Swedish language which I prefer.

It looks like OpenHAB would give me that Google Home support for free with myopenhab.org but can I do all the things I do with Domoticz on OpenHAB?
Now I have a RFLink connected to my server to control all my 433 Mhz devicez like lamps, temperature sensors and so on. I have integrated Life 360, Gigaset Elements and some network cameras. I have also some simple Blocky scripts.

I was also looking at Home Assistant but it looks like I only get Google Home support by using Home Assistant Cloud service which cost $5/month.

Best of all would be if there where support for Google Home in Domoticz by adding support to mydomoticz.org but I guess we are not there get?

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Tuesday 23 October 2018 16:59
by hoeby

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Tuesday 23 October 2018 17:31
by emme
Ankan wrote: Sunday 21 October 2018 12:10 I would like to get Google Home support without paying for that service like with Controlicz and also without exposing my installation to internet.
with ANY external/cloud service, you actually DO THAT

Voice systems are NOT processed locally by the device, but on the service provider backend, for which the home device act as a proxy.

This means that ANY command you teach to the voice system, linked to a local server IP, with a user and a password, where linking to a specific ID and an action, are moved to the cloud and turns back to the device.

Well, there is an implicit privacy statement by which the service providers say ( :roll: ) they cannot/won't use them.... but you actually expose your configuration to external players.... probably in a worst way than expose a port to the internet

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Tuesday 23 October 2018 17:40
by emme
btw... not sure for Google, but for Alexa it seems it does exist a local way to do not use the cloud

https://www.npmjs.com/package/node-red- ... lexa-local

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Tuesday 23 October 2018 18:41
by Ankan
emme wrote: Tuesday 23 October 2018 17:40 btw... not sure for Google, but for Alexa it seems it does exist a local way to do not use the cloud

https://www.npmjs.com/package/node-red- ... lexa-local
There was a local way but they removed it sadly.

I guess you have to expose your devices in one way or another if you want to use Google Home. I would prefer not to, but it's very nice to be able to control lights and get device info by voice.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Tuesday 23 October 2018 18:55
by Ankan
hoeby wrote: Tuesday 23 October 2018 16:59 See this thread
http://www.domoticz.com/forum/viewtopic ... 69&t=25344
I prefer to use my Google Home as I already have one and I guess it's much better to ignore noise and only pickup voice. Thanks anyway, I read that thread before I started mine.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Tuesday 23 October 2018 18:59
by Ankan
I can get voice control working on Domoticz via IFTTT and Pushbullet where I parse spoken words on my server, but I can't give any feedback on my Google Home which is little pity.

With OpenHAB I guess the control would be better as myopenhab plugin is already added to Google Assistant as a smart home device/gateway.

I got an idea, and maybe someone here knows if it's possible and how to set it up.
Can I get my Domoticz to sync all my devices to a local MQTT gateway and then let a local OpenHAB server sync with same MQTT server?
In that case I can sync my OpenHAB with myopenhab.org and setup Google Assistant to access myopenhab.

But in the end, best of all would be if Google Home had a local API where you can get spoken words i clear text and you can do whatever you want with it.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Tuesday 23 October 2018 20:20
by hoeby
Ankan wrote: Tuesday 23 October 2018 18:55 I prefer to use my Google Home as I already have one and I guess it's much better to ignore noise and only pickup voice.
This i don't understand :?:
You want something that doesn't send your installation over the internet.
But you already have a google home. Like Emme said, google home send info over the internet. Your google home already does that, what is the difference your are looking for?

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Tuesday 23 October 2018 20:51
by Ankan
I want to control my devices with my Google home like domoticz connected to controlicz but for free.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Thursday 29 November 2018 4:02
by Bradds
For all those interested, there is a way to get your devices from domoticz on the google home app (and alexa) for free using openhab without moving away from domoticz - all on the same pi - warning, takes a lot of time but works just fine.

Simplified below but you may need to do some reading in the openhab docs if you are not familiar on how it works.

1. Install openhabian image https://github.com/openhab/openhabian/releases

2. Once openhab is setup, install openHAB Cloud Connector and set that up. - under add-ons>misc

3. Install domoticz as usual on the same pi with all your devices/hardware but --MAKE SURE YOU CHANGE THE DOM PORT ie 9090-- openhab port change can be problematic.

4. Install ha-bridge and retrieve your selected devices from domoticz - make sure you edit the config to reflect the /home/opendabian instead of /home/pi directory in the configs.

5. Install the hue binding on openhab and add as a thing and scan, all your devices now show up in openhab - add them as items from the things

6. Install and use REST API to add "tags" to your items or they will not show up in the google home app https://github.com/openhab/openhab-google-assistant - alternatively you can create your own domoticz.items file and code the items in yourself and add tags there. The thermostat works great as well if you MQTT the temp sensor from dom to openhab, or even use node-red. You will need to install the homekit binding for this and make sure you change the "mode" item as a string instead of a number or else you will not be able to change the thermostat settings.

7. Link openhab service to your Google home app and then ask google to "sync my devices" they will all pop up and you will be good to go.

I have this setup working great on a pi 2 and have encountered no problems at all, plus you get the added benefit of the best of both worlds, openhab and dom. PLUS you do not have to manually open any ports on your router for this to work.


Enjoy.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Thursday 29 November 2018 5:18
by Ittiz
get mycroft (works on any linux system), as far as I'm aware locally processed. Also there is a skill for domoticz that I've been helping with. It's been working great for me.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Thursday 29 November 2018 21:38
by Ankan
Bradds wrote: Thursday 29 November 2018 4:02 For all those interested, there is a way to get your devices from domoticz on the google home app (and alexa) for free using openhab without moving away from domoticz - all on the same pi - warning, takes a lot of time but works just fine.

Simplified below but you may need to do some reading in the openhab docs if you are not familiar on how it works.

1. Install openhabian image https://github.com/openhab/openhabian/releases

2. Once openhab is setup, install openHAB Cloud Connector and set that up. - under add-ons>misc

3. Install domoticz as usual on the same pi with all your devices/hardware but --MAKE SURE YOU CHANGE THE DOM PORT ie 9090-- openhab port change can be problematic.

4. Install ha-bridge and retrieve your selected devices from domoticz - make sure you edit the config to reflect the /home/opendabian instead of /home/pi directory in the configs.

5. Install the hue binding on openhab and add as a thing and scan, all your devices now show up in openhab - add them as items from the things

6. Install and use REST API to add "tags" to your items or they will not show up in the google home app https://github.com/openhab/openhab-google-assistant - alternatively you can create your own domoticz.items file and code the items in yourself and add tags there. The thermostat works great as well if you MQTT the temp sensor from dom to openhab, or even use node-red. You will need to install the homekit binding for this and make sure you change the "mode" item as a string instead of a number or else you will not be able to change the thermostat settings.

7. Link openhab service to your Google home app and then ask google to "sync my devices" they will all pop up and you will be good to go.

I have this setup working great on a pi 2 and have encountered no problems at all, plus you get the added benefit of the best of both worlds, openhab and dom. PLUS you do not have to manually open any ports on your router for this to work.


Enjoy.
Would it be possible to test this setup with my domoticz setup by installing openhab on a new RPi and let it talk to my domoticz RPi via ha-bridge? Maybe it's even possible to test the setup by installing openhab on a windows laptop and let it talk to my domoticz server?

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Friday 30 November 2018 17:54
by Bradds
Yes, it will work fine on a separate Pi's, (DOM on one and OH on the other) that is how I has it setup at first for testing. No reason to think it will not work on windows or any other device on your network running OH.
If you don't 'have an alexa, you can forego the ha-bridge link and MQTT from DOM<>OH but this will require some additional coding skills.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Friday 30 November 2018 21:23
by Ankan
Bradds wrote: Friday 30 November 2018 17:54 Yes, it will work fine on a separate Pi's, (DOM on one and OH on the other) that is how I has it setup at first for testing. No reason to think it will not work on windows or any other device on your network running OH.
If you don't 'have an alexa, you can forego the ha-bridge link and MQTT from DOM<>OH but this will require some additional coding skills.
I don't have Alexa. Do you mean that the ha-bridge solution won't work for me? As I understand the ha-bridge is only a solution to get domoticz and openhab to sync with each other. The connection to Google home is done by openhab.
In that case I guess it doesn't matter how openhab and domoticz sync.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Friday 30 November 2018 22:57
by Bradds
The ha-bridge works fine with or without an alexa, it is just the way I did it because I have both. It is probably easier to setup and use than MQTT in this situation, upto you which you use.
I suggested ha-bridge because it is easy to link to DOM devices and OH can scan Ha-bridge and import all those devices as things with a hue bindings scan.
If you used MQTT you would have to setup bi-directional comms for each switch/sensor and would probably take a lot longer to implement. I have done this for non switchable sensors, ie, temp hum etc. But as GH cannot port these to the app anyway there is really no point, just leave them on domoticz and use it as the main controller.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Monday 03 December 2018 18:40
by EdddieN
My two cents here.

I use HA bridge, the new / latest Alexas (3rd gen and so) do not work with it so what I do is use a 1st gen echo dot in the house and suddenly the rest of the Echos see the devices.

I cannot read values, only switch ON and OFF but that is plenty for me.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Monday 03 December 2018 19:50
by Ankan
Bradds wrote: Friday 30 November 2018 22:57 The ha-bridge works fine with or without an alexa, it is just the way I did it because I have both. It is probably easier to setup and use than MQTT in this situation, upto you which you use.
I suggested ha-bridge because it is easy to link to DOM devices and OH can scan Ha-bridge and import all those devices as things with a hue bindings scan.
If you used MQTT you would have to setup bi-directional comms for each switch/sensor and would probably take a lot longer to implement. I have done this for non switchable sensors, ie, temp hum etc. But as GH cannot port these to the app anyway there is really no point, just leave them on domoticz and use it as the main controller.
I have start setting up a Mqtt connection. I installed mosquito on my RPi running Domoticz and running openhab on my windows laptop.
Openhab is trickier to setup but I got switch status and temp sensors to openhab. Next step is to do the reverse, send state to domoticz from openhab.
I will document it all here, as I guess Iam not alone to do this.

Remind me if I forget. 🙄

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Monday 03 December 2018 22:00
by renerene
Yes, you are not alone ;-)

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Monday 03 December 2018 23:19
by Bradds
If you are doing bi-comms in MQTT look out for infinate loops.
I use node red as the go-between and it is easy to limit the amount of messages going either way.
If you manage to get round this in the OH MQTT code, please share.

Re: Moving to OpenHAB to get Google Home support for free?

Posted: Thursday 06 December 2018 22:21
by Ankan
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);