Combining node messages - Node Red

I'm working on a lock announcement flow and I would like to combine it so that I don't have to have a bunch of flows happening. I was wondering if someone would help me with the function of it?

So, I have 3 locks foyer, front, garage and I want a voice announcement to happen when it's locked and unlocked. But, I'm running into trouble combining this into an even flow. I could have a separate flow for each, but I'd prefer not to double up on the announcements. Door is unlocked. door is unlocked by last code used. Also, i'd like to know which door instead of pre-formatting a bunch of flows to do one job each.
So

image

image

I would like for it to identify the lock and if it was unlocked by someone, who. But if it was unlocked or locked by rule or manually, I would just like it to announce the change in state.
[named lock] was [state] by [last code entered] or just [named lock] was [state] if no code entered
is that possible to do in one flow?

I dont use function nodes, but could you incorporate msg.topic somewhere? That should give you which lock was used (i think)

1 Like

I've tried everything I can guess.

I can't help on the alexa part, but let me poke around on the msg combining part for a bit. Should be doable - I just need to spend a few minutes on it.

I'll be back...

1 Like

Maybe use the join node?

That is a question that I don't know the answer to. :grin:

1 Like

What do your lock/unlock events look like on your lock?

Mine (Kwikset zigbee lock) look something like:

image

image

image

msg.topic should give the device name for the event. So that part should be easy to add to the message.

EDIT: Never mind. Not applicable to you since your events are completely different than mine.
For the code/no code, I would do something like

if (msg.payload.value.search("manual") {
  <return payload without user code>
 }
else {
  <return payload with user code>
}
```</s>

Ah, your device driver doesn't include the code used to unlock in the unlock message. Yuck.

That makes it significantly harder as you have to combine multiple messages. Hmm.

Blame Mike he wrote the drivers. :grin: I have two alfreds and one Schlage be469. If it's a pain, then I'll nix it and do something else to only have one announcement play.

Perhaps just having it play only when the last code wasn't used? and vise versa. two flows?

I just really don't want two announcements when the door gets opened. door is unlocked - door is unlocked by ... ugh

Should be able to do that. Use msg.payload.name as the path selector.

The real fix is that Mike should make the event description the same as all of the other in-box drivers. :slight_smile: If manual vs code was added to the event description on the lock/unlock event (like it is on the generic zigbee lock driver) then it would be trivial.

Maybe he didn't do that because Alfred doesn't report it in the extra data field when reporting the lock/unlock events - not sure.

There's always a way....sometimes it's just ugly. I end up tossing everything into flow variables as they come in and using those in functions. Just need a good trigger for the flow. Having multiple messages associated with an event could be a challenge though. Is the sequence of the messages consistent? Who then what, or what then who?

Yah ... I am not the one to argue that point. :grin:
Not sure about that. He's got so many drivers to write that he was probably like "just live with it for a while".
so is there anything special I need to do to get only one message to play per activity? I've now managed to overthink it.

As you can see, with the generic zigbee lock driver and a kwikset lock, the unlock command contains which code # as well as the actual code in the msg.payload.data field:

Are you using the websocket or webhook node-red node connectivity method? I do know that there are different fields reported to node-red between the two.

My example above uses the webhook method (I only use webhook on all my production hubs as it is simply more reliable, and 100% supported).

Websocket reports less stuff, and in different formats, so if using websocket it might be worth switching to the supported webhook method and seeing if the results differ.

For the record, you can use both at the same time - just make 2 config nodes and set one up one way, and the other the other way.

No idea. The thought came to me when I wondered if the door had locked after my parents left and realized that there's not an announcement for auto lock and realized why I hadn't done it. In RM I had separate announcements and it drove me crazy, so I delayed setting that up until I could consult with someone that can make a problem like this look "trivialL. I'm so glad someone can.
Don't underestimate how much I appreciate you guys.
:kiss:

OH ... I'll check

Webhook

Weird, I guess it is a driver difference then.

As an example of webhook vs websocket differences, on websocket here is what I get on an unlock on the exact same lock. Note, no code info at all. Which, again for others, is why I strongly recommend using webhook by default, and websocket only if you have a specific reason to (and even then only on the specific devices you have the need for it on)