NorthernMan54 / node-red-contrib-homebridge-automation

Homebridge and Node-RED Integration
Apache License 2.0
106 stars 18 forks source link

Question on accessories giving enumerated values #27

Closed ahartman closed 4 years ago

ahartman commented 4 years ago

I use the homebridge-automation-calendar to determine sunrise - value changes from 2 to 3 - and sunset, value changes from 3 to 4. Can I use such nodes in in your node-red homebridge interface as trigger and conditions?

Regards, ahartman, belgium

NorthernMan54 commented 4 years ago

I can’t see why not, give it a try and see how it works out

Sent from my iPad

On Oct 25, 2019, at 3:46 AM, Andre Hartman notifications@github.com wrote:

 I use the homebridge-automation-calendar to determine sunrise - value changes from 2 to 3 - and sunset, value changes from 3 to 4. Can I use such nodes in in your node-red homebridge interface as trigger and conditions?

Regards, ahartman, belgium

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ahartman commented 4 years ago

I am an absolute beginner and I find node-red + homebridge a steep learning curve. I will try to ask as few 'stupid' questions as possible and I promise to contribute examples of my learning to the wiki to help the next beginner.

This is about controlling the exterior and interior lighting of a medical practice with two inputs:

  1. Do we have appointments. This is done with homebridge-calendar, building a ‘fake’ contact sensor, that is normally closed and ‘open’ when we have appointments.
  2. Do we have ‘before sunrise’, ‘during daylight’ or ‘after sunset’. This is done with homebridge-automation-calendar; this accessory produces a 2 for sunrise, a 3 for daylight and a 4 for sunset.

Appointments (trigger) can start and end before, during or after daylight (condition). The sun’s position (trigger) can change during appointments (condition).

There are 3 scenes to set: = Morning: exterior lights on and normal white interior lights. = Day: exterior lights off and normal withe interior lights. = Night: exterior lights on and warm white interior lights.

I build this in Homekit/Homebridge with 6 automations: 1 = Start of agenda (trigger) before sunrise (condition): set scene ‘morning’ 2 = Start of agenda (trigger) during daylight (condition): set scene ‘day’ 3 = Start of agenda (trigger) after sunset (condition): set scene ‘night’ 4 = Sunrise to daylight (trigger) during agenda (condition): set scene ‘day’ 5 = Daylight to sunset (trigger) during agenda (condition): set scene ‘night’ 6 = End of agenda: all off

However, using an iPad does not work well as automations do not fire reliably.

I can now do the trigger bit in node-red but I always need a condition as well. My questions: 1 = How do I use the hb-status node to retrieve status? 2 = Does the hb-status node get updated so that the sun’s position and agenda ‘open’ or ‘close’ are correct over the course of the day?

I hope I made the objective clear and all help is appreciated. Regards, ahartman, belgium

NorthernMan54 commented 4 years ago

Did you close this as you have your answers?

ahartman commented 4 years ago

Dear Northernman54, Stupid me, even GitHub is new for me. For now, I am ok as I had a very fruitful afternoon. I may come back later. Regards, ahartman, belgium

ahartman commented 4 years ago

Now I have a question. I want to switch on 2 lights, one is dimmable and the other one is a simple on/off light. I want to send {"On":true, "Brightness":25} to the first and {"On":true} to the second one. I do this with a function node with the following Javascript code:

msg1 = msg; msg1.payload={"On":true, "Brightness":25}; msg2 = msg; msg2.payload={"On":true}; msg = [msg1,msg2]; return msg;

The result is that both lights get msg2. What is my error? Please find an export plus screen image of the node-red flow below.

[{"id":"5f3b429e.f3ddbc","type":"function","z":"2f99f1f.d93930e","name":"Set JSON","func":"\nmsg1 = msg;\nmsg1.payload={\"On\":true, \"Brightness\":25};\nmsg2 = msg;\nmsg2.payload={\"On\":true};\nmsg = [msg1,msg2];\nreturn msg;","outputs":2,"noerr":0,"x":380,"y":120,"wires":[["1e95a90a.617be7"],["586fad9a.778514"]]}]
Schermafbeelding 2019-10-26 om 20 13 44

Regards, ahartman, belgium

NorthernMan54 commented 4 years ago

Just send the same command to both, the one that doesn't support brightness will grumble but it is a nothing

NorthernMan54 commented 4 years ago

Or try this

var msg1 = { payload:{"On":true, "Brightness":25} };
var msg2 = { payload:{"On":true} };
return [ msg1, msg2 ];
ahartman commented 4 years ago

Thank you, I realised I was using the same msg multiple times.

I started contributing to to the node-red-contrib-homebridge-automation wiki. You can go and read 'lights example' 0 and 1. However, explaining without images is hard.

Question: I think images need uploading in some way to GitHub. How do I insert an image in a wiki page?

Question: people may wish to ask questions or comment on my wiki pages to me. Would it be more convenient if I put these wiki pages in my own GitHub account and make links to them on your Node-RED wiki or is that somehow not possible?

Regards, ahartman, belgium.

NorthernMan54 commented 4 years ago

To put images in the wiki, I upload them to an issue then use the image link in the wiki

ahartman commented 4 years ago

Thank you, that works. How can I center images? Please take a look at my 'Lights example 0' and let know what you think.