Temperature Sensor and Google Assistant

I added an MQTT connected DHT22 sensor (temperature and humidity) to my home and configured it successfully in OpenHab2. I’ve also configured it with the Google Assistant so that I can ask for the temperature:

Group gBasement_tstat "Basement Thermostat" {ga="Thermostat" }
Number bh1temp "Basement Temperature" (gBasement_tstat) { channel="mqtt:topic:sensors:th1temp", ga="thermostatTemperatureAmbient" }

This is as described in the documenation:

You can also set up a Thermostat for using it as a temperature sensor. To do so, create a Thermostat group and only add one item member as “thermostatTemperatureAmbient”.

When I ask for the temperature: Hey Google, what’s the basement temperature?
Answer: It’s currently 20 degrees and Basement Thermostat is off.

How can I get rid of the “and Basement Thermostat is off” part of the answer? I’m guessing I need to tell Google that the thermostat is on.

The docs also mentions creating a mode and manually assigning a value. I see how a mode is added.
How do you manually assign a value?

Yes you have to create a mode.
Look at this. Its basicly the same.

Thanks for your response.

I dug a little deeper and found this in the Google reference that was linked in the OH documentation:

queryOnlyTemperatureSetting
Boolean. Optional. Required if the device supports query-only execution. This attribute indicates if the device can only be queried for state information, and cannot be controlled. Sensors that can only report temperature should set this field to true. If this field is true, the availableThermostatModes attribute is optional.

Looking at the OH code, it is setting that attribute when the temperature group DOESN’T have a mode or setpoint. This logic looks right to me and is what is described in the OH documentation.

Googling further, I found the same problem reported with another product.

They conclude that the problem is on the Google side and I tend to agree.

Since I wrote the Arduino code that is accessing the DHT22 and publishing the MQTT sensor values, I can just add a thermostat mode topic and publish a value for the mode…

That was unsuccessful. I added a thermostat mode:

Group gBasement_tstat "Basement Thermostat" {ga="Thermostat" }
String bHeatMode "Basement Thermostat Mode" (gBasement_tstat) { ga="thermostatMode" }
Number bh1temp "Basement Temperature" (gBasement_tstat) { channel="mqtt:topic:sensors:th1temp", ga="thermostatTemperatureAmbient" }

And a rule to set the mode:

rule "Init"
when
    System started
then
    logInfo( "sensor.rules", "Setting thermostat heat" )
    bHeatMode.postUpdate("heat")
end

Me: Hey Google, what is the temperature in the basement?
Google: The basement thermostat is set to heat.

And it doesn’t tell me anything about the temperature. The behaviour without the thermostat mode was better.

Google recently added standalone sensors to Google Assistant, and by “recently” I mean within the last two weeks…and just before the world shut down. So, it definitely hasn’t been added to OH yet.

https://developers.google.com/assistant/smarthome/guides/sensor

FYI

@michikrug

Have you seen enough of the new sensor api to know whether this use case will work as intended?

If not, could you look at the existing thermostat support to see whether a slightly different response to Google (e.g. indicate that the thermostat is ON), when providing temperature readings makes a difference?

Thanks

The API looks quite promising. But, so far my tests did not yield in any functional results.

Unfortunately, I do not really get your second question.

Hi michikrug

The behaviour I’m seeing is described in the first post of this thread. I’ve added a temperature sensor and as recommended, put it in a thermostat group. When I ask Google for the temperature, it tells me what it is, but it feels obligated to tell me that my pseudo-thermostat is off.

I don’t know what communication takes place between Google and the OH integration layer for this temperature sensor when “queryOnlyTemperatureSetting” is true. I was just speculating that something in there tells Google about the thermostat group. If this is true, is there a way to indicate that the pseudo-thermostat is ON, at some point during the exchange of information?

Maybe this minor issue stems from the fact that that sensor temperature is a ga=“thermostatTemperatureAmbient”, making it part of a thermostat. That was the intention of my first question to you. Is a termperature sensor better implemented with the “sensor” api support?

Regards

Any update on this? I’m having trouble with a temperature sensor working at all with google home and openhab. i have a thermostat item which works fine. but i also own a standalone temperature sensor which works but not with google home. i followed the instruction also to “only add the ambienttemperature item to the group” but it just shows mode Other and temperature 50. The temperature isn’t even right. Does it expect celsius maybe? My item/openhab uses fahrenheit.

I recall there were a fahrenheit issue at some time… Perhaps thats the issue you´re having… Did you try celcius?

I tried Celsius but it just detailed to showing 20 degrees it was weird. Using 2.5.5 latest snapshot.

Hmm, could you show your items for this? It makes it a bit easier to provide help :smiley:

Number:Temperature BackDoor "Back Door" { alexa="TemperatureSensor.temperature" [ scale="Fahrenheit" ] }

Number:Temperature Outside "Outside" { alexa="TemperatureSensor.temperature" [ scale="Fahrenheit" ] }

Group Thermostat "Thermostat" { alexa="Endpoint.Thermostat", ga="Thermostat" [ useFahrenheit=true, modes="off=0,heat=4,cool=3,auto=1" ] }
Number:Temperature Temperature "Temperature" (Thermostat) { alexa="TemperatureSensor.temperature" [ scale="Fahrenheit" ], ga="thermostatTemperatureAmbient" }
Number:Temperature TargetTemperature "Target Temperature" (Thermostat) { alexa="ThermostatController.targetSetpoint" [ scale="Fahrenheit" ], ga="thermostatTemperatureSetpoint" }
Number ThermostatMode "Thermostat Mode" (Thermostat) { alexa="ThermostatController.thermostatMode" [ OFF=0,HEAT=4,COOL=3,AUTO=1 ], ga="thermostatMode" }

That works except the temperature sensors for Google. If I try putting BackDoor or Outside in a group for google is when I get the trouble I described.

If anyone has able to get rid of the “and Basement Thermostat is off” part of the answer when asking for temperature using Google Assistant, please let me know how it’s done. Thanks.

@michikrug are you perhaps the one that can help @chaapu, me and others with how to get rid of the “and blabla thermostat is off” answer? All I would like to know is the temperature of the poolwater! :slight_smile:

Unfortunately, I don’t think you’ll be able to do this until the new standalone sensor types are added (see my previous post). You’re telling Google Assistant that your thermometer is a thermostat, so it’s acting appropriately by telling you that the thermostat is off.

They need to be added in the binding or by Google? From comment #16 in the thread https://issuetracker.google.com/issues/136103089 it seems it should already be possible to “use the TemperatureControl trait instead of TemperatureSetting as the latter is designed for thermostat-like devices”. So this means the binding needs to be updated?

Well, the documentation explicitly states:

action.devices.traits.TemperatureControl - Trait for devices (other than thermostats) that support controlling temperature, either within or around the device. This includes devices such as ovens and refrigerators.

I still can try to implement this too. But not for Thermostat devices as this likely conflicts with the TemperatureSetting trait attributes.

Ok guys. I have successfully implemented a Temperature Sensor using the SENSOR device type and the TemperatureControl trait.
With that GA will only respond with the current temperature.

Will do some more testing and provide a PR soon.

1 Like