Other homekit types through node-red

siri
homekit
node-red
Tags: #<Tag:0x00007f0145428018> #<Tag:0x00007f0145427e60> #<Tag:0x00007f0145427c80>

(Garrett Porter) #41

What “service” are you using for your HomeKit node?

There’s no reason this won’t work - but if you’re using “switch” as the type then you’ll need to send:

{"On":true}
{"On":false}

As your payloads.

We’ve had a lot of recent discussion in another thread - I even put together a pretty detailed tutorial of how I handle all of my items. Perhaps you’ll find something helpful over there:


(Georg) #42

Hi there, I need some help on this:
I have Roller Shutters and I would like to set the position on them from a Node Red HomeKit item. Can somebody tell me what items I need and how to setup them?
I get the CurrentPosition from the HomeKit item, but I don’t know the payload I have to set on the openHab item.


(Garrett Porter) #43

There’s a roller shutter example in my link just above your post - I call it “curtains”

My openhanded item is a dimmer, accepts 0-100 where 0 is closed and 100 is all the way open. I don’t know what hardware you’re using, but it should be a pretty easy to convert to your hardware. Maybe a matter of scaling numbers if anything?

My curtain motor is controlled by an Insteon micro open/close module.


(Georg) #44

Thank you for your answer Garrett. I had a look at your solution using dimmers, but i thought about a solution without a workaround. Unfortunately it looks like there is no other solution. Could you please send me your item and rule file?
I also think i have to do this with a timer. Sending the command “.SendCommand(50)” does noch set the shutter device to 50 of 100.


(Christian Berndt) #45

No need to for timer in my view
I did solve the issue the following (I am using Fibaro FGR222 in Venetian Blinds mode, which requires “TargetHorizontalTiltAngle” in addition)


I am using the blinds motor power consumption to update CurrentPosition.
Without that the blinds in homekit app would always be indidcated as Open/Close - with small spinning wheel.

CurrentPosition code:

var TargetPosition = context.get('TargetPosition');
var SensorPower = context.get('SensorPower');

if (msg.item == "ZWaveNode010FGR222RollerShutter2_ShutterPosition")
{
    TargetPosition = msg.payload;
}

if (msg.item == "ZWaveNode10FGRM222RollerShutter_SensorPower") 
{
    SensorPower = msg.payload;
}

if (SensorPower === 0);
{
msg.payload = {CurrentPosition: TargetPosition}
return msg;
}

The code for TargetPosition:

msg.payload = {TargetPosition : msg.payload}
return msg;

The code for TargetHorizontalTiltAngle:

msg.payload = { TargetHorizontalTiltAngle : msg.payload}
return msg;
your code goes here

(Garrett Porter) #46

This is a cool approach. I wonder is it accurate enough that you could use the total power used to come up with a % open number and send a stop command once you’ve reached that?

@gegy - you’ll need to say what your hardware setup is, as you see there are many approaches that could work. Pick one and run with it!


(Christian Berndt) #47

Actually, very accurate.
But not sure, what you are trying to achieve.
The motor is requiring roughly the same power for lowering and raising throughout the movement of the blinds. There is no real peak to determine stop based on some calculation.
This implementation allows to raise (and tilt) the blinds to whatever percentage of open (and tilt) you would like to have from iOS device:


(Garrett Porter) #48

I guess you must have more code somewhere then! I was curious if this setup lets you set different amounts of “open” - it seems like the answer is yes.

I’m not really trying to accomplish anything just curious about the setup. I’ve thought about power monitoring for different things but I don’t have any sensors at this point.

My motor is actually variable speed - starts slow then speeds up - so if I set anything but 0% or 100% open it doesn’t end up in quite the right place.


(Christian Berndt) #49

No additional code for homekit control.
but quite a lot of code lines for automation rules to handle all blinds - depending inputs like temperature outside, inside, luminance, time of day, presence etc.

As stated before I am using Fibaro FGR222 Zwave actors for roller blinds (quick google search should provide all details).
The FGR222 provide a fix value for blinds open = 100 (%) and blinds closed = 0 (%). (and same for venitian blind tilt: 0 closed, 50 horizontal orientation, 100 completely rotated (almost closed, but up slide down).
When setting up the FGR222s they are calibrating and with that identifying the respective endpoints.

When sending a certain value e.g. as result of moving the slider to 30 the blinds lower to leave 30% of windows uncovered.
The FGR222 allow to invert to the values to 0 is opened and 100 is closed, but I like that way.

function “BlindsControl”:

msg.payload = msg.payload.TargetPosition
return msg;

analog for tilt: “LamellaPosition” (with some extra logic to prevent negative values):

var TargetHorizontalTiltAngle = context.get('TargetHorizontalTiltAngle') || 0;

TargetHorizontalTiltAngle = msg.payload.TargetHorizontalTiltAngle;
if (TargetHorizontalTiltAngle < 0)
{
    TargetHorizontalTiltAngle = (TargetHorizontalTiltAngle*(-1));
    msg.payload = TargetHorizontalTiltAngle;
}
else
{
    msg.payload = msg.payload.TargetHorizontalTiltAngle;   
}
return msg;

(Ben Geens) #50

Hi Adam and everyone else!

Can you post what you injected in the HomeKit Garagedoor opener on the left side? I am struggling with finding the right configuration. I am working with KNX and I only have the status 1 or 0 when the door is opened or closed. At the moment I am sending the “CurrentDoorState” to HomeKit but that only seems to work when I am operating the door througd HomeKit itself. When I am for example opening through KNX, HomeKit gets stuck at “Closing…”. So I can’t close it back with HomeKit and Siri.
Long story short, I am hoping there are more parameters to send to the HomeKit Garagedoor opener.
If anyone else has experience or thinks he/she can help, I would be happy :wink:

Thanks


(Garrett Porter) #51

Ben -

The Garage Door homekit object needs at least 2 things going into the node to work properly:

TargetDoorState
CurrentDoorState

Your “target door state” is a 0 for “Open” and a 1 for “Closed”

Your “CurrentDoorState” options are:
0: Open. The door is fully open.
1: Closed. The door is fully closed.
2: Opening. The door is actively opening.
3: Closing. The door is actively closing.
4: Stopped. The door is not moving, and it is not fully open nor fully closed.

To pass these into homekit in nodered your payload needs to be something like these:

{"TargetDoorState":0}
{"CurrentDoorState":3}

You said you have a status 1 or 0 from KNX - you’ll want to set up your nodered to take these, “translate” them to what homekit is looking for - then you should be set. I linked a tutorial earlier in this thread that should have more explanation for you.

I’m familiar with window items which don’t have as many “CurrentDoorState” options, just “open” or “closed”. For the window item, what HomeKit is looking for is a “target state” then a “current state”. If you send an “open” current state when the target state is “closed” then homekit will show “closing” - if you send a “closed” current state when the target state is “open” then it will show “opening” and so on. For MY window I first send {"TargetState":"Open"} - wait 12 seconds - then send {"CurrentState":"Open"}. That makes my homekit show “opening” for 12 seconds.

You’ll have to adapt it to garage door with the 5 “CurrentDoorState” options - but that shouldn’t be too bad. If Adam is still around he could probably paste in the code so you can see the payloads being sent into HomeKit. They’re some combination of what I described above thouth!


(Ben Geens) #52

Thanks Garrett for the valuable information!

I can go on experimenting with the status. I will have to figure out one last problem. When the garage door is operated from KNX, the target state in HomeKit hasn’t changed and like you said it is showing “Opening…” or “Closing…”. But the command for opening the gate from KNX is just a 1. It’s an impulse. So I think I’m a little bit stuck. Maybe I can use HomeKit for opening and closing but not for knowing the status of the gate.


(Rohnny Swennen) #53

If your KNX just gives an impulse to open and close there indeed is no way to know the status, unless you start counting (which will get out of sync at some point anyhow).

So you might want to consider a sensor like this https://www.banggood.com/Zinc-Alloy-Security-Garage-WindowDoor-Rolling-Gate-Magnet-Alarm-Reed-Switch-p-1015568.html?cur_warehouse=CN

That way you always get the correct state irrespective from how or who opened the garage door.


(Ben Geens) #54

I have a semi solution. I can open, close trough HomeKit and will even display the correct status. I just had to make sure when I inject ‘TargetDoorState’, it won’t forward it to KNX, which would trigger the garagedoor again. See below for a screenshot!