Aeotek Multisensor 6: Google Home Alerts When Movement Detected

Hi Guys,

I have a couple of Aeotek Multisensor 6 units, connected via Z-wave to my Vera Edge Hub.

I’ve configured (more accurately, still configuring) my front end to look nice showing all the stats (temp, humidity, etc) for each location.

The next thing I would like to do is to have either a specific Google Home (or mini) unit give a verbal announcement (eg “Someone is at the front door”) when movement is detected from a specific unit.

Therefore the requirement would need to be:

  • Have a specific Aeotek Multisensor 6 unit selected;
  • Have a specific response;
  • Ideally being able to select which GH/GHM does the alerting.

The reasoning behind this is that there was one night when I woke up at 2am due to the noise of freight trains (the track is about 1km away over open field so noise travels at night quite easily) and I got up to close the bedroom window. The outdoor lights were on (activated by a sensor) and as I went to close my window, 2 guys were walking right past. Due to the layout of my front yard (we’re about 16m back from the footpath), there’s no reason to be anywhere near the house if just walking past.

So, I would like the bedroom GHM to give me a verbal notification if the Aeotek Multisensor 6 I’ve just put above the front door (or the one over the back door) detects movement as the exterior lights coming on won’t wake me. This is also why a specific message for each unit would be nice so it could say “front door” or “back door” so I know which unit was tripped.

Is this possible?

Thanks in advance.

Hi MadMAx12,

I have something similar running at home if I have correctly understood your requirements. A word of warning flys and spiders on PIRs can cause panic in the middle of the night ask my wife lol. If you need any further explanation on the configuration below let me know.

  - alias: Front Door Motion Detected
    trigger:
      - platform: state
        entity_id: sensor.front_door_motion
        from: 'None'
        to: 'Detected'
    condition:
      - condition: state
        entity_id: input_boolean.window_door_notifications
        state: 'on'
      - condition: state
        entity_id: sensor.front_door
        state: 'Closed'
      - condition: state
        entity_id: binary_sensor.ring_front_door_motion
        state: 'on'
# Text to Speech
    action:
      - service: notify.google_assistant
        data:
          message: "Motion Detected At The Front Door"
# Kodi Machines Notifications
      - service: notify.all_kodi
        data:
          title: "Home"
          message: "Motion Detected At The Front Door"
          data:
            displaytime: 20000
            icon: "warning"  
# LG TVS          
      - service: notify.lg_tvs
        data:
          message: "Motion Detected At The Front Door"

Hi J_IO_B

I have never done any programming before but from what I can see is that:

  • you have your condition at the top (sensor changed from not triggered to triggered),
  • You have an entity_Id for the notification itself (input_boolean.window_door_notifications)
  • You have an entity_id for the sensor involved which in my case would be the motion sensor of the particular Aeotek unit (sensor.front_door)
  • You have an entity_id for when the Aeotek sensor is tripped (binary_sensor.ring_front_door_motion)
  • You then have a warning transmitted to your Google Assistant, your Kodi and your LG TV, which in my case would be just the one particular GH unit.

Does this go into the Configuration.yaml file?

Do you have a link to some beginner’s tutorial for this type of coding? That way I can learn what I need to change, and what to change it to, to suit my needs?

It looks very promising.

Thanks in advance.

Have you read any if the basic documentation at all?

An automation needs 2 things to work at its most basic:

A trigger and an action. You can also be a little more discerning on when it runs by putting in conditions

The functions of those three things are fairly self explanatory.

The trigger is the thing (or things) that starts the automation running. The triggers are all ‘or’. Meaning if any of the triggers become true then the automation will run.

The conditions are things that have to be satisfied in order for the automation to run but they aren’t used to actually start the automation. The conditions can all be true but the automation won’t run unless the trigger is true. The conditions are ‘and’ by default which means that all the conditions gave to be true to allow the automation to run. Or you can make them ‘or’ which means that any condition can be true for it to run.

The action is what you want it to do when it runs. The actions can be many different things and are too extensive to cover in a post. But basically everything in an action will be done when the trigger becomes true and the conditions are satisfied.

Now with that info read the example above and see if can figure out what is going on.

As I wrote, I’ve never done any programming before. I then wrote at the end asking if there was a link to a beginner’s tutorial for this type of coding. I don’t know the best words to use in a search (eg “programming”, “Coding”, “HA”) - in other words not sure where to start looking.

I tried my best with my lack of knowledge and I thought my summary of what I thought I was reading was close.

I could see the condition (sensor being triggered) and the actions of the warnings being sent to LG TV’s etc. I just mis-interpreted the others.

So in summary, to me the “script” basically says: “If the Front Door Motion Sensor is tripped (goes from none to detected), and we have the Notifications turned on, and the front door is currently closed and the motion sensor for the front door is on, then send a message (motion detected at the front door) to Google Assistant, Kodi machines and the LG TV’s.”

I don’t expect anyone to write my code for me. I was just asking firstly if they thought it was possible, and if so, provide links so I could learn. I’m just so new at this that I don’t know where to start or even where to start looking (what to actually google to get accurate responses).

Are these called “Scripts” and if so, do they go in the “Scripts.yaml” file or do we just put them in the configuration.yaml file? Edit: Nevermind. I did a big of digging around and it seems that it goes in the configuration.yaml file.

Sorry if I offended anyone by my newbie questioning.

Regards

Max

I wasn’t offended. I was just asking a straightforward question. I just wanted to know if you had read any of the documentation on the Home Assistant website itself

Yes, that’s correct.

the proper terminology for what is posted in the above example is called an “automation” not a “script”. While those two things are closely related there is a difference - a script doesn’t use a trigger. It just runs a series of actions when told to run. Which is normally done by using an automation.

So the sequence of events is:

write an automation which contains a trigger, an action and (optionally) condition.

In the action section you can specify things you want the automation to do. That can also include telling a script to run.

then you will also then write a script with a sequence of events you want the script to perform.

NOTE: You don’t have to put your actions into a script. All of the actions can likely be done using the automation alone. However, there are some things you will have to run in a script.

Lastly, EVERYTHING you add to HA goes in the configuration.yaml file (unless it doesn’t…but that’s more advanced stuff that you don’t need to worry with yet).

There are lot’s of examples of people’s configurations at the above automations page by following the link there.

Hi

Apologies for the delay. Been very busy at work and when I did have free time, I had projects at home to work on.

Anyway, I’ve added an automation to my configuration.yaml file and Yamllint says it’s ok, but when I test it doesn’t do anything.

I’m not sure if it’s the condition that isn’t configured correctly or the action. I haven’t set a condition.

The following is what is in my configuration.yaml file:

automation:

  • alias: ‘Someone At The Front Door’
    trigger:
    • platform: state
      entity_id: switch.front_door_15
      from: ‘false’
      to: ‘true’

    Text to Speech

    action:
    • service: tts.google_say
      entity_id: media_player.living_room_mini
      data:
      message: ‘Motion Detected At The Front Door’

The device (my front door 6-in-one sensor) has the motion detection part entity id of switch.front_door_15. Here’s a screenshot

The part that I’m confused about is the entity state page shows that the trigger is when device_tripped becomes true, but I’m not sure how I write it so it knows that AND the device. I based it on J_IO_B’s reply above where that example read as:

  • alias: Front Door Motion Detected
    trigger:
    - platform: state
    entity_id: sensor.front_door_motion
    from: ‘None’
    to: ‘Detected’

Do I change the entity_id to something which describes both the unit (front door motion sensor) and the state eg sensor.front_door_motion:device_tripped??

As for the Action part, I followed this page so I think that’s ok.

Thanks in advance.

Does the switch change states from on to off (or vice versa) when the motion sensor detects motion?

Also try to format your code correctly so we can see the exact format as it is in you config. See the blue box at the top if the page.

Looking at the entities on my mobile, the entity called “switch.front_door_15” shows a state of “on” meaning that motion sensing is active.

It’s when you click on the link to the left (looks like a rectangle with an arrow in the corner) and it shows “sub-levels”.

One of these is “device tripped” which is “false” if it hasn’t detected motion recently and “true” if it does detect motion.

Will update thread when I get home and have access to configuration.yaml file.

edit:

automation: 
  - alias: 'Someone At The Front Door'
    trigger:
      - platform: state
        entity_id: switch.front_door_15
        from: 'false'
        to: 'true'
    # Text to Speech
    action:
      - service: tts.google_say
        entity_id: media_player.living_room_mini
        data:
          message: 'Motion Detected At The Front Door'

For your trigger try:

trigger:
    platform: template
    value_template: "{% if 'states.switch.front_door_15.attributes.device_tripped', 'True') %}true{% endif %}"

Thanks for the suggestion. Unfortunately it didn’t work.

automation: 
  - alias: 'Someone At The Front Door'
    trigger:
      platform: template
      value_template: "{% if 'states.switch.front_door_15.attributes.device_tripped', 'True') %}true{% endif %}"
    # Text to Speech
    action:
      - service: tts.google_say
        entity_id: media_player.living_room_mini
        data:
          message: 'Motion Detected At The Front Door'

On the Overview tab of my web front end, there’s a message about an Config Validation error. When I go to it, it reads:

Invalid config for [automation]: invalid template (TemplateSyntaxError: unexpected ‘)’) for dictionary value @ data[‘trigger’][0][‘value_template’]. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 197). Please check the docs at Automation - Home Assistant

Line 197 is where it says “automation:”

Given the message, I gather that it’s because there’s a missing open bracket ( in the value_template line, so I tried adding one in front of if ‘states.switch.front_door_15.attributes.device_tripped’, restarted the services but get the same error.

Cheers and thanks

Max

Yeah, I see the issue. Its because I accidentally stuck an extra “)” after the first “True”. Try removing that.

That’s what the error code is telling you.

Edit: on second thought I think you may actually need to add a ( to the beginning of the entity declaration.

…('states…

Try it both ways and see which one works (hopefully…)

I tried this first and it works like a charm. Thanks so much.

I gather I can have multiple automations using the same action. I probably will copy all of the current automation section, paste it back in and add in my bedroom mini as I want to be woken up if people are coming up to the door in the middle of the night (some homes have been burgled in the past) as the sensor light coming on won’t wake me.

Later on I might experiment on time based announcements where it does all my minis in the house during the day and early evening as a sort of early doorbell.

I’ve only been using Hassbian for a short while but very happy with what it can do. Ironically, whilst doing this project for movement detection, I received an email advertising a product called Homey SmartHome Controller and part of it’s blurb was showing a simple gui using this 6-in-1 sensor and having it do things if movement was detected during certain times. :grinning:

Once again, thank you.

I’m glad I could help you get it going.

Yes you can have multiple automations that result in the same action. Or, better yet, you could have one automation with multiple triggers for the same action. That would work much cleaner as long as the conditions for the automations would coincide.

Not sure why but it’s very hit-and-miss.

Yesterday I was home, sitting in the loungeroom next to the Google Mini waiting for my daughter to come home from school. She came in through the front door, yet the GM didn’t make a peep.

I opened the screen door again which would activate the motion sensor and still didn’t hear anything. Loaded up the interface on my mobile, turned the automation off and back on and it tested fine.

Today I tested it again and it’s not working, although 10 minutes later as I was passing by my daughter, she said the GM did eventually make the announcement.

I did a final test where I walked out the front door whilst watching the Hassbian front end on my mobile and saw the patio motion sensor change from “off” to “on” but once again, no announcement.

Not sure where the issue is. I don’t have a Z-wave USB stick in the Raspberry Pi. My Z-wave devices are connected to a Vera Edge. Looking at the Vera app, it’s dashboard is showing when the various motion sensors (Patio, kitchen, entertainment area) are tripped.

I’ll look into “nested” actions and perhaps get it to also (in addition to making the announcement), turn on my Xiaomi Yeelight (called light.yeelight_bedside_7811dc9201bd under “states”) to see if the light comes on and the announcement still doesn’t play.

Before doing that, and even though it tested fine before, can I just confirm the formatting, mainly the white spaces, is correct?

automation: 
  - alias: 'Someone At The Front Door'
    trigger:
      platform: template
      value_template: "{% if ('states.switch.front_door_15.attributes.device_tripped', 'True') %}true{% endif %}"
    # Text to Speech
    action:
      - service: tts.google_say
        entity_id: media_player.living_room_mini
        data:
          message: 'Motion Detected At The Front Door'

The part I want to confirm is ok, is how we have the trigger and action starting at the same indented space, but under action, the word “service” (and entity_id and data) are not at the same indented spot as the word “platform” under “trigger”. Does this make a difference?

Thanks

Edit:

Based on https://www.home-assistant.io/docs/automation/action/ page, I added a section to turn on the bedside light.

automation: 
  - alias: 'Someone At The Front Door'
    trigger:
      platform: template
      value_template: "{% if ('states.switch.front_door_15.attributes.device_tripped', 'True') %}true{% endif %}"
    # Text to Speech
    action:
      - service: tts.google_say
        entity_id: media_player.living_room_mini
        data:
          message: 'Motion Detected At The Front Door'
    # Bedroom Light On - Red at Full Brightness
      - service: light.turn_on
        data:
          brightness: 100%
          rgb_color: [255, 0, 0]
          entity_id: 
            - light.yeelight_bedside_7811dc9201bd      

I noticed they have data line(s) before the entity_id line so that’s what I tried. When I tested the script at yamllint.com it said it was valid, but field testing had the GH saying making the announcement but the lamp didn’t come on.

A couple of things:

  1. try changing the ‘True’ in the trigger template to ‘true’. Case matters.

  2. what does your patio motion sensor have to do with whether or not the automation work? You’re triggering off the front door. Are those two things the same thing but you are just referencing them here differently?

  3. It’s strange that it worked once but not every time or that the announcement was delayed. Are you sure she actually heard the announcement? It could make a difference on how to troubleshoot.

  4. the indentations all look OK to me the “-” in front of the “service” is interpreted as being the first character so it goes by that for the syntax.

  5. you can test that the action part is correct by clicking on the automation in the frontend and click the “trigger” button. If that works you know the action portion is OK.

  6. copy the template from the trigger section and paste it into the template editor in HA and see if the value on the right side shows ‘True’. If it does then you know the trigger template is OK.

As I look at your template it might not be correct. Try:

{% if (states.switch.front_door_15.attributes.device_tripped == true) %}true{% endif %}"

and I think you can also just simplify it even more:

“{{ states.switch.front_door_15.attributes.device_tripped }}”

Those statements should evaluate to true or false.

Try either or both and see if it works. I tested them with one of my entities and they both worked and returned “True”.

Since I’m standing inside (when testing), opening the front screen door (which opens outwards) will trigger the patio motion detector which is located above the screen door looking down at where visitors would stand when they knock at the door.

Yes, I agree.

Yes, she’s 10 and very responsible. The front door opens onto our hallway which is open plan to our living room. Our Google Home Mini (GHM) is on a coffee table next to the lounge which is against the front wall. In other words, standing just inside the door and I’m only a few feet away from the GHM, so we can definitely hear it if it made the announcement during the testing.

I had done the test and even asked my daughter if she heard anything just in case my ears failed me :smile: as she was sitting right next to it and she said it didn’t. I went off to do a few things and the next time I went past, she said that it made the announcement. I confirmed with her that she wasn’t joking and she assured me she wasn’t. She suggested maybe someone came up to the patio, but it’s highly unlikely as we are on a quiet street and we don’t get many visitors, so I’m pretty confident that it would have been a delayed transmission.

fixed.

Yes, it made the announcement.

I copied:

trigger:
      platform: template
      value_template: "{% if ('states.switch.front_door_15.attributes.device_tripped', 'true') %}true{% endif %}"

onto the left hand side and the right hand side came up as:

trigger:
      platform: template
      value_template: "true"

Since the action tested ok and the trigger tested ok, I just went out the front door, once again watching the HA front end on my mobile change “Front Patio Motion” from “Off” to “On” and nothing.

Ok, I tried this (I put a quotation mark in from of the open { at the start as we were missing one) but testing didn’t get a response from GHM.

So mine read:

automation: 
  - alias: 'Someone At The Front Door'
    trigger:
      platform: template
      value_template: "{% if (states.switch.front_door_15.attributes.device_tripped == true) %}true{% endif %}"
    # Text to Speech
    action:
      - service: tts.google_say
        entity_id: media_player.living_room_mini
        data:
          message: 'Motion Detected At The Front Door'

Next I tried:

So mine now reads:

automation: 
  - alias: 'Someone At The Front Door'
    trigger:
      platform: template
      value_template: “{{ states.switch.front_door_15.attributes.device_tripped }}”
    # Text to Speech
    action:
      - service: tts.google_say
        entity_id: media_player.living_room_mini
        data:
          message: 'Motion Detected At The Front Door'

Result - Nothing from GHM.

When I put it into the trigger tester (whilst Front Patio Motion shows “on” ie tripped = true), it comes back:

trigger:
      platform: template
      value_template: “True”

I waited until Front Patio Motion shows as “off” (ie tripped = false), and it comes back:

trigger:
platform: template
value_template: “False”

I tested the trigger again in the front end (I’m sitting at a PC in a room at the back of the house) and went to the living room and my daughter said it played.

So it looks like the trigger and action are both working when tested manually, but not in “real life”.

Cheers

there is one more thing you can try…

The double quotes you used in the last snippet above are strange looking. try to delete those from the code and then re-type them as single quotes in your text editor.

So it looks like this:

'{{ states.switch.front_door_15.attributes.device_tripped }}'

But DON’T copy & paste. just re-type manually those two quote marks.

Sometimes copy and paste (if that’s what you did) will end up giving strange results depending on the format the original characters were originally typed.

If you didn’t copy & paste then make sure you are using a plain text editor to edit your code. Other rich-text editors do fancy things with the text that breaks the format that HA is looking for to work correctly.

That’s the only thing I can think to try since you said the trigger and action both work manually and separately.

This seems to have fixed it. I did the change this morning before I went out and it tested fine. When I came back I tested it twice and both times it made the announcement. It must have been the quotation marks.

I use Notepad++

Thanks for all your help.

Ok, well it’s been working well and I found some time to sit down and tweak it to the way I want.

My objective was to have the message play on the living room Google Home Mini (GHM) and the master bedroom GHM at night between 8pm and 8am, then play on all my GHM’s throughout the house during the period 8am to 8pm.

I went into the Google Home app and created 2 groups of speakers - Nighttime_doorbell and Whole_house_doorbell. These appeared in Hassbian as expected.

I’ve updated my configuration.yaml file as follows and it works, but I was just curious as to whether there was a neater way.

automation: 
  - alias: 'Someone At The Front Door'
    trigger:
      platform: template
      value_template: '{{states.switch.front_door_15.attributes.device_tripped}}'
    # The Condition Syntax from https://www.home-assistant.io/docs/scripts/conditions/
    condition:
      condition: time
      # At least one of the following is required.
      after: '08:00:00'
      before: '20:00:00'
      # Text to Speech
    action:
      - service: tts.google_say
        entity_id: media_player.whole_house_doorbell
        data:
          message: 'Motion Detected At The Front Door'
    # Bedroom Light On - Red at Full Brightness
      - service: light.turn_on
        entity_id: light.yeelight_bedside_7811dc9201bd 
#         data:
#           brightness: 100%
#           rgb_color: [255, 0, 0]
#            color_name = 'white'
    trigger:
      platform: template
      value_template: '{{states.switch.front_door_15.attributes.device_tripped}}'
    # The Condition Syntax from https://www.home-assistant.io/docs/scripts/conditions/
    condition:
      condition: time
      # At least one of the following is required.
      after: '20:00:00'
      before: '08:00:00'
      # Text to Speech
    action:
      - service: tts.google_say
        entity_id: media_player.nighttime_doorbell
        data:
          message: 'Motion Detected At The Front Door'
    # Bedroom Light On - Red at Full Brightness
      - service: light.turn_on
        entity_id: light.yeelight_bedside_7811dc9201bd 
#         data:
#           brightness: 100%
#           rgb_color: [255, 0, 0]           

The other thing I’m tinkering with is the brightness level and colour of the Yeelight Bedside lamp.

I found a helpfile that talked about changing colour of LED’s by using the following:

data:
  brightness: 100%
  rgb_color: [255, 0, 0]  

But that didn’t work. It bought up error messages so that’s why it’s hashed out. Perhaps the “data” has to go before the “entity_id” line???

I also found a reference to using:

color_name = 'white'

but that also seem to cause error messages.

It’s not a biggie if I can’t configure it to change the colour or brightness. Just wanting to learn what I can do.

In the meantime, I’ll continue playing with weather icons and doing a Lovelace interface. I’m enjoying tinkering, just wish I had more time for it.