NRCHKB / node-red-contrib-homekit-bridged

Node-RED Contribution - HomeKit Bridged : Node-RED nodes to simulate Apple HomeKit devices.
https://nrchkb.github.io
MIT License
413 stars 52 forks source link

Using Valve for HomeKit Automation #247

Closed P1Rebo closed 4 years ago

P1Rebo commented 4 years ago

Dear contributors, first of all many thanks for providing this library. It seamlessly combines Node-Red with the Apple device and ecosystem possibilities. I just notice this behaviour, maybe it's a bug or a feature. I've tried to create an automation based on a Valve object, e.g. to enable an irrigation sequence based on an event. In the Home App I can only select e.g. light bulbs / switches as objects to control. Am I doing something wrong / missing any parametrization? Thanks a lot in advance, and continue this great work!

Shaquu commented 4 years ago

Hi there, I am happy to see new faces here :) Surely it’s about configuration.

I am calling our Master Sprinkler @crxporter

crxporter commented 4 years ago

@P1Rebo - SHORT ANSWER: your comment is consistent with what I see.

LONG ANSWER:

Item types I have in my home app:

The Home app limits what you can actually automate. If I go to "scenes" or "automations" the list gets a little shorter. The sprinkler (valve) items can't be controlled over automations. The only sensors that appear are motions (humidity/light/temp can't trigger automations). Cameras don't have any automation options.

But that's not the end of automations in the home app! When you make a scene or automation or action for a StatelessProgrammableSwitch then you can scroll all the way to the bottom and click "convert to shortcut" - you'll see more options now. You don't get more things to automate but you can automate based on if your sprinklers are turned on or only turn on the lights if your light sensor is below a certain value...

This still doesn't help with your sprinklers! If I may ask, what did you have in mind here? What kind of automation are you thinking? How are the sprinklers connected?

Currently things like "hey siri turn on the back sprinklers for 5 minutes" works great for me. I'm using opensprinkler - I have a "master valve" that if turned on runs a whole program.

If you want to get fancy and run an automation from homekit then you can use siri shortcuts. Example:

  1. set home app "when the door opens, run automation 1"
  2. "automation 1" triggers a shortcut in the shortcuts app
  3. your shortcut has a "get contents of url" automation that sends a get request (webhook) to your node red environment
  4. from that get request you can do whatever you want in nodered...

That's just one way to get around Apple's walls. Most of the work going into these projects are to expand the options and get things into a more friendly environment for complex automations... Along with others around here, I'd be happy to read your ideas and discuss options.

P1Rebo commented 4 years ago

@crxporter @Shaquu Thanks a lot for the quick reply! Now I understand the principle a little bit better. I didn't expect that kind of restrictions by Apple.

Here's a brief description of my use case: I also have a bunch of objects within my Smart Home based on an Industrial PLC controller (Bosch Rexroth IndraControl XM2) connected via a very static OPC UA interface to Node-Red. The rest is based on an MQTT "world model". This enables me to use e.g. Alexa (Echo Dots, Echo Show, Echo etc.) for commanding based also on objects. I want to integrate everything also within Apple Home, to use it on my Apple devices (iPad, iPhone(s), MacBook Pro etc.).

My garden irrigation use case is very simple. There are several water circuits that can't be run in parallel. So I need a sequence (of 3 sprinklers). The sequence length depends e.g. on the current earth humidity. Each sprinkler is a PLC object and directly controlled via electronic relays (24VDC PLC out to 24VAC).

Now that I know based on your feedback, I could implement the sequence based on a duration value either within Node-Red or directly within the PLC. The sequence could be activated based on a Switch. But as I saw, a switch doesn't accept a duration as input... As a workaround I could create e.g. 3 Switches (Long, Mid, Short Duration) :-)

crxporter commented 4 years ago

Alternately could you put proxy sprinklers in homekit and deal with the intricacies in node-red. This way you don't have to say "hey siri turn on the sprinkler switch" but "hey siri turn on side garden sprinklers for 5 minutes".

Another interesting thing that comes into play with this is that most items don't let siri take the duration like "siri turn on the light for 20 minutes" won't work but valves do have this so "turn on the sprinkler for 20 minutes" would work fine.

My best advice is play around with the input and debug nodes until you see all of the options then go from there to fit everything to your setup.

P1Rebo commented 4 years ago

Hi @crxporter thanks for the hints. I just realized it with a switch that triggers the sequence (10min Sprinkler 1 then 10min Sprinkler 2 etc....). I'll try the hint with the input + debug nodes also.

Keep continuing this great work! Thanks a lot!