How can I trigger a flow from google home?

I made an automation to read the temperature and it works fine … except I can’t get it triggered by using google home. Works fine if I enable the script in HA states UI and the buttons in lovelace and Node-Red dashboard.

[{"id":"dc10d147.eff51","type":"inject","z":"5e4ba6a8.3a5918","name":"Inne og ute temperatur","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":200,"wires":[["d2c514f1.9a48c8"]]},{"id":"d2c514f1.9a48c8","type":"api-current-state","z":"5e4ba6a8.3a5918","name":"Henter ute temperatur","server":"640a3dfe.0fc004","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"sensor.sensative_strips_comfort_temperature","state_type":"str","state_location":"utetemp","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":180,"y":260,"wires":[["e8e2a424.cfc4e8"]],"icon":"font-awesome/fa-thermometer-0"},{"id":"287b9e4e.343da2","type":"api-call-service","z":"5e4ba6a8.3a5918","name":"Leser ute temperatur","server":"640a3dfe.0fc004","version":1,"debugenabled":false,"service_domain":"tts","service":"google_say","entityId":"media_player.google_home","data":"{\"message\":\"Temperaturen ute er {{payload}} grader.\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"global","mustacheAltTags":false,"x":640,"y":260,"wires":[["7943768e.3ed378"]],"icon":"node-red-contrib-cast/google-home-mini2.svg"},{"id":"e8e2a424.cfc4e8","type":"function","z":"5e4ba6a8.3a5918","name":"Comma <--> Dot","func":"msg.payload = msg.utetemp.replace(\".\" , \",\");\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":260,"wires":[["287b9e4e.343da2"]]},{"id":"d77dc62f.f1ba98","type":"ui_button","z":"5e4ba6a8.3a5918","name":"","group":"ffc2e198.4ee64","order":0,"width":0,"height":0,"passthru":false,"label":"Les temperatur","tooltip":"","color":"blue","bgcolor":"yellow","icon":"","payload":"on","payloadType":"global","topic":"","x":440,"y":200,"wires":[["d2c514f1.9a48c8"]]},{"id":"7943768e.3ed378","type":"debug","z":"5e4ba6a8.3a5918","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":830,"y":260,"wires":[]},{"id":"38bdaf34.7303f","type":"server-events","z":"5e4ba6a8.3a5918","name":"Les temperatur","server":"640a3dfe.0fc004","event_type":"call_service","x":160,"y":340,"wires":[["bc04bc25.ca8d1"]]},{"id":"bc04bc25.ca8d1","type":"switch","z":"5e4ba6a8.3a5918","name":"","property":"payload.event.service_data.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"script.les_temperatur","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":340,"wires":[["d2c514f1.9a48c8"]]},{"id":"640a3dfe.0fc004","type":"server","z":"","name":"Home Assistant"},{"id":"ffc2e198.4ee64","type":"ui_group","z":"","name":"Automasjoner","tab":"43e15607.8d9cb8","order":2,"disp":true,"width":"6","collapse":false},{"id":"43e15607.8d9cb8","type":"ui_tab","z":"","name":"Dashboard","icon":"dashboard"}]

scripts.yaml

les_temperatur:
    alias: Les temperatur
    sequence:

How can I trigger this automation by saying “hi google, …” ?

1 Like

There might be a way to do it more directly… create an input_boolean and expose that. Then ask Google to turn on the input_boolean. In NodeRED have the input_boolean trigger the flow. Then turn off the input boolean as part of the flow.

2 Likes

Can you please show me an example ?
I’ve only been using Node-Red for a few days and am not quite sure about programming in yaml either :flushed: :flushed:

Just expose the script to Google Home.

1 Like

oh yeah @mbonani - didn’t realize you had a script in HA. You can expose that to Google Home directly. I think once you do that you just ask GH turn on

2 Likes

The script is alredy in my google home app… :cold_sweat:
nr1

You have one switch and one script with the same name exposed. Probably Google home gets confused. You should be able to tell Google home “hey Google, aktivera/activate les temperatur” and it should activate the script.

Also, why do you have your lights exposed as switches instead of lights?

1 Like

Yes, maybe google home gets confused. Have to change the name of one of them.
I have tried Hey google, activate… turn on, open, start. and more in both norwegian and english but Goggle dont understand what I want it to do :slight_smile:

The lights that you see above as switches are outlets that controls some led strips and other lamps without smart bulbs :slight_smile:

I would try that, my scripts are firing without issues when I say “activate script_name”

Why not make some template lights for those switches?
It works much better to separate them and then Google knows what is what.
For example if I say “turn off kitchen” Google turns off both lights and switches, including my coffee machine.
But if I say “turn off kitchen lights” it only turns of the lights.

To convert a switch to a light you can add this template light:

- platform: template
  lights:
    lusthus_fonster_1:
      friendly_name: 'Lusthus Fönster 1'
      level_template: '{{ 100 if is_state("switch.lusthus_fonster_1", "on") else 0 }}'
      value_template: '{{ is_state("switch.lusthus_fonster_1", "on") }}'
      turn_on:
        service: switch.turn_on
        entity_id: switch.lusthus_fonster_1
      turn_off:
        service: switch.turn_off
        entity_id: switch.lusthus_fonster_1

Then expose

- light.lusthus_fonster_1

In your cloud config.
And maybe even give it some aliases.
With aliases I can now control all my entities both in Swedish and English without having to say “foooenster” in a swenglish accent while I integrate with my Google homes in English.

  entity_config:
    light.lusthus_fonster_1:
      name: Lusthus fönster
      aliases:
       - Fönster
       - Windows
       - Summerhouse windows
      room: Trädgård

Then keep devices like coffee makers as switches.
Hope this gets you on the right track :smiley:

Edit: please note all my code is intended 2 spaces to little since I use separate files for my config.

1 Like

Thanks rodak, haven’t thought of it before. I’m not very good with this yaml programming, but with such a good example as you have come up with here I think I’ll do it. :grinning:

Node-Red seems to be much easier to understand than yaml, but as long as I can achieve the desired result, then it does not matter whether it is done using yaml or Node-red.
Time to clear some switches :blush:

Thank you very much for good info

1 Like

Let me know if you get any issues.
I can then reformat my code to be single “configuration.yaml” friendly tomorrow when I’m at my computer. Just did a quick copy and paste above on my phone so maybe not the cleanest.

Now time to say “aktivera godnatt” :smiley:

1 Like