openHAB Google Assistant Integration v2.0

For the Speaker, there isn’t on/off traits with it ? only volume traits ? thx :slight_smile:

Currently, there is only the volume trait. Since there is no documentation about this device type, I can not tell what the “right” implementation would be.

Great job guys. Very nice improvement.

Works well - apart from two minor issues: When the volume is at (OH specific) maximum level (100%) and I try to increase it by 10% GA sends the new value for the item (110) to the REST API - which results in a warning:

2020-01-17 18:48:03.050 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/kodiLivingRoomVolume' with an invalid status value '110'.

Same thing happens when the volume is 0% and one tries to decrease it. I guess we should check the threshold value before triggering the REST request.

Nice find. Will fix this.

@michikrug I have both Alexas and Google Homes in my house so I have found it easiest to use the V2 (homekit) style tags for my items so they are easily picked up by both. I have a thermostat which maps differently the modes. For example:

When my thermostat is set to heat it reports the mode to the mode channel as 4. Off = 0. Auto = 1. Cool = 3.

The problem is if i say “alexa/ok google set the thermostat to heat” it will change the thermostat to its auto mode. If I say “set the thermostat to auto” it will put my thermostat in cool mode.

What is the easiest way for me to remedy this so they match up what I say to what I get?

Thanks,
David

Please have a look at https://github.com/openhab/openhab-google-assistant/pull/131 where I started extending the documentation.

5 Likes

Please see https://github.com/openhab/openhab-google-assistant/pull/132

2 Likes

I would recommend using a String for the Google thermostat mode that will then receive values like “on”, "off, “heat”, etc. and use transform maps with a set of rules to translate those strings into the number of your choice for your thermostat (and the other way around).
I use this in my own installation with FritzBox thermostats that use uppercase modes.

E,g.

rule "Translate Mode from GA"
when
        Item ThermostatMode_Ga changed
then
        ThermostatMode.sendCommand(transform("MAP", "modes.map", ThermostatMode_Ga.state.toString))
end

modes.map:

off=0
auto=1
cool=3
heat=4
=1

What will happen if both tags and metadata are defined for an item? Will the GA binding ignore tags if metadata is provided

Yes. Tags will only be considered when no metadata in the “ga” namespace is found.

1 Like

I just tried out the two-factor authentication, and I note that you can use acknowledgement or a PIN code with any device type. So, it might be better to have a separate section for TFA in the documentation, rather than including it with the Lock and SecuritySystem item configurations.

Great work!

Nothing is logged in events.log. I even tried to set events to TRACE.
Which log level would i need? Here are my current settings:

Logger                                             │ Level
───────────────────────────────────────────────────┼──────
ROOT                                               │ WARN
javax.jmdns                                        │ ERROR
org.apache.karaf.jaas.modules.audit                │ INFO
org.apache.karaf.kar.internal.KarServiceImpl       │ ERROR
org.apache.karaf.shell.support                     │ OFF
org.eclipse.jetty.util.thread.ThreadPoolBudget     │ ERROR
org.eclipse.lsp4j                                  │ OFF
org.eclipse.smarthome                              │ INFO
org.eclipse.smarthome.automation                   │ WARN
org.jupnp                                          │ ERROR
org.openhab                                        │ INFO
org.openhab.binding.sony                           │ WARN
org.ops4j.pax.url.mvn.internal.AetherBasedResolver │ ERROR
org.ops4j.pax.web.pax-web-runtime                  │ OFF
smarthome.event                                    │ TRACE
smarthome.event.InboxUpdatedEvent                  │ ERROR
smarthome.event.ItemAddedEvent                     │ ERROR
smarthome.event.ItemRemovedEvent                   │ ERROR
smarthome.event.ItemStateEvent                     │ ERROR
smarthome.event.ThingAddedEvent                    │ ERROR
smarthome.event.ThingRemovedEvent                  │ ERROR
smarthome.event.ThingStatusInfoEvent               │ ERROR

Out of curiosity, does your thernostat work if you go back to using tags? The reason I ask is that I got the same error response from Google today when I got home and asked it to turn on the heat, and I was still using tags. It started working shortly after that, so I think the issue was with the connection, not with tags or metadata.

I’ve since switched to metadata and it’s working as expected.

I had another look and the “mode not available” message could also happen, when the specific thermostat item (setpoint, mode,…) was not correctly detected. Troubleshooting this is unfortunately pretty hard.
Could you maybe share your item configuration?

Nothing is logged? I have a complete standard installation and every item change is logged in events.log. (it is set to INFO).

These are my settings for Thermostat setup in one of my rooms (still using Tags though, but that shouldnt matter).

Group     g_Stortbad_TSTAT           "Stort Bad Termostat"                                                                                                                      [ "Thermostat" ]
Number    stort_bad_Temperature      "Stort Bad Temperatur [%.1f °C]"                                          <cu_heating> 	(g_Stortbad_TSTAT,Temperatur,gTvaer,gSugeTemp) 	[ "CurrentTemperature" ]                { channel="ihc:controller:elko:stortbad_temperatur_fb" }
Number    stort_bad_Tempsetpunkt     "Stort Bad Temperature setpunkt [%.1f °C]"                                <temperature>	(g_Stortbad_TSTAT)                              [ "homekit:TargetTemperature" ]	        { channel="ihc:controller:elko:stortbad_temperaturSet_fb", autoupdate="false" }
Number    stort_bad_fugt             "Stort Bad Fugtighed [%.0f %%]"                                           <Humidity>       (g_Stortbad_TSTAT,Fugtighed,gHumidityBathRoom) 	[ "CurrentHumidity" ]                   { channel="ihc:controller:elko:stortbad_fugtighed" }
String    stort_bad_Mode             "Stort Bad Mode [%s]"                                                                      (g_Stortbad_TSTAT)                              [ "homekit:TargetHeatingCoolingMode" ]
Switch    telestat1_stort_bad        "Stort Bad Telestat [%s]"                                                 <cu_switch> 	(g_Stortbad_TSTAT,gTelestat)                                                            { channel="ihc:controller:elko:stortbad_telestat" }

The item for Mode is a string item…

I then use the item telestat1_stort_bad to “parse” the mode status to the thermostat in a small and very simple rule:

rule "heatingmode stortbad"
when
     Item telestat1_stort_bad changed
then
     if (telestat1_stort_bad.state.toString == "ON" ) {
        stort_bad_Mode.postUpdate("heat") } 
     else {
         stort_bad_Mode.postUpdate("cool") }
end

This will result in the Google Home “Stort Bad Termostat” showing two possible modes:
“heat” when Telestat is ON, (Icon will turn red in the app/Hub)
“cool” when Telestat is OFF, (Icon will turn blue in the app/Hub)
All depending on wether the Telestat is ON or OFF…

Very simple and highly logic. Plus it works great :slight_smile:

Sorry for bothering. After the 3rd restart of openHAB and the maybe 10th time resyncing devices it is working now. Anyways, here my item config for reference:

Group 		gHeatingthermostat_Lr	"Wohnzimmer Thermostat" (gHeatingthermostats) 									{ ga="Thermostat" }
String		St_Ht_Controlmode_Lr	"Wohnzimmer Thermostat Controlmode" (gHeatingthermostat_Lr, gHeatingControlMode, gPersist_MapDB_Restore) 	{ ga="thermostatMode" }
Number 		Nu_Ht_ActTemp_Lr	"T_Ist Wohnzimmer Thermostat [%.1f °C]"	<temperature> (gHeatingthermostat_Lr)					{ channel="homematic:HG-HM-CC-RT-DN:homegear:NEQ0871180:4#ACTUAL_TEMPERATURE", ga="thermostatTemperatureAmbient" }
Number 		Nu_Ht_SetTemp_Lr 	"T_Soll Wohnzimmer [%.1f °C]" <temperature> (gHeatingthermostat_Lr, gHeatingSetTemp)				{ channel="homematic:HG-HM-CC-RT-DN:homegear:NEQ0871180:4#SET_TEMPERATURE", ga="thermostatTemperatureSetpoint" }
1 Like

@michi
I tried played abit with the security system (Switch { ga="SecuritySystem" [ tfaPin="1234" ] }
This is my item…

Switch    alarm_totalalarmFra        "IHC Total Alarm koble fra [%s]"                                          <switch>                  (alarm)           { channel="ihc:controller:elko:alarm_totalFra", ga="SecuritySystem" [ tfaPin="1234" ], autoupdate="false" }

First of all… I noticed I got an error loading the item, if I insert 5 digits PIN code…

I then changed back to 4 digits and it worked fine…

But…
When I asked Google to:
turn on IHC Total Alarm koble fra
she responded with,
"okay can I have your PIN code to turn on IHC Total Alarm koble fra ".
I said
1 2 3 4
and “she” responded,
okay here is 1234…“blablabla something”… from Spotify

And she started playing that track from Spotify!
She never reached as far as triggering the item.

I dont think thats whats suppose to happen :slight_smile:

First of all thank you for your effort.
Im happy to try out soon. It would be awesome if there is now an option to have different modes for vacuums like cleaningmodes for different rooms… Is that already possible?

No problem here : but I say 12 and after 34