Closed RSWilli closed 2 years ago
okay after some more fiddeling around, I figured it out:
I didn't have the item type set to loopback command only. maybe this also needs more docs
apparently loopback only doesn't allow me to use event nodes with the item
but when I set the item type to "Status & Loopback Command" then i cannot use the action anymore
Yep, more docs are needed.
What you're describing should work. Take a look at the example below:
[ { "id": "0728c9e25ba71209", "type": "hal2Thing", "z": "797bdc9088052f14", "eventHandler": "e228014191d14be6", "thingType": "d5ffe0552919047a", "name": "Loopback test thing", "attributes": [], "topicFilter": "", "topicFilterType": "mqtt", "topicPrefix": "", "notes": "", "outputs": 0, "x": 360, "y": 680, "wires": [] }, { "id": "2aa3c080d26cc6e6", "type": "hal2Action", "z": "797bdc9088052f14", "eventHandler": "e228014191d14be6", "name": "Set 'active' to payload", "commandset": [ { "category": "hal2Thing", "thing": "0728c9e25ba71209", "item": "159e7a28.f5e3d6", "value": "payload", "type": "msg" } ], "ratelimit": 0, "x": 360, "y": 800, "wires": [] }, { "id": "a8abe93abde82244", "type": "inject", "z": "797bdc9088052f14", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "true", "payloadType": "bool", "x": 150, "y": 660, "wires": [ [ "0728c9e25ba71209" ] ] }, { "id": "5bb00ea396d4244f", "type": "inject", "z": "797bdc9088052f14", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "false", "payloadType": "bool", "x": 150, "y": 700, "wires": [ [ "0728c9e25ba71209" ] ] }, { "id": "4ca782f829d6af56", "type": "inject", "z": "797bdc9088052f14", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "true", "payloadType": "bool", "x": 150, "y": 800, "wires": [ [ "2aa3c080d26cc6e6" ] ] }, { "id": "1433f0c70d965ec8", "type": "inject", "z": "797bdc9088052f14", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "false", "payloadType": "bool", "x": 150, "y": 840, "wires": [ [ "2aa3c080d26cc6e6" ] ] }, { "id": "d480c792c8464b68", "type": "debug", "z": "797bdc9088052f14", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 490, "y": 940, "wires": [] }, { "id": "0ec518ecbfbf3691", "type": "hal2Group", "z": "797bdc9088052f14", "eventHandler": "e228014191d14be6", "name": "Group", "group": [ { "thing": "0728c9e25ba71209", "item": "159e7a28.f5e3d6" } ], "ratelimit": 0, "output": true, "input": true, "outputs": 1, "inputs": 1, "x": 310, "y": 940, "wires": [ [ "d480c792c8464b68" ] ] }, { "id": "a93103ea2d3684c2", "type": "hal2Event", "z": "797bdc9088052f14", "eventHandler": "e228014191d14be6", "name": "Loopback test thing active", "topic": "", "thing": "0728c9e25ba71209", "typeSel": "hal2Thing", "item": "159e7a28.f5e3d6", "operator": "always", "change": "1", "compareValue": "", "compareType": "num", "outputValue": "payload", "outputType": "state", "x": 190, "y": 1080, "wires": [ [ "5065094e82437d97" ] ] }, { "id": "5065094e82437d97", "type": "debug", "z": "797bdc9088052f14", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 490, "y": 1080, "wires": [] }, { "id": "710e47e4719132ca", "type": "comment", "z": "797bdc9088052f14", "name": "Set 'active' directly", "info": "", "x": 170, "y": 620, "wires": [] }, { "id": "227e32044fb969d5", "type": "comment", "z": "797bdc9088052f14", "name": "Set 'active' using an action", "info": "", "x": 190, "y": 760, "wires": [] }, { "id": "1dce6af66fcbfc2a", "type": "comment", "z": "797bdc9088052f14", "name": "Get and set 'active' using a group", "info": "", "x": 220, "y": 900, "wires": [] }, { "id": "2e82bd39fc1f7758", "type": "inject", "z": "797bdc9088052f14", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "true", "payloadType": "bool", "x": 150, "y": 940, "wires": [ [ "0ec518ecbfbf3691" ] ] }, { "id": "e8a260c959a1bdb8", "type": "inject", "z": "797bdc9088052f14", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "false", "payloadType": "bool", "x": 150, "y": 980, "wires": [ [ "0ec518ecbfbf3691" ] ] }, { "id": "ad1343b560e38e1c", "type": "comment", "z": "797bdc9088052f14", "name": "Trigger event on 'active' change", "info": "", "x": 210, "y": 1040, "wires": [] }, { "id": "e228014191d14be6", "type": "hal2EventHandler", "name": "Event handler", "maxlisteners": "50", "heartbeat": "10" }, { "id": "d5ffe0552919047a", "type": "hal2ThingType", "name": "Loopback test type", "contextStore": "filesystem", "nodestatus": "%active%", "items": [ { "name": "active", "id": "159e7a28.f5e3d6", "topicFilterType": "str", "topicFilterValue": "", "topicSuffix": "", "type": "loopback_both", "ingress": "ec279681.0060a8", "egress": "4976b249.e2879c", "notes": "" } ], "attributes": [], "ingress": [ { "name": "Pass-through", "id": "2d956987.ef2ce6", "fn": "// msg object is passed to function\n\nreturn msg.payload;" }, { "name": "Convert to Number", "id": "81c4ed2e.d9dcc", "fn": "// msg object is passed to function\n\nmsg.payload = Number(msg.payload);\nreturn msg.payload;" }, { "name": "Convert to Boolean", "id": "ec279681.0060a8", "fn": "// msg object is passed to function\nswitch(typeof msg.payload) {\n case 'number':\n msg.payload = (msg.payload==1);\n break;\n case 'string':\n msg.payload = (msg.payload == 'true');\n break;\n}\nreturn msg.payload;" } ], "egress": [ { "name": "Pass-through", "id": "4976b249.e2879c", "fn": "// msg object is passed to function\n\nreturn msg;" }, { "name": "Convert to Boolean", "id": "3fb2df57.db66e", "fn": "// msg object is passed to function\n\nmsg.payload = (msg.payload == 'true');\nreturn msg;" } ], "thingStatus": true, "thingCommand": true, "thingOutput": false, "hbCheck": false, "hbType": "lwt", "hbTTL": "", "hbLWT": "2d956987.ef2ce6", "hbFilterVal": "", "hbFilterType": "StrEnd", "filterFunction": "0" } ]
thanks for the bigger example!
I had a topic set on the message and a topic filter in the item, that's why it did not update
I'm using the thing types for presence detection in my local network, and I'm planning to use it for my thermostats
after a bit of fiddeling i came around the action node, and I'm a bit confused by it:
I am trying to set the value from the payload to the count item in the thing
I looked at the basic scene example and from what I can tell I replicated it 1:1, but I must have overlooked something