Create nodes to interpret keypad input

I have an ESP8266 with remote control and ESP-Home is programmed to recognise numbers 0-9 in HA
image

What I was looking to do was to pick up each number press state from off to on convert the on action to a number which I think in node-red is referred to as a message payload and then use the combine to put the pressed numbers together as a string of 4 for comparison to a "security code"

Sounds simple but not even getting any debug outputs so I'm not sure what I am doing wrong and I'm struggling to find any decent step by step guides to help me with the Entity Node.

There are not too many HA uses (that I know of) frequent this forum I'm afraid so you may fair better asking on the HA forum.

That said, doesn't esp-easy talk mqtt?

If you use MQTT nodes there will be plenty here who can help.

1 Like

Hi @daknightuk

As mentioned above, NR has built in Nodes for MQTT.

if these entity nodes however, are not providing the expected values - the HA community will likely have answers - albeit the developer (assumingly in that community) should be able to advise.

If your getting into Node Red however, and want to combine payloads for concatenation.
You can use the join node, to create an array of the payloads (set to trigger after 4) i.e a 4 digit pin.

then use a function node to concatenate the values to yield your pin code.

Your function node will have

let PinCode;

for(let i = 0;i<msg.payload.length;i++)
{
    PinCode += msg.payload[i]
}
return {payload:PinCode}

@marcus-j-davies

From the information you provided and also from a video I found I worked out I needed to use the state change node and then when I pass the payload message I pass the "digit" being pressed.
Now I just need to work out how I do something with the pincode.
**


**

That's where you explore :wink:

Pass the pin code around your flows, do this or that, turn on a relay, send it to a web service, send an email, send it to an MQTT broker, check if its of a certain value etc etc.

its best to keep whatever you are passing around under the key of payload

i.e
{payload: integer | string | array | object}

the payload key is widely used and nodes built in or otherwise will use it by default.

Have fun - there is plenty of Node Red help here.

2 Likes

I did a debug on the pincode its coming out as undefined1234
image
@marcus-j-davies any idea's I spent several hours trying to work out a solution.

Very difficult to help with a single screen shot.

Can you export your flow and describe the operations you perform.

1 Like

Here is the export

Basically I have an ESP8266 connected to ESP-Home which has an infrared reciever.
I am looking to get the 4 digit code from the remote based on buttons pressed.
Each button is a binary sensor which is why I have remote_key_0 to remote_key_9.
Each button is a momentary action i.e On then Off.
The msg.payload has been combined thanks to some code which marcus provided but I get undefined which I think is something to do with the Combine when it creates the array.
Not sure if I need to "declare" the type for msg.payload?

[{"id":"d58407e6a1aa0fbd","type":"tab","label":"Get Security Code","disabled":false,"info":"","env":[]},{"id":"ec804da156ea6773","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_0","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"0","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":80,"wires":[["29427d651418fd7f"],[]]},{"id":"f476e28dad6f0906","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_1","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"1","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":140,"wires":[["29427d651418fd7f"],[]]},{"id":"931b6628b27fc0c9","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_2","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"2","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":200,"wires":[["29427d651418fd7f"],[]]},{"id":"c2962f54d6b0af4a","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_3","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"3","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":260,"wires":[["29427d651418fd7f"],[]]},{"id":"945f9df12d244d4d","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_4","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"4","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":320,"wires":[["29427d651418fd7f"],[]]},{"id":"d926c35ea391d6b6","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_5","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"5","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":380,"wires":[["29427d651418fd7f"],[]]},{"id":"47fd9ffc4ebe9630","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_6","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"6","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":440,"wires":[["29427d651418fd7f"],[]]},{"id":"24e77e3a72f0bdbc","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_7","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"7","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":500,"wires":[["29427d651418fd7f"],[]]},{"id":"239e9b7a4e52235e","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_8","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"8","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":560,"wires":[["29427d651418fd7f"],[]]},{"id":"5fd40fe50f1227f5","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_9","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"9","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":620,"wires":[["29427d651418fd7f"],[]]},{"id":"29427d651418fd7f","type":"join","z":"d58407e6a1aa0fbd","name":"Combine Digits","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":670,"y":320,"wires":[["8dcd5e79f9f8cda9"]]},{"id":"8dcd5e79f9f8cda9","type":"function","z":"d58407e6a1aa0fbd","name":"Get Pincode","func":"let PinCode;\n\nfor(let i = 0;i<msg.payload.length;i++)\n{\n    PinCode += msg.payload[i]\n}\nreturn {payload:PinCode}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":320,"wires":[["6858598e172efa7d"]]},{"id":"6858598e172efa7d","type":"debug","z":"d58407e6a1aa0fbd","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":320,"wires":[]},{"id":"28d29ba7.5cc1e4","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

You didnt initialise the variable in your function to empty string.

chrome_AoDQsXtAmH

This works...

[{"id":"7e01e6c58d6d88db","type":"join","z":"6ae4dd80c061dc7a","name":"Combine Digits","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1920,"y":180,"wires":[["ab4ad40b4df17a78"]]},{"id":"ab4ad40b4df17a78","type":"function","z":"6ae4dd80c061dc7a","name":"Get Pincode","func":"let pin = \"\";\nfor (let i = 0; i < msg.payload.length; i++) {\n    pin += msg.payload[i];\n}\nreturn { payload: pin };\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1940,"y":220,"wires":[["02f1fafdc71e278d"]]},{"id":"02f1fafdc71e278d","type":"debug","z":"6ae4dd80c061dc7a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1960,"y":260,"wires":[]},{"id":"c35c0940fea7a360","type":"inject","z":"6ae4dd80c061dc7a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":1720,"y":100,"wires":[["7e01e6c58d6d88db"]]},{"id":"c626bc4e47eefb01","type":"inject","z":"6ae4dd80c061dc7a","name":"","props":[{"p":"payload"},{"p":"topic","v":"","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2","payloadType":"num","x":1720,"y":140,"wires":[["7e01e6c58d6d88db"]]},{"id":"b571908ae6b6b98e","type":"inject","z":"6ae4dd80c061dc7a","name":"","props":[{"p":"payload"},{"p":"topic","v":"","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"3","payloadType":"num","x":1720,"y":180,"wires":[["7e01e6c58d6d88db"]]},{"id":"4dcfef25aa1db067","type":"inject","z":"6ae4dd80c061dc7a","name":"","props":[{"p":"payload"},{"p":"topic","v":"","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":1720,"y":220,"wires":[["7e01e6c58d6d88db"]]},{"id":"43625c3421f6a390","type":"inject","z":"6ae4dd80c061dc7a","name":"","props":[{"p":"payload"},{"p":"topic","v":"","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5","payloadType":"num","x":1720,"y":260,"wires":[["7e01e6c58d6d88db"]]}]
1 Like

Just for info. You do not need the function if you join the payloads as a string.
[edit] I would also add a timeout to the join so the password input resets after a few seconds. Then when you partly input code it will reset.

3 Likes

Indeed. (I left the function there as the question was about getting undefined in his function)

@daknightuk as @E1cid rightly says, you can simplify this by changing the join to create a string

image

chrome_7YuiLnzb6j

2 Likes

2nd it!

I wasn't sure if the value of interest was in fact the payload - as apposed to something further down.
If so - I think you can do that in the Combine each path anyway right?

Ah I see what you mean, yes it works the key is to remove the /n which is why the msg.payload looked like it had a load of "Carriage Returns"

image

image

Final code for my keypad which links into HA manual alarm panel
This is a disarm function only using the code "2222"
I arm using voice control.

[{"id":"d58407e6a1aa0fbd","type":"tab","label":"Get Security Code","disabled":false,"info":"","env":[]},{"id":"ec804da156ea6773","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_0","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"0","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":80,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"f476e28dad6f0906","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_1","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"1","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":140,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"931b6628b27fc0c9","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_2","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"2","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":200,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"c2962f54d6b0af4a","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_3","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"3","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":260,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"945f9df12d244d4d","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_4","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"4","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":320,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"d926c35ea391d6b6","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_5","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"5","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":380,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"47fd9ffc4ebe9630","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_6","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"6","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":440,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"24e77e3a72f0bdbc","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_7","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"7","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":500,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"239e9b7a4e52235e","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_8","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"8","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":560,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"5fd40fe50f1227f5","type":"server-state-changed","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.remote_key_9","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"1","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"9","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":620,"wires":[["7e01e6c58d6d88db"],[]]},{"id":"7e01e6c58d6d88db","type":"join","z":"d58407e6a1aa0fbd","name":"Combine Digits","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"3","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":540,"y":80,"wires":[["475bcbd476515e89"]]},{"id":"475bcbd476515e89","type":"function","z":"d58407e6a1aa0fbd","name":"Check Pin","func":"var payload = msg.payload;\nif (msg.payload==\"2222\"){\n    msg.payload = 1;\n} else {\n    msg.payload = 0;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":80,"wires":[["258f8ea6099ad45c"]]},{"id":"23edf12e78b1b735","type":"api-call-service","z":"d58407e6a1aa0fbd","name":"","server":"28d29ba7.5cc1e4","version":3,"debugenabled":false,"service_domain":"alarm_control_panel","service":"alarm_disarm","entityId":"alarm_control_panel.home_security_system","data":"{\"code\":2222}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":780,"y":340,"wires":[[]]},{"id":"258f8ea6099ad45c","type":"switch","z":"d58407e6a1aa0fbd","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":890,"y":80,"wires":[["23edf12e78b1b735"],[]]},{"id":"28d29ba7.5cc1e4","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

Hi, in order to make code more readable and importable it is important to surround your code with three backticks
```
like this
```

You can edit and correct your post by clicking the pencil icon.

See this post for more details - How to share code or flow json

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.