Have Google home read out sensor state when asked?

I have been experimenting with Stringify. Asside from having to say “ok, google. tell stringify…”, its works a lot better than IFTTT. You can string a lot of triiggers and actions together.

You can use the maker component to call scripts in HA Good alternative to IFTTT

Stringify doesn’t even work for me. It says it can’t find the trigger I said, then reads out the trigger name when it says the triggers it has found :rofl:

I still use Google Assistant though IFTTT, and set a random response such as ‘Just checking’. So I say:

Hey Google, what’s temperature upstairs?’.

It says ‘Just checking’, ‘Let me check’ or whatever, then runs the script that says
The temperature upstairs is 21 degrees.

Not ideal, but it’s the best workaround I’ve found for now.

1 Like

Hi
I’ve set up the same thing with ifttt

I’ve set up two so far

1 check is anything is downloading
2 check if anyone is remote playing plex

1 Like

I’ve just done this by setting up the demo switch component that creates two switches (all I needed); switch.ac and switch.decorative_lights.

I’ve added an automation that turns these switches on and then straight off again after calling a script that reads either the garage door status or the pool temperature. The switches, customization and automations are all held in a package which is below.

###################################
##  Customize
###################################
homeassistant:
  customize:
    switch.ac:
      friendly_name: Garage Status
      icon: mdi:text-to-speech
      hidden: false
    switch.decorative_lights:
      friendly_name: Pool Status
      icon: mdi:text-to-speech
      hidden: false

# ###################################
# ##  Automations
# ###################################
automation:
  - alias: 'Set Demo Switch to Off'
    trigger:
      - platform: homeassistant
        event: start
    action:
      - service: switch.turn_off
        entity_id: switch.decorative_lights

  - alias: 'Check Garage Door Status'
    trigger:
      - platform: state
        entity_id: switch.ac
        from: 'off'
        to: 'on'
    action:
      - delay:
          seconds: 2
      - service: script.turn_on
        entity_id: script.garage_status
      - service: homeassistant.turn_off
        entity_id: switch.ac

  - alias: 'Check Pool Temperature'
    trigger:
      - platform: state
        entity_id: switch.decorative_lights
        from: 'off'
        to: 'on'
    action:
      - delay:
          seconds: 2
      - service: script.turn_on
        entity_id: script.pool_status
      - service: homeassistant.turn_off
        entity_id: switch.decorative_lights

switch:
  - platform: demo

I’ve then added switch.ac and switch.decorative_lights to both Alexa and Google Home and then created shortcuts in Google Home for “is the garage door open or closed” which fires “turn on garage status” and “what’s the pool temperature” that fires “turn on pool status” Works for me! :slight_smile: :stuck_out_tongue:

P.S Here is one of the scripts. Going to see if they’ll stick inside the package too.

pool_status:
  alias: 'Check Pool Temperature'
  sequence:
  - service: tts.google_say
    entity_id: media_player.gaming_room_home
    data_template:
      message: >-
        The pool temperature is currently {{states('sensor.pool_temperature')}} degrees
3 Likes

Have now moved both ‘speech’ scripts inside package and it works great. All code now inside one yaml file. :slight_smile:

3 Likes

Hi Sir
My name is Mubeen i am an electrical engineer and working with Google Home Mini.
i want that google Home read my sensor data like
i ask what is the voltage and power factor in phase 1
and speak out the value .
I have zero knowledge of IFFT and Google home i am just learning it .
lease guide me step by step . i will be very thankful to you for this favor.
Regards
Mubeen

Did you already have a working setup with google home and ifft? Is your sensor already integrated in home-assistant?

Thank you for the response Sir
i just bought the Google home mini and watching videos from you tube to integrate it with my circuit .
this is very new thing for me please guide me
thank you

Hi, I’ve read you can use Home Assistant integrated TTS (Google Assistant - GA) to check the garage door status and report it to Home Assistant (HA).
I have an AC switche recognized by Google Home (GH) -Google Assistant (GS) but not by HA. I’m able to command it via HA using a script:

   #Switch Google Home
      - platform: command_line
        switches:
          filtro_piscina:
            command_on: "/usr/bin/curl -X GET http://192.168.1.110:5000/command?message=accendi%20filtro%20piscina"
            command_off: "/usr/bin/curl -X GET http://192.168.1.110:5000/command?message=spegni%20filtro%20piscina"`

I’d like to “ask” to GA the status of the “filtro_piscina” switch and report it to HA in order to have a different icon or something similar.
Could you help me? Thanks a lot!

You can do it that way, I did the same for being able to check/open/close the garage door with a switch. But you unfortunately have to use on/off as the state not open/closed.

You can create shortcuts in GA to recognise you saying ‘Open the garage door’ or ‘Is the garage door closed’, and translate that to what is required for switches being ‘Turn on the Garage Door’ or ‘Is the Garage Door turned on?’.

Not quite sure what you mean when you say Google can ‘see’ your switch but Home Assistant can’t. You could look into creating a template switch for your command line switch which may be better and simpler than my method and template switches show up in both Google and Alexa inside the HA cloud.

You need to get to a point where HA knows the state of your ‘filtro_piscina’ and when it does, you can then use my method to query Google by asking Google to turn on a fake switch. The fake switch could be the new template switch which I’m going to try at some point.

It will be something like EWeLink which has native Google Assistant support but is not supported by HA without setting up IFTTT and binary switches/sensors or flashing with Tasmota

Meross switch has a native Google Home support, Home Assistant none.
So, I have to use Google Assistant Webserver with HA in order to create a switch in HA, using text command, as I wrote. So I have the possibility to use the Meross in HA.
But this method gives no feedback about switch state on or off.

So how can I “ask” to GA via GH? You wrote about a script for the garage, but you didn’t published it. Could you post it?

Think sa lot.

The garage script is exactly the same as the pool one except with a different entitiy ID. Have Google home read out sensor state when asked? - #24 by xbmcnut. When I did this, Google and Alexa could only control switches so you need to be able to get a switch into Home Assistant that you can voice control then you run a script when that switch is activated. I believe now that you might be able to get Google (and Alexa) to control input_booleans and if so, that would be easier.

So the steps are:

  1. Have the device you need to get the feedback on reporting its state to Home Assistant.

  2. Create a fake switch that you can turn on with voice control. (My method, input_boolean if controllable with Google/Alexa or maybe a template switch).

  3. Use that fake switch to run a script that grabs the value from your device and reads it aloud using the TTS engine.

I just played around with creating a bogus switch and it works.

switch:
  - platform: template
    switches:
       pool_status:
         friendly_name: "Ask Google for the Pool Temperature"
         value_template: "{{ is_state('input_boolean.pool_status', 'on') }}"
         turn_on:
           service: script.pool_status
         turn_off:
           service: script.none

There is no input_boolean defined and no script called script.none but no errors throw up and it works a treat. Turning on this switch reads out the pool temperature and the switch turns itself off ready to use again. Much easier than setting up the whole demo platform.

Welcome to any ideas on a better way to set up a fake switch.

2 Likes

Furthermore, I have confirmed input_boolean function directly within Google Home and Alexa via the HA cloud. No need for fake switches at all. Here is a high tide example which gets Google or Alexa to tell me the time of the next high tide. Cool.

input_boolean:
  next_high_tide:
    name: Next high tide by Google
    icon: mdi:swim

script:
  speak_next_high_tide:
    alias: 'Ask Google for next High Tide time'
    sequence:
    - service: tts.google_say
      entity_id:
        - media_player.kitchen_home
        - media_player.gaming_room_home
      data_template:
        message: >-
          The next high tide is at {{ as_timestamp(states.sensor.onetaunga_bay_tides.attributes.high_tide_time_utc) | timestamp_custom("%H:%M") }}

automation:
  - alias: 'Check Next High Tide'
    trigger:
      - platform: state
        entity_id: input_boolean.next_high_tide
        from: 'off'
        to: 'on'
    action:
      - delay:
          seconds: 2
      - service: script.turn_on
        entity_id: script.speak_next_high_tide
      - service: input_boolean.turn_off
        entity_id: input_boolean.next_high_tide

The add the following to your cloud config:

cloud:
  google_actions:
    filter:
      include_entities:
        - input_boolean.next_high_tide

  alexa:
    filter:
      include_entities:
        # - switch.pool_light
        - input_boolean.next_high_tide

Lastly, say “OK Google, sync my devices” to add the input_boolean in and discover devices in Alexa to have it added there. Then give the device a nickname in each platform and create a routine in Google so you can ask for the high tide using different phrases.

3 Likes

Is there a way that you can turn on the input_boolean without it responding “sure turning on …” I thought that was the point of doing it with a boolean and not just exposing the script to GH. Otherwise you could just make sure that scripts is exposed to Google like this.

google_assistant:
  project_id: something_something
  api_key: <its mine and I'm not telling>
  exposed_domains:
    - switch
    - light
    - group
    - script

With scripts you can just say “Turn on …” or “activate …” and GH responds with “sure, Activating …” but I want to just have my TTS and not that part.

Not sure what you’re looking for, but if you want a customized request and response, you could use IFTTT, and say something like “what is the current water temperature?”.

As for the state of certain devices, you should be able to just ask,“are my kitchen lights on” and GH will respond with the state.

My end goal is to ask Google “What is the battery percentage of my car …” and have it respond only with the sensor value. I was trying to avoid using ifttt because it adds a extra level of complication.

1 Like

Anyone clever enough to figure out how I could add a condition to my TTS automation to define the Google Home speaker that just activated and to speak back only to that one?