Control HA when not at home using Siri and Gmail

Inspired by https://github.com/thesanjeetc/SiriControl-System

Setup the imap integration with your Gmail and in config file and add folder: Notes line at the end of it so it only scans for that specific folder.

Before you can give siri commands you need to enable google notes on ios in settings/notes/accounts and then set google notes as default in settings/notes/default account. Same goes for MacOS if you use Siri there.

This is the automation code


alias: Siri automation
description: ''
trigger:
  - platform: template
    value_template: |-
      {{

      true if 
      states('sensor.my_gmail_com')|
      regex_search("(?:^|(?<= ))(light|)(?:(?= )|$)",
      ignorecase=True )
      and
      states('sensor.my_gmail_com')|
      regex_search("(?:^|(?<= ))(off|)(?:(?= )|$)",
      ignorecase=True ) 
      and 
      states('sensor.my_gmail_com')|
      regex_search("(?:^|(?<= ))(living|)(?:(?= )|$)",
      ignorecase=True )
      else false

      }}
condition: []
action:
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.living_room
mode: single

As you can see there are 3 keywords inside the regex code , light, off, living ,
those 3 are the trigger words so no matter the letter case and no matter how the words are organized, if those 3 are present in that note you’ve said to Siri, the automation will be triggered.

All you got to say is hey siri, note (and then your command with all trigger words you’ve setup in automation )
example :
Hey Siri! Note Turn off the light in my living room.
This will activate the automation as all trigger words have been mentioned and my light will be turned off.
If you don’t have an apple home hub using HomeKit Siri commands when not at home is impossible, this workaround makes it possible to use Siri away from your home and your HA.
Have fun