[Google Integration] Thermostat Example

Hi All.

Having fun with my new installation of OH2 but have come to a brick wall.

I have a heating system fully functional and working via mqtt and node red, however I am in the process of migrating to OH2 due to the google home functionality.
I have successfully ported all my switches and lights through to GH via OH2 but I am stuck on how to create a working “virtual thermostat” that shows up (and works) in google home.

I have one item (temp sensor) of type “number” that is updated via mqtt and tagged as “CurrentTemperature” and another one of type “number” that if changed can update mqtt and tagged as “TargetTemperature”

The temp sensor that is tagged as “CurrentTemperature” shows up as a thermostat in GH but only displays the temp as expected, but does nothing else. If I set tag to “Thermostat” as I found in the documents, it does not even show up in GH.

Does anyone know how to combine these two items together so that I will have a working “virtual thermostat” usable in GH? This is the last piece I need in the puzzle but am at a loss on how to do it.

Any help would be appreciated, or links to references on how to do it, been looking and reading for days but can’t seem to suss it out.

Thanks in advance.

1 Like

Here’s a github link to google assistant with some thermostat examples in the read me. https://github.com/openhab/openhab-google-assistant/blob/master/USAGE.md

Thanks H

Got it working…sort of.

I cannot get it to work with living room as the name, google translates the text as “living room” but I have to name it livingroom or living_room, both of which google does not seem to like. For instance when name in OH2 is set to livingroom, then if I say “what is the living room thermostat temperature” I get back “Sorry I’m not sure which thermostat you’d like to control” but if I type it in manually with livingroom, it works. Even if assigned to the Living Room. I have changed to kitchen and bedroom, both work fine.
Has anyone managed to get it working with living room as the name?

Glad to see you’ve made some progress!

I’m not a google user but maybe try a name like Family Room, Den, etc… Or post your items for review, maybe something small that got overlooked.

You need to assign the thermostat to a room in the google home app. Then it will work. The location has nothing to do with the name of the item in openHAB.

Thanks again H.

Yeah, I keep chipping away at it :grinning:

Not too bothered as I have renamed it to “House” now and it seems to be fine, The living room code I was using was this below:-

Group g_Livingroom_TSTAT "Living room Thermostat" [ "Thermostat", "Celsius" ]
Number Livingroom_Mode "Living room Heating/Cooling Mode" (g_Livingroom_TSTAT) [ "homekit:HeatingCoolingMode" ]
Number Livingroom_Temp "Living room Temperature" (g_Livingroom_TSTAT) [ "CurrentTemperature" ]
Number Livingroom_Setpoint "Living room Setpoint" (g_Livingroom_TSTAT) [ "TargetTemperature" ]

Where it has “Livingroom” I tried changing to “Living_room”,“livingroom” and “living_room” but none seemed to work.

The ambient temp now shows correctly in the GH thermostat, also updating the setpoint works fine, just trying to figure out when I change the mode in GH so it updates the mode setting in OH2 - as it is doing nothing at the moment, just stuck on whatever mode I set it to in OH2. Although It would be better to be able to turn the heating off from the thermostat by selecting “OFF” mode rather than creating a seperate switch.
I think it may have something to do with the homekit config somehow…maybe? although I do not have any homekit, i assume it uses the misc addon to “emulate it” somehow? been looking here https://www.openhab.org/addons/integrations/homekit/ but it says it can be edited in paperUI in standard and expert mode, dont know where those options are and cant seem to figure that one out yet.

Many thanks for your help.

Looking at this item:

Number Livingroom_Mode "Living room Heating/Cooling Mode" (g_Livingroom_TSTAT) [ "homekit:HeatingCoolingMode" ]

Is the mode reported to OH as a Number item or Switch (ON/OFF) item?

Hi H.

The mode does not change in OH2 when selected from GH app. if I select a change, it just says "Updating please wait… then goes back to whatever mode it was in before.
However if I change the mode setting in OH2 to a number 0,1,2,3 then refresh the thermostat on GH app, it changes to the following/
0 - Off
1 - Heating
2 - Cooling
3 - Other

The problem is I need it to work the other way way round - from GH app to OH2 at the moment only works from OH2 to GH app… hmmmm

I have give up on trying to get it to recognise “Living room” [vzorglub] thanks for your suggestion but I assigned the thermostat to living room straight away in GH app and it still did not work.

I am now using

Group g_House_TSTAT "House Thermostat" [ "Thermostat", "Celcius" ]
  Number House_Mode "House Heating/Cooling Mode" (g_House_TSTAT) [ "homekit:HeatingCoolingMode" ]
  Number House_Temp "House Temperature" (g_House_TSTAT) [ "CurrentTemperature" ]
  Number House_Setpoint "House Setpoint" (g_House_TSTAT) [ "TargetTemperature" ]

Thanks guys.

Have you tired using MAP transformation with the TSTAT item?

Well I would if I knew what that meant :thinking:

Checking the docs now…

Using this item as example

Number House_Mode "House Heating/Cooling Mode" (g_House_TSTAT) [ "homekit:HeatingCoolingMode" ]

adding MAP transformation to the item

Number House_Mode "House Heating/Cooling Mode [MAP(NameOfYourMapFile.map):%s]" (g_House_TSTAT) [ "homekit:HeatingCoolingMode" ]

Create the MAP file in /etc/openhab2/transform name the file and use the .map extension.

Example name: /etc/openhab2/transform/house.map

EDIT: If using the MAP transformation use PaperUI > Addons > MAP Transformations to install.

Hi H.

I think I understand what you mean here by changing the input from House_Mode , however I cannot determine what the GH app is sending to OH2 (if anything at all) so I can map it. When I monitor the House_mode item in OH2 it does not change at all.

I appears to be only reading from mode status from OH2 instead of writing to it on a GH app change.

Are you looking at the logs while making changes to both the app and OH? What interface are you using to view and send commands on OH, BasicUI, ClassicUI, etc…?

Apologies H

I just found this in the log

[WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/House_Mode' with an invalid status value 'cool'

I will attempt to map them now I know what they are.


I will try it now

Thank you

I think your on the right track,:sunglasses: when you get time check out REST API. You can install this via PaperUI > Addons > Misc > REST Documentation.

Don’t forget to install MAP transformation in PaperUI.


Thought I nearly had it there. but alas it wasn’t meant to be.

I installed map trans in Paper UI.
created a file in transform dir called ghtherm.map


now I am getting this in the log

2018-11-24 22:32:23.557 [thome.event.ExtensionEvent] - Extension 'transformation-map' has been installed.
2018-11-24 22:39:29.707 [vent.ItemStateChangedEvent] - House_Temp changed from 22.8 to 22.9
2018-11-24 22:44:29.731 [vent.ItemStateChangedEvent] - House_Temp changed from 22.9 to 22.8

==> /var/log/openhab2/openhab.log <==
2018-11-24 22:47:46.749 [WARN ] [rm.AbstractFileTransformationService] - Could not transform '1' with the file 'ghtherm.map' : Target value not found in map for '1'
2018-11-24 22:47:47.683 [WARN ] [rm.AbstractFileTransformationService] - Could not transform '1' with the file 'ghtherm.map' : Target value not found in map for '1'
2018-11-24 22:47:48.174 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/House_Mode' with an invalid status value 'cool'.
2018-11-24 22:47:49.578 [WARN ] [rm.AbstractFileTransformationService] - Could not transform '1' with the file 'ghtherm.map' : Target value not found in map for '1'
2018-11-24 22:47:52.130 [WARN ] [rm.AbstractFileTransformationService] - Could not transform '1' with the file 'ghtherm.map' : Target value not found in map for '1'
2018-11-24 22:47:55.140 [WARN ] [rm.AbstractFileTransformationService] - Could not transform '1' with the file 'ghtherm.map' : Target value not found in map for '1'

I am confused as to why the House_Mode won’t accept the text in the first place…:roll_eyes:



or add this to the file


OMG just realised what is going on…

House mode is assigned as a number instead of a string…

just changed it from

Number House_Mode "House Heating/Cooling Mode" (g_House_TSTAT) [ "homekit:HeatingCoolingMode" ]


String House_Mode "House Heating/Cooling Mode" (g_House_TSTAT) [ "homekit:HeatingCoolingMode" ]

and it is working great now…

just checked the https://github.com/openhab/openhab-google-assistant/blob/master/USAGE.md page again and it is a number in there, thats what led me a stray I think.
Anyway thanks ever so much H, I have learnt a lot this evening.

Take care. V

1 Like

Guess I should have expanded my question.:rofl:

Good to see that you have it working,:sunglasses: you did a great job!