Configuration of Evok to internal act on event



  • Hi,

    Don't find what I'm looking for, maybe the bad word I have been using to search.

    I'm looking to directly connect the Input to an action of Output. The idea is to have switch connected to Unipi and the light for exemple on the relay.
    So I can configure directly the action on event in Evok and no need for outside home automation software for this use case.

    Is it possible, can we add it ? Where ?



  • Hi,

    Don't find what I'm looking for, maybe the bad word I have been using to search.

    I'm looking to directly connect the Input to an action of Output. The idea is to have switch connected to Unipi and the light for exemple on the relay.
    So I can configure directly the action on event in Evok and no need for outside home automation software for this use case.

    Is it possible, can we add it ? Where ?



  • If you look here:

    http://unipi.technology/wiki/Controllin ... BM_Bluemix

    and the go to the section "Local control of UniPi", there is a string of JSON that can be imported into Node Red and it will set up this exact functionality:
    Input 1 Controls Relay 1
    Input 2 Controls Relay 2
    etc...

    Thanks,
    Brett.



  • Sorry,
    I actually imported the string into Node Red and it is only half the solution. Here is what I have:

    [{"id":"447d966a.bb8268","type":"websocket-client","path":"ws://127.0.0.1/ws","wholemsg":"false"},{"id":"467c28da.b983d8","type":"websocket out","z":"e6b446f4.194bb8","name":"","server":"","client":"447d966a.bb8268","x":718,"y":411,"wires":[]},{"id":"bb5201c5.44ae","type":"inject","z":"e6b446f4.194bb8","name":"R1 ON","topic":"","payload":"{"dev":"relay", "circuit":"8", "value":"1"}","payloadType":"string","repeat":"","crontab":"","once":false,"x":418,"y":409,"wires":[["467c28da.b983d8"]]},{"id":"4b04b743.b4fb48","type":"inject","z":"e6b446f4.194bb8","name":"R1 OFF","topic":"","payload":"{"dev":"relay", "circuit":"8", "value":"0"}","payloadType":"string","repeat":"","crontab":"","once":false,"x":418,"y":445,"wires":[["467c28da.b983d8"]]},{"id":"740e838.f8bf17c","type":"inject","z":"e6b446f4.194bb8","name":"AO set 5V a","topic":"","payload":"{"dev":"ao", "circuit":"1", "value":"5"}","payloadType":"string","repeat":"","crontab":"","once":false,"x":404,"y":371,"wires":[["467c28da.b983d8"]]},{"id":"de2846e5.21d7b8","type":"websocket in","z":"e6b446f4.194bb8","name":"","server":"","client":"447d966a.bb8268","x":194,"y":553,"wires":[["1cb3732f.e34c8d"]]},{"id":"1cb3732f.e34c8d","type":"function","z":"e6b446f4.194bb8","name":"IN 1-7 -> RELAY 1-7","func":"var unipistatus = JSON.parse(msg.payload);\nvar msg = {};\nif (unipistatus.dev == "input" && unipistatus.circuit<8) {\n\t//leave the relay 8 to the temp control node\n\tif (unipistatus.value === 0) {\n\t\tmsg.payload = {"dev":"relay", "circuit":"", "value":"0"};\n\t\tmsg.payload["circuit"] = unipistatus.circuit;\n\t}\n\telse {\n\t\tmsg.payload = {"dev":"relay", "circuit":"", "value":"1"};\n\t\tmsg.payload["circuit"] = unipistatus.circuit;\n\t}\n\treturn msg;\n}\nelse return;\n","outputs":1,"noerr":0,"x":456,"y":553,"wires":[["467c28da.b983d8"]]}]

    Get Node Red running on your RPi, log into the Node Red UI and Import -> clipboard…

    Thanks,
    Brett



  • Here is another flow where inputs directly control the output relays. However, now the input can be either a click or a press and hold where a click will toggle the state of the relay and a hold will activate the relay only when held.

    [{"id":"5605b7b2.a9fa48","type":"websocket-client","path":"ws://127.0.0.1/ws","wholemsg":"false"},{"id":"2538f19e.dac70e","type":"websocket out","z":"12603337.ed9fcd","name":"","server":"","client":"5605b7b2.a9fa48","x":969,"y":185,"wires":[]},{"id":"8c6ee30f.73912","type":"websocket in","z":"12603337.ed9fcd","name":"","server":"","client":"5605b7b2.a9fa48","x":192,"y":170,"wires":[["27c90225.d836fe"]]},{"id":"aacdc1c4.55324","type":"function","z":"12603337.ed9fcd","name":"Latch Relay - Toggle","func":"var unipistatus = JSON.parse(msg.payload);\nvar modulestatus = context.global.modulestatus;\nvar inDevice = {};\nvar outDevice = {};\nvar msg = {};\n\nfor (var indev in modulestatus){\n if (modulestatus[indev] == unipistatus.circuit){\n inDevice = modulestatus[indev];\n \n }\n}\n \nfor (var outdev in modulestatus){\n if (modulestatus[outdev].dev == "relay" && modulestatus[outdev].circuit == unipistatus.circuit){\n outDevice = modulestatus[outdev];\n }\n}\n \nif (unipistatus.dev == "input" && unipistatus.circuit<8) {\n \n\tif (unipistatus.value === 0) {\n if (outDevice.value == "0"){\n msg.payload = {"dev":"relay", "circuit":"", "value":"1"};\n\t\t msg.payload.circuit = unipistatus.circuit;\n\t\t outDevice.value = "1";\n\t }\n\t else{\n\t msg.payload = {"dev":"relay", "circuit":"", "value":"0"};\n\t msg.payload.circuit = unipistatus.circuit;\n\t outDevice.value = "0";\n\t }\n\t}\n\telse {\n\t \n\t}\n\treturn msg;\n}\nelse return;\n","outputs":1,"noerr":0,"x":734,"y":163,"wires":[["2538f19e.dac70e"]]},{"id":"16044675.e9fbba","type":"http request","z":"12603337.ed9fcd","name":"Initial Status","method":"GET","ret":"txt","url":"http://127.0.0.1/rest/all","x":316,"y":77,"wires":[["9291954d.6d6e68"]]},{"id":"bf8a9779.407568","type":"inject","z":"12603337.ed9fcd","name":"Startup","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":175,"y":77,"wires":[["16044675.e9fbba"]]},{"id":"9291954d.6d6e68","type":"function","z":"12603337.ed9fcd","name":"Store Status","func":"context.global.modulestatus = JSON.parse(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":472,"y":77,"wires":[["ec3278b5.13cd88"]]},{"id":"ec3278b5.13cd88","type":"debug","z":"12603337.ed9fcd","name":"","active":false,"console":"false","complete":"false","x":630,"y":77,"wires":[]},{"id":"27c90225.d836fe","type":"function","z":"12603337.ed9fcd","name":"Click or Hold","func":"var unipistatus = JSON.parse(msg.payload);\nvar msg1 = {};\n\nif (unipistatus.dev == "input"){\n msg1 = msg;\n if (unipistatus.value == "0"){\n msg1.reset = 1;\n return [msg,msg1];\n }\n else {\n return [null,msg1];\n }\n}\n\nreturn;","outputs":"2","noerr":0,"x":379,"y":170,"wires":[["aacdc1c4.55324"],["65fe55ef.9a01ac"]]},{"id":"65fe55ef.9a01ac","type":"trigger","z":"12603337.ed9fcd","op1":"1","op2":"0","op1type":"nul","op2type":"pay","duration":"500","extend":false,"units":"ms","name":"Press and Hold","x":554,"y":206,"wires":[["1f48c204.e0b73e"]]},{"id":"1f48c204.e0b73e","type":"function","z":"12603337.ed9fcd","name":"On Until Release","func":"var unipistatus = JSON.parse(msg.payload);\nvar modulestatus = context.global.modulestatus;\nvar inDevice = {};\nvar outDevice = {};\nvar msg = {};\n\nfor (var indev in modulestatus){\n if (modulestatus[indev] == unipistatus.circuit){\n inDevice = modulestatus[indev];\n \n }\n}\n \nfor (var outdev in modulestatus){\n if (modulestatus[outdev].dev == "relay" && modulestatus[outdev].circuit == unipistatus.circuit){\n outDevice = modulestatus[outdev];\n }\n}\n \nif (unipistatus.dev == "input" && unipistatus.circuit<8) {\n \n\tif (unipistatus.value == "1") {\n msg.payload = {"dev":"relay", "circuit":"", "value":"1"};\n\t\t msg.payload.circuit = unipistatus.circuit;\n\t\t outDevice.value = "1";\n\t\t inDevice.value = "1";\n\t}\n\telse {\n\t msg.payload = {"dev":"relay", "circuit":"", "value":"0"};\n\t msg.payload.circuit = unipistatus.circuit;\n\t outDevice.value = "0";\n\t inDevice.value = "0";\n\t}\n\t\n\treturn msg;\n}\nelse return;\n","outputs":1,"noerr":0,"x":745,"y":206,"wires":[["2538f19e.dac70e"]]}]

    Thanks,
    Brett.