Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DoorBell trigger the "IDENTIFY" of a lamp (go bright -> dark -> back to last brightness) possible? #219

Closed
StefanMeGit opened this issue Nov 22, 2017 · 7 comments
Labels

Comments

@StefanMeGit
Copy link

I am searching for a possibility to visualize my doorbell.

I installed an homebridge input as an motion sensor to create a trigger when my doorbell rings... works perfect. Now i want to let my lights go bright to 100% and go back to brightness before.

If i push on "identify" in the original HUE app, the light goes to 100%->0-> and back to the brightness like before.
The "identify" command would be perfect for this! Is there any possibility to trigger this event?

@ebaauw
Copy link
Owner

ebaauw commented Nov 24, 2017

When you select Identify in the Hue app, it sends a PUT of {"alert":"select"} to light state resource (/lights/xx/state) on the Hue bridge. homebridge-hue does the same, when you select the Identify characteristic of the Accessory Information service of the LightBulb accessory.

Apple's Home app doesn't display the Identify characteristic, and only uses it when the accessory is paired. Other HomeKit apps, like Eve do show it. As far as I know, it's not possible to include this characteristic in a HomeKit scene, or select it in a HomeKit action. So the only way to issue an identify would be from a rule on the Hue bridge.

Assuming the motion sensor is connected to HomeKit directly (not through the Hue bridge), you need to create a CLIPGenericFlag sensor on the Hue bridge (exposed as a switch to HomeKit by homebridge-hue) to bridge both worlds. You then create a HomeKit automation to set the flag when the motion sensor is triggered, and a Hue bridge rule to send the alert when the flag is set.

@StefanMeGit
Copy link
Author

Yes, the "Motion Sensor" is connected via homebridge-hc-sr501 plugin and is just a simulated one. It uses an relay and an input of an RPI3 to get triggered. Works perfectly fine. BUT after that i use an IFTTT script to "blink" a few lights in the apartment. The problem now is... it blinks 15 times. 1 to 5 time would be perfect.

So if i understand u correctly, i have to create this... lets call it "action" in the homebridge-hue plugin to make the blink. The CLIPGenericFlag?

@ebaauw
Copy link
Owner

ebaauw commented Nov 24, 2017

The CLIPGenericFlag?

A CLIP sensor is like a variable on the Hue bridge, that can be set (and read) from the outside, and used in bridge rules. homebridge-hue exposes these to HomeKit, so they’re perfect to link HomeKit automations to Hue bridge rules. For example, I use my Hue motion sensor to set a flag that some-one is in the room, then, based on that flag, I switch on the lights (when it’s dark) using Hue bridge rules, and I switch on my Sonos speakers (through homebridge-zp) using HomeKit automation.

i have to create this... lets call it "action" in the homebridge-hue plugin to make the blink

You create the CLIP sensor and the bridge rule throught the Hue API, see https://developers.meethue.com/documentation/getting-started. All homebridge-hue does is expose the CLIPGenericFlag sensor on the Hue bridge to HomeKit.

@StefanMeGit
Copy link
Author

StefanMeGit commented Nov 25, 2017

Ok, i think i got it now... or the first part of it.

I have to create an CLIPGenericFlag in the hue bridge over web interface:
https://developers.meethue.com/documentation/supported-sensors

then i expose all the sensors (including the new created CLIPGenericFlag) to HomeKit with homebridge-hue.

BUT: So i can trigger the CLIPGenericFlag with an automation when my doorbell rings. But whats the next step? I have to create an rule i a thrid party app like eve to make my lights blinking when sensor is triggered? Or can i include the the part directly inside the CLIPGenericFlag?

Address | http://<bridge ip address>/api/1028d66426293e821ecfd9ef1a0731df/lights/1/state
-- | --
Body | {"alert":"none"}
Method | PUT

@ebaauw
Copy link
Owner

ebaauw commented Nov 25, 2017

You need to do a POST to /api/username/sensors using the CLIP API debugger with a body of something like:

{
  "manufacturername": "homebridge-hue",
  "modelid": "CLIPGenericFlag",
  "name": "Motion Sensor Flag",
  "swversion": "1",
  "type": "CLIPGenericFlag",
  "uniqueid": "Motion Sensor Flag"
}

This will create a /sensors/xx resource on the Hue bridge.

Next, create a rule to flash the light and reset the sensor when the sensor is set, i.e. POST to /api/username/rules with a body like:

{
  "name": "Alert on motion",
  "conditions": [
    {
      "address": "/sensors/xx/state/flag",
      "operator": "eq",
      "value": "true"
    }
  ],
  "actions": [
    {
      "address": "/lights/1/state",
      "body": {
        "alert": "select"
      },
      "method": "PUT"
    },
    {
      "address": "/sensors/xx/state",
      "body": {
        "flag": false
      },
      "method": "PUT"
    }
  ]
}

Note that the value in the condition always is a string, whereas the body in the action is the actual json value. Test that the rules works as indented by a PUT to /api/username/sensors/xx/state of

{ "flag": true }

The light should flash, and the sensor state.flag should be reset to false.

(If by now, you're as annoyed by the CLIP API debugger as I am, check out https://github.com/ebaauw/ph.sh)

Next, you add "sensors": true to your config.json and restart homebridge. Now, the sensors are exposed to HomeKit, and you should see a switch corresponding to the CLIPGenericFlag you just created. Flip the switch from your favourite HomeKit app (or ask Siri) and check that the light flashes and the switch turns off again. If needed, check the output of homebridge -D to see what's going on.

You might get (a lot) more new accessories than you bargained for, depending on how many sensor resources the Hue bridge already has (many apps create companion CLIP sensors for routines and sensor/switch rules). Use "excludeSensorTypes" in config.json to prevent homebridge-hue from exposing the unwanted types (see https://github.com/ebaauw/homebridge-hue/wiki/Configuration) and/or a blacklist resourceitem to exclude unwanted (other) CLIPGenericFlag sensors (see #170 (comment)).

Next, you can create a HomeKit scene which sets the switch and create a HomeKit automation to recall this scene when your motion sensor detects motion.

@StefanMeGit
Copy link
Author

Thank u so much! Now i understand the system. Very powerfull! I tried some things and all work very nicely. If u ring now on my doorbell, it triggers the homebridge motion sensor and this will trigger an "alert:select" on a few lights.
I also created an second automation that triggerns the "select" a second time when the first trigger is set back. But this is only working a few times... depend on the heartrate and response from the HUE. Sometimes the the CLIPGenericFlag in homekit is allready set to false but the animation is still ongoing.

You have an idea how to trigger it twice?
The only idea i have is to create an output with an off delay from 2 sedonds (over homebridge-wpi2), trigger it parallel to the CLIPGenericFlag and trigger the an second CLIPGenericFlag when the ouput goes OFF. Looks a bit clunky

@ebaauw
Copy link
Owner

ebaauw commented Nov 27, 2017

Just leave the HomeKit bit. On the bridge, create a second rule with an added ddx condition on the flag sensor’s state.lastupdated and only reset the flag in the second rule. See ph_rules.sh in the ph.sh repository for some examples how to use ddx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants