Newbie trying to integrate OpenHAB with RFID card Reader

Hi All,

I've managed to get the OpenHAB nodes imported and can see state changes etc working just fine. I downloaded some code and imported it for my Wiegand RFID reader and it also works fine by using an Inject Node to trigger the reader's electric strike.

What I want to do now is use OH to send an ON message (which works) to trigger the electric strike instead of the Inject button.

For the life of me, I cant get it working. I deleted the inject node and took its code over into a change node, and then used a switch with ==ON to send the messagee to the change node, but it wont trigger.

Here is my code:

[
    {
        "id": "86bbf50e.a7f188",
        "type": "tab",
        "label": "7-doors",
        "disabled": false,
        "info": "# door control: basic examples\n\nBasic examples for the _get-door-control_, _set-door-control_ and _open-door_ nodes.\n\n - the _get-door-control_ example retrieves the current open delay to 5 seconds and control state for door 1 from the controller with serial number 405419896.\n\n - the _set-door-control_ example sets the open delay to 5 seconds and control state to 'normally closed' for door 1 on the controller with serial number 405419896.\n\n - the _open-door_ example opens door 1 on the controller with serial number 405419896 to the current time\n\nThe _doors_ flow in the _dashboard_ flowset contains a more complete example."
    },
    {
        "id": "d5c7ad9cd70bb7af",
        "type": "tab",
        "label": "7-doors",
        "disabled": false,
        "info": "# door control: basic examples\n\nBasic examples for the _get-door-control_, _set-door-control_ and _open-door_ nodes.\n\n - the _get-door-control_ example retrieves the current open delay to 5 seconds and control state for door 1 from the controller with serial number 405419896.\n\n - the _set-door-control_ example sets the open delay to 5 seconds and control state to 'normally closed' for door 1 on the controller with serial number 405419896.\n\n - the _open-door_ example opens door 1 on the controller with serial number 405419896 to the current time\n\nThe _doors_ flow in the _dashboard_ flowset contains a more complete example."
    },
    {
        "id": "a59d1554ba50a912",
        "type": "openhab2-controller2",
        "name": "OH3-Garage",
        "protocol": "http",
        "host": "localhost",
        "port": "8080",
        "path": "",
        "username": "oh.NodeRed.Wvv3IgWXYuf1KRD3qVvVk6DYH4Ec70VOPSICqI1uoBKdWXCTposqiQazrY5tMhPc1z8Orbwp1SyzUsa8Eg",
        "password": "",
        "ohversion": "v3",
        "token": ""
    },
    {
        "id": "a06b26d13b1eda23",
        "type": "config",
        "name": "SideGate",
        "timeout": "5000",
        "bind": "192.168.0.3",
        "broadcast": "192.168.0.255",
        "listen": "192.168.0.3:60001",
        "controllers": "{\"225024747\":{\"address\":\"192.168.0.19\",\"broadcast\":false}}",
        "debug": false
    },
    {
        "id": "ea318236.7f96",
        "type": "ui_tab",
        "name": "overview",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    },
    {
        "id": "ddd9980ec282d9e3",
        "type": "config",
        "name": "examples",
        "timeout": "5000",
        "bind": "192.168.1.100",
        "broadcast": "192.168.1.255:60000",
        "listen": "192.168.1.100:60001",
        "controllers": "{\"303986753\":{\"address\":\"192.168.1.100:60000\",\"broadcast\":false},\"405419896\":{\"address\":\"192.168.1.100:60000\",\"broadcast\":true}}",
        "debug": true
    },
    {
        "id": "6c1b3177.30bd2",
        "type": "open-door",
        "z": "86bbf50e.a7f188",
        "name": "open-door",
        "topic": "",
        "config": "a06b26d13b1eda23",
        "x": 1400,
        "y": 540,
        "wires": [
            [
                "cf49a18d.73b92",
                "e35ca985.ab1a28"
            ]
        ]
    },
    {
        "id": "cf49a18d.73b92",
        "type": "debug",
        "z": "86bbf50e.a7f188",
        "name": "received",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1630,
        "y": 540,
        "wires": []
    },
    {
        "id": "e35ca985.ab1a28",
        "type": "debug",
        "z": "86bbf50e.a7f188",
        "name": "door-1.opened",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.opened",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1650,
        "y": 580,
        "wires": []
    },
    {
        "id": "144b42932f4e8aa3",
        "type": "change",
        "z": "86bbf50e.a7f188",
        "name": "Trigger Side Gate",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{     \"deviceId\": 225024747,     \"door\": 1 }",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1150,
        "y": 540,
        "wires": [
            [
                "6c1b3177.30bd2"
            ]
        ]
    },
    {
        "id": "ee2d3c90742d633e",
        "type": "openhab2-in2",
        "z": "86bbf50e.a7f188",
        "name": "Side Gate",
        "controller": "a59d1554ba50a912",
        "itemname": "Side_Gate_DoorStrike",
        "topic": "",
        "initialstate": false,
        "whenupdated": true,
        "whencommand": true,
        "whenchanged": false,
        "changedfrom": "",
        "changedto": "",
        "x": 580,
        "y": 520,
        "wires": [
            [
                "70558842b957eab8"
            ]
        ]
    },
    {
        "id": "70558842b957eab8",
        "type": "switch",
        "z": "86bbf50e.a7f188",
        "name": "Strike Switch",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "ON",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "OFF",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 870,
        "y": 520,
        "wires": [
            [
                "144b42932f4e8aa3"
            ],
            []
        ]
    },
    {
        "id": "111dd9fb840fc110",
        "type": "debug",
        "z": "d5c7ad9cd70bb7af",
        "name": "received",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 520,
        "y": 100,
        "wires": []
    },
    {
        "id": "fcfd7e488a4b1bde",
        "type": "inject",
        "z": "d5c7ad9cd70bb7af",
        "name": "test",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{ \"deviceId\": 405419896, \"door\":1 }",
        "payloadType": "json",
        "x": 130,
        "y": 100,
        "wires": [
            [
                "f3b788c97b83575e"
            ]
        ]
    },
    {
        "id": "f3b788c97b83575e",
        "type": "get-door-control",
        "z": "d5c7ad9cd70bb7af",
        "name": "get-door-control",
        "config": "ddd9980ec282d9e3",
        "x": 300,
        "y": 100,
        "wires": [
            [
                "111dd9fb840fc110",
                "65d4906a6a8ec76a",
                "e52e6f10765e5b02"
            ]
        ]
    },
    {
        "id": "aedf48681de1700f",
        "type": "set-door-control",
        "z": "d5c7ad9cd70bb7af",
        "name": "set-door-control",
        "config": "ddd9980ec282d9e3",
        "x": 300,
        "y": 260,
        "wires": [
            [
                "8b8c229233ce6deb",
                "e0011c126c48574b",
                "5a7d6284df064c72"
            ]
        ]
    },
    {
        "id": "8b8c229233ce6deb",
        "type": "debug",
        "z": "d5c7ad9cd70bb7af",
        "name": "received",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 520,
        "y": 260,
        "wires": []
    },
    {
        "id": "fc90731fc4de8026",
        "type": "inject",
        "z": "d5c7ad9cd70bb7af",
        "name": "test",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"deviceId\":405419896,\"door\":1,\"delay\":6,\"control\":\"controlled\"}",
        "payloadType": "json",
        "x": 130,
        "y": 260,
        "wires": [
            [
                "aedf48681de1700f"
            ]
        ]
    },
    {
        "id": "c4d6a64920ea2d03",
        "type": "open-door",
        "z": "d5c7ad9cd70bb7af",
        "name": "open-door",
        "topic": "",
        "config": "a06b26d13b1eda23",
        "x": 290,
        "y": 420,
        "wires": [
            [
                "94b7915a77c82707",
                "ce309b81538b8e1b"
            ]
        ]
    },
    {
        "id": "94b7915a77c82707",
        "type": "debug",
        "z": "d5c7ad9cd70bb7af",
        "name": "received",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 520,
        "y": 420,
        "wires": []
    },
    {
        "id": "4dba9efe71bcdff9",
        "type": "inject",
        "z": "d5c7ad9cd70bb7af",
        "name": "test",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{ \"deviceId\":225024747, \"door\":1 }",
        "payloadType": "json",
        "x": 130,
        "y": 420,
        "wires": [
            [
                "c4d6a64920ea2d03"
            ]
        ]
    },
    {
        "id": "65d4906a6a8ec76a",
        "type": "debug",
        "z": "d5c7ad9cd70bb7af",
        "name": "door-1.delay",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.doorControlState.delay",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 530,
        "y": 140,
        "wires": []
    },
    {
        "id": "e52e6f10765e5b02",
        "type": "debug",
        "z": "d5c7ad9cd70bb7af",
        "name": "door-1.control",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.doorControlState.control.state",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 540,
        "y": 180,
        "wires": []
    },
    {
        "id": "e0011c126c48574b",
        "type": "debug",
        "z": "d5c7ad9cd70bb7af",
        "name": "door-1.delay",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.doorControlState.delay",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 530,
        "y": 300,
        "wires": []
    },
    {
        "id": "5a7d6284df064c72",
        "type": "debug",
        "z": "d5c7ad9cd70bb7af",
        "name": "door-1.control",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.doorControlState.control.state",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 540,
        "y": 340,
        "wires": []
    },
    {
        "id": "ce309b81538b8e1b",
        "type": "debug",
        "z": "d5c7ad9cd70bb7af",
        "name": "door-1.opened",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.opened",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 540,
        "y": 460,
        "wires": []
    }
]

Any help would be great!

Thanks

At a guess , may be the Openhub in node expects a JSON(Javascript) object rather than a JSON string. Try changing the type input of the change node to JSON {}.
eg.

[{"id":"144b42932f4e8aa3","type":"change","z":"86bbf50e.a7f188","name":"Trigger Side Gate","rules":[{"t":"set","p":"payload","pt":"msg","to":"{     \"deviceId\": 225024747,     \"door\": 1 }","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":540,"wires":[["6c1b3177.30bd2"]]},{"id":"70558842b957eab8","type":"switch","z":"86bbf50e.a7f188","name":"Strike Switch","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":870,"y":520,"wires":[["144b42932f4e8aa3"],[]]}]

The In node appears to function just fine, because when I change its state in Openhab, its reflected in NodeRed so I believe the in node works as expected. Further, a debug on this node shows its sending the payload with ON, outbound which is as expected

Sorry I meant the out node expects a object.

Sorry I don't follow :frowning:

Did you try my example. I changed the type of payload in the change node to json, as you had it as string.
Again I am guessing,

If that doesn't work you will need to provide debugs of incoming data for an informed answers, You could also check if the msg is making it past the switch node, place more debugs and follow he msg.

After changing to JSON it started to work :slight_smile: Thanks!! learnt alot in that process, appreciated

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