In the previous post, we have seen how Xiaomi BLE Temperature and Humidity sensors can be integrated to HASS. In the same post, there was also an example of using RaspberryPi+MQTT to network distant BLE sensors.
Now that the sensors and lights are integrated at one place, I would like to use Google Assistant to further get notifications for these devices:

I have borrowed this picture from my first post, where I integrated the Ikea lights with HASS. Ikea Smart Home App has an integrated support for Google Assistant. This way we can turn on, turn off and dim lights using Google commands. However Xiaomi sensors do not have any ready made solutions to integrate with Google Assistant (at the time of publishing this post).
I would like to setup this integration so that I can ask Google “Hey Google! Den Shower Humidity?” and then Google will respond with “Temperature in the bathroom is 23.4 deg”. To get this working, we need to:
- Expose HASS server with a publicly accessible hostname and SSL certificate.
- Setup a project using Google Actions Console.
- Link the project with publicly accessible HASS.
Detailed instructions can be found here. As also described in the same instructions, a “Sensor” domain in Google Assistant exposes the temperature settings and nothing more. This means we can only expose the Xiaomi sensor’s temperature setting through this procedure. In order to expose the humidity setting, we have to develop a custom script in HASS and then configure HASS to run this script when triggered by Google Assistant commands. I have used the script procedure to expose both temperature and humidity settings of the Xiaomi BLE sensor. Here are the details for this procedure:
Edit the file /config/scripts.yaml
and enter the following lines:
google_den_shower_temp:
alias: Den Shower Temperature
sequence:
- service: tts.google_translate_say
entity_id:
- media_player.ghome_kitchen
data_template:
message: “Temperature in bathroom is {{ states("sensor.basement_shower_temperature") }} degrees.”
cache: falsegoogle_den_shower_humidity:
alias: Den Shower Humidity
sequence:
- service: tts.google_translate_say
entity_id:
- media_player.ghome_kitchen
data_template:
message: “Humidity in bathroom is {{ states("sensor.basement_shower_humidity") }} percent.”
cache: false
The tags are self-explanatory. We have defined the service as tts.google_translate_say
that invokes the text-to-speech service on Google Assistant. We then define the entity_id
as the device where the service will be invoked — in this case the Google Home Mini that is placed in the Top Floor. You can find the entity names under “Entity Registry” of HASS. Finally we define data_template
with text that should be used. Note that the text contains an expression that retrieves temperature or humidity values from the Xiaomi sensor. Next we expose the relevant domains for Google Assistant integration. Edit /config/configuration.yaml
and update the following:
google_assistant:
project_id: !secret google_assistant_project_id
api_key: !secret google_assistant_api_key
expose_by_default: false
entity_config:
script.google_den_shower_temp:
name: Den Shower Temperature
expose: true
room: Den
script.google_den_shower_humidity:
name: Den Shower Humidity
expose: true
room: Den
If you have followed the earlier instructions to setup Google Assistant integration, you should already have the essential configuration in place. We need to update it with the entity_config
that exposes the scripts created above. Optionally you can also assign a room for the script, so they appear under those specific rooms in the Google Home App. Once this is complete, restart HASS for the changes to take effect.
Once HASS is up and running, open Google Home App in the smartphone and “sync devices”. Again this depends on successful configuration of Google Assistant integration as explained at this link. In Google Home App, select Settings →More Settings →Assistant →Home Control →Devices. You should now be able to see the exposed domains(scripts) under the app created via Google Actions Console. Here is a snapshot from my phone:

Now just say “Hey Google! Den Shower Humidity” and Google Home responds with the humidity setting available via Xiaomi BLE sensor. Do note that the accent is different from the one configured for the Assistant and I suspect this is because of the text-to-speech conversion. But, apart from this anomaly, everything else works just fine!
Hope this series has been helpful in starting with your own automation environment using HASS. Until next time!