[Tutorial]: Adding your Google Nest Protect to Homey

Starting Off


One of the things that has bothered me quite severely, is that I was not able to get my Google Nest Protect (Smoke alarm) into Homey. This isn’t necessarily Homey’s fault. It’s just Google being Google, and they love refusing to make Local API’s available for their devices.

After a bit of digging, I figured out a way to let me add the smoke detector towards my Homey. Or well… I created a device, thanks to the Advanced Virtual Devices app. This in conjunction with the Google Scripting interface, allows you to trigger a flow in Homey to set the smoke alarm towards true or false, based on the state of the alarm.

Kind Reminder & Warning: Remember that your smoke alarm is a security device. Never trust solely on your home automation to protect your house.

That being said. Let’s get going!

Prerequisites


  • You need to make sure that your Nest Protect is connected towards the Google Nest app. You can download this from your favorite App Store. I won’t go into too much detail on how to do this, as there are other tutorials for that.
  • You need to have the Device Capabilities app installed on your Homey.
  • Your Homey needs to be connected towards Google Assistant.
  • The set-up needs to be done via a computer, as it’s absolutely cumbersome (and I don’t think it’s even possible) to set-up this project on a mobile device.

Installation

Homey

Setting up the Advanced Virtual Device


  1. To setup the AVD, add a new device in Homey and click on Device Capabilities and choose the device Advanced Virtual Device.
  2. Create an empty AVD, set-up a name for your smoke alarm and choose an icon.
  3. On your Homey Devices dashboard, right-click on your newly created AVD and press “Repair”.
  4. The device properties opens. Choose Sensor as a device class.
  5. Create a new Yes/No field and give it a name for your smoke status. Something like Smoke Detected or in my case Rook.
  6. Make sure that Show As is set-up as Smoke Alarm, and click on Create real fields and flow cards.
  7. Save your device.

This finishes your AVD and you’ve created a virtual smoke alarm which won’t do much for now, but that’s what we’ll be creating flows for.

Creating the flows


In this section we’ll be creating a flow that will set the Yes/No field in your AVD to true if smoke is detected or to false if smoke is no longer detected.

  1. Create a simple flow. This will be the flow to detect smoke.
  2. Select When this flow is started as the If condition.
  3. In the Then section, select your newly created AVD and choose the flow card Set Yes/No field to Yes/No and Do Nothing.
  4. Make sure your Yes/No field is selected and select Yes and Do Nothing as a value. This will give you a flow card like such:
  5. Test your flow by clicking on Test. Homey will sent a notification to your devices to warn you that the smoke alarm has triggered.
  6. Click on Save.
  7. Duplicate the flow and create another flow to disable the smoke alarm. Just place your Yes/No value to No.
  8. Test the flow again. Homey will send a notification that there’s no longer any smoke detected.

You might wonder that this is very nice and all, but in this sense we really need to manually trigger the flows. However, we can favorite both flows, which in turn will send the flows towards Google Home. They show up in Google Home as a “Scene”, making it possible to “Activate” the scene in Google Home. This in turn runs the Smoke Detected/No Smoke Detected flows, respectively.

The most important part of this last piece of text is that you need to Favorite both Homey Flows. They will show up in your favorite flows, but will also go to Google Home.

Google Home

Setting up Google Home


To make sure that your flows turn up into Google Home you need to take some actions to get them into Google Home. So grab your mobile device and open the Google Home app. Then:

  1. Go to Settings
  2. Click on Works With Google under Services
  3. Click on Homey and press Check for new devices.

Your flows will now be loaded in and you will be able to use them in the script editor from Google.

Creating the scripts

Now for the actual magic. Go back to your computer and follow these steps.

  1. Go to Google Home On Web
  2. On the page click on Automations.
  3. In the bottom right click on Add New

This will bring you in the script editor. Paste the following script and replace the commented fields with your devices.

Script for Smoke Alarm Firing:

metadata:
  name: Brandalarm Gaat Af
  description: Bandalarm Gaat Af
automations:
  - starters:
      - type: device.state.SensorState
        device: Nachthal - Nachthal # Your Nest Protect Device.
        state: currentSensorStateData.SmokeLevel.currentSensorState
        is: high
      - type: device.state.SensorState
        device: Nachthal - Nachthal
        state: currentSensorStateData.SmokeLevel.currentSensorState
        is: smoke detected
    actions:
      - type: device.command.ActivateScene
        activate: true
        devices: Flow Nachthal - Rook Gedetecteerd # Your created flow when smoke is detected.

Script for Smoke Alarm Cleared:

metadata:
  name: Brandalarm Gaat Uit
  description: Bandalarm Gaat Uit
automations:
  - starters:
      - type: device.state.SensorState 
        device: Nachthal - Nachthal # Your Nest Protect Device.
        state: currentSensorStateData.SmokeLevel.currentSensorState
        is: no smoke detected
    actions:
      - type: device.command.ActivateScene
        activate: true
        devices: Flow Nachthal - Rook Trekt Op # Your created flow when smoke has cleared.

Finishing Up


Voila. And now you’ve set-up a virtual smoke alarm that gets its input from Google Home.
Try out the smoke alarm by holding a lighter under it or a candle (don’t drop it, don’t burn yourself).

Hopefully you thought this was useful. It’s my way of finally being able to give something back towards the community.

All the best!

B

8 Likes

Moved this towards the Tutorial section. As it’s a tutorial. Obviously.

Hi @Herazio.

It would be awesome if I get this to work.

I will try this tomorrow but I have already a question.

Will this also work for the battery operated ones?

Rogier

Yep! I actually use those myself. The Protects (No matter battery or AC operated) are registered towards the Google Home cloud. You should normally be able to see them in the script editor.

Happy coding!

Hi @Herazio,

It works. Can’t wait to set my house on :fire: for the ultimate test :rofl:

Great tutorial.

Thanks a lot.

2 Likes

Just a quick FYI. I tested the flow today with an actual live test and I saw that my Homey didn’t react towards the change of state. I found out that there’s some debug tools in Google Home and they showed me this when the alarm was sounding:

[INFO] Automatisering gestart door: [apparaat niet gevonden] vanwege [home.graph.traits.SensorState/current_sensor_state_data[0].current_sensor_state] [string_value: "high"].

So it seems that the state, whenever a smoke alarm sounds is not “smoke detected”, rather “high”. So I adjusted the script and now it seems to work fine. Also adjusted the original post:

metadata:
  name: Brandalarm Gaat Af
  description: Bandalarm Gaat Af
automations:
  - starters:
      - type: device.state.SensorState
        device: Nachthal - Nachthal
        state: currentSensorStateData.SmokeLevel.currentSensorState
        is: high
      - type: device.state.SensorState
        device: Nachthal - Nachthal
        state: currentSensorStateData.SmokeLevel.currentSensorState
        is: smoke detected
    actions:
      - type: device.command.ActivateScene # Activate or deactivate a scene. # Activate or deactivate a scene.
        # <code>false</code> to cancel a scene if it is reversible, <code>true</code> to activate a scene.
        activate: true
        devices: Flow Nachthal - Rook Gedetecteerd

Thanks. I will change that tomorrow.

Fyi, one time I saw that the state on one of my AVD buttons on my tablet was ‘active’ (red dot with exclamation mark) while at the same time on my phone it wasn’t.

Rogier

This doesn’t work…my google home can’t find the virtual smoke detector

Good work. I will give this a try.

One question though. What is the benefit of having smoke alarms connected to Homey? I mean the Nest Protect App will let you know if one of the sensors becomes active, even if you are away from home.

That all depends on what other devices you have connected to Homey. But a few things I can think of are:

  • Turing on the lights on your escape route
  • Unlocking the door (if you are home)
  • Playing sound through speakers
  • Controlling your AC or ventilation to stop feeding additional oxygen to a potential fire

Of course all this depends on power being available

Thanks. I have implemented the lights idea,. The others are good ideas also but I don’t yet have the capabilities.

Nice tutorial, but the two favorite flows in Homey, do not show up in my Google Home.
Not even after a “Sync all my devices” command for Google Home.

H-uh you know I’ve never thought of this idea since I use hue motion sensors upstairs, but that’s actually a pretty cool idea. Had a look at it in the Google Script Editor and I saw that it can trigger an event for when motion is detected. The only problem is that I didn’t find any event that would tell Homey that motion was no longer detected, which is a bit of a bummer.

I guess you could work around it by maybe using Chronograph so that when you start the flow a timer gets started for motion detection (let’s say 30 seconds). Should any other motion then still be detected, the flow would get restarted and your timer would reset itself so that the state of motion remains on detected. If no more motion is detected, your timer would expire and a flow that runs with the trigger “when timer finishes” could put the state back on “Motion: False”.

I haven’t had the time to try this out yet, and even if my logic is correct. But I’m trying to think with you on how to tackle this case :smiley:

2 Likes

How did you get Ajax in Homey?

Hi @MichelB91

Ajax and Homey are making an app as we speak. They think it will be ready end of Q1

But I have it running differently for 1,5 years now.

But please use topic below.

Rogier

1 Like