Shelly input - different actions for short and long press

Hi,

I am using a Shelly input to set through lighting scenes. Simply when a short press is registered, scenes are selected in sequence (1,2,3,Off).

What I want to do is use the same input on a long press, to open and close a cover/blind. Here is my setup:

[{"id":"ec6dc9291bfe2ed3","type":"mqtt in","z":"a3a21d2e40b021ad","name":"","topic":"shellies/shellydimmer2-XXXXXX/input/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","nl":false,"rap":true,"rh":0,"inputs":0,"x":250,"y":680,"wires":[["c5105f8c0c31fdcc"]]},{"id":"c5105f8c0c31fdcc","type":"switch","z":"a3a21d2e40b021ad","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":550,"y":680,"wires":[["16a02a23072c6cae"]]},{"id":"f0ea7b4e55209481","type":"server-state-changed","z":"a3a21d2e40b021ad","name":"HL Scene Selection","server":"2278bc1a32e13768","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.hl_scene_selection","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":190,"y":840,"wires":[["f9d88212ed61b89f"]]},{"id":"f9d88212ed61b89f","type":"switch","z":"a3a21d2e40b021ad","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Scene 1","vt":"str"},{"t":"eq","v":"Scene 2","vt":"str"},{"t":"eq","v":"Scene 3","vt":"str"},{"t":"eq","v":"Off","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":550,"y":840,"wires":[["4c5ff381bc3062ae","59e62f9d132de4ae"],["35f74dc56386fdc7","1bb8a6745cca1e7d"],["95233b1cdb47b51a","f28505f6cd9a50f4"],["d18b170168501f5d","35f812682983ee26"]]},{"id":"4c5ff381bc3062ae","type":"api-call-service","z":"a3a21d2e40b021ad","name":"HL Scene 1","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.hl_scene_1","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":750,"y":780,"wires":[[]]},{"id":"35f74dc56386fdc7","type":"api-call-service","z":"a3a21d2e40b021ad","name":"HL Scene 2","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.hl_scene_2","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":750,"y":860,"wires":[[]]},{"id":"95233b1cdb47b51a","type":"api-call-service","z":"a3a21d2e40b021ad","name":"HL Scene 3","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.hl_scene_3","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":750,"y":940,"wires":[[]]},{"id":"d18b170168501f5d","type":"api-call-service","z":"a3a21d2e40b021ad","name":"HL Off","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.hl_off","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":730,"y":1020,"wires":[[]]},{"id":"16a02a23072c6cae","type":"api-call-service","z":"a3a21d2e40b021ad","name":"HL select next scene","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"input_select","service":"select_next","entityId":"input_select.hl_scene_selection","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":780,"y":680,"wires":[[]]},{"id":"59e62f9d132de4ae","type":"api-call-service","z":"a3a21d2e40b021ad","name":"Hall Lamp Off","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.plug_adapter_1","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":760,"y":820,"wires":[[]]},{"id":"1bb8a6745cca1e7d","type":"api-call-service","z":"a3a21d2e40b021ad","name":"Hall Lamp On","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.plug_adapter_1","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":760,"y":900,"wires":[[]]},{"id":"f28505f6cd9a50f4","type":"api-call-service","z":"a3a21d2e40b021ad","name":"Hall Lamp On","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.plug_adapter_1","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":760,"y":980,"wires":[[]]},{"id":"35f812682983ee26","type":"api-call-service","z":"a3a21d2e40b021ad","name":"Hall Lamp Off","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.plug_adapter_1","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":760,"y":1060,"wires":[[]]},{"id":"b798d361a05c84aa","type":"mqtt in","z":"a3a21d2e40b021ad","name":"","topic":"shellies/shellydimmer2-XXXXXX/longpush/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","nl":false,"rap":true,"rh":0,"inputs":0,"x":270,"y":720,"wires":[["0053f6b134236f97"]]},{"id":"0053f6b134236f97","type":"debug","z":"a3a21d2e40b021ad","name":"What goes after this?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":600,"y":720,"wires":[]},{"id":"3d4fd0c968879c2c","type":"mqtt-broker","name":"Mosquito","broker":"192.168.10.4","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"2278bc1a32e13768","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"}]

Obviously, I could just add a toggle to the long press, however by doing this, a short press is registered at the same time. I cannot open/close the cover without the switch first activating a lighting scene.

What I want to achieve is the following (I think):

Short press - scene is activated on the release, instead of the press.
Long press - when pressed, toggle is activated for the cover. This also disables the “release” of the short press, so that the lighting scene is not changed. This “disable” lasts for 1-2 seconds after the long press is released, and the system goes back to normal operation.

Any ideas?

1 Like

Not sure I really follow.
I don’t have this button so that could be the “issue”.

Anyways I believe I understand that you have the same issue as I did with my IKEA remote.
When I longpress it sends another command also (?).

What I did was to use the events node and listen to all events from zha. I could see that it first sends either a “release” or “press” command then the unwanted command.
The solution is to set up a sequence that captures this event and blocks the “main” sequence from happening.

further down is the real longpress sequence.

But what you see up here is that the zha event goes to a function node:

if(msg.payload.event.device_id == "9a34dc524acebdca64a4ad35af2a67c5" ){
    if(msg.payload.event.command == "press" || msg.payload.event.command == "release"){
        return msg;        
    } 
    
}

If it is the start of a longpress one of the commands above will first be sent from the remote, I use this to then set a flow variable to false.
This variable is then used in the switch node to block the unwanted action from happening.
The block sequence then delays for three seconds and then resets the flow variable.

OK i think i understand, so what i need is the following - how can i create a module that is true or false?

[{"id":"ec6dc9291bfe2ed3","type":"mqtt in","z":"a3a21d2e40b021ad","name":"","topic":"shellies/shellydimmer2-XXXXXX/input/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","nl":false,"rap":true,"rh":0,"inputs":0,"x":250,"y":680,"wires":[["abfe9d3ca3fd148c"]]},{"id":"c5105f8c0c31fdcc","type":"switch","z":"a3a21d2e40b021ad","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":750,"y":680,"wires":[["16a02a23072c6cae"]]},{"id":"16a02a23072c6cae","type":"api-call-service","z":"a3a21d2e40b021ad","name":"HL select next scene","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"input_select","service":"select_next","entityId":"input_select.hl_scene_selection","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":960,"y":680,"wires":[[]]},{"id":"b798d361a05c84aa","type":"mqtt in","z":"a3a21d2e40b021ad","name":"","topic":"shellies/shellydimmer2-XXXXXX/longpush/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","nl":false,"rap":true,"rh":0,"inputs":0,"x":250,"y":740,"wires":[["96775e2d978ebdf8","82a67c55f2e9f47a"]]},{"id":"abfe9d3ca3fd148c","type":"switch","z":"a3a21d2e40b021ad","name":"True/False?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":680,"wires":[["c5105f8c0c31fdcc"]]},{"id":"82a67c55f2e9f47a","type":"switch","z":"a3a21d2e40b021ad","name":"Set False","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":560,"y":760,"wires":[["71c5989342317f89"]]},{"id":"96775e2d978ebdf8","type":"switch","z":"a3a21d2e40b021ad","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":550,"y":720,"wires":[["14415829457460ca"]]},{"id":"14415829457460ca","type":"api-call-service","z":"a3a21d2e40b021ad","name":"Open/Close Blinds","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"cover","service":"toggle","entityId":"cover.lr_curtains","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":720,"wires":[[]]},{"id":"71c5989342317f89","type":"delay","z":"a3a21d2e40b021ad","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":760,"y":760,"wires":[["33c93f7f6e02def7"]]},{"id":"33c93f7f6e02def7","type":"switch","z":"a3a21d2e40b021ad","name":"Set True","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":920,"y":760,"wires":[[]]},{"id":"3d4fd0c968879c2c","type":"mqtt-broker","name":"Mosquito","broker":"192.168.10.4","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"2278bc1a32e13768","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"}]

I don’t think that will work.

If you open developer tools and events (or use Node red and events node to debug node).
Listen to the event (ZHA or ZigBee2 MQTT) and do a single click then a long press and copy the responses to here.
Just make sure to separate them so that I can see the difference which is long press and which is short press.

I am using Shelly switches

But how are they communicating? Is there nowhere you can get the raw data?

Sure here:

Short press = shellies/shellydimmer2-XXXXXX/input/0 (payload = 1 for press, 0 for release) - note that the release command is sent every 5 seconds once the switch is released.

Long press = shellies/shellydimmer2-XXXXXX/longpush/0 (payload = 1 for press, 0 for release) - note that the release command is sent every 5 seconds once the switch is released.

I meant one node that can read any event that happens with any shelly.

I think the only option is to delay the click and to first wait for longpress to occur.

[{"id":"ec6dc9291bfe2ed3","type":"mqtt in","z":"a787a77.9c16458","name":"","topic":"shellies/shellydimmer2-XXXXXX/input/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","nl":false,"rap":true,"rh":0,"inputs":0,"x":290,"y":3580,"wires":[["fef6ef52d795b171"]]},{"id":"c5105f8c0c31fdcc","type":"switch","z":"a787a77.9c16458","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":3580,"wires":[["16a02a23072c6cae"]]},{"id":"f0ea7b4e55209481","type":"server-state-changed","z":"a787a77.9c16458","name":"HL Scene Selection","server":"2278bc1a32e13768","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.hl_scene_selection","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":230,"y":3780,"wires":[["f9d88212ed61b89f"]]},{"id":"f9d88212ed61b89f","type":"switch","z":"a787a77.9c16458","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Scene 1","vt":"str"},{"t":"eq","v":"Scene 2","vt":"str"},{"t":"eq","v":"Scene 3","vt":"str"},{"t":"eq","v":"Off","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":590,"y":3780,"wires":[["4c5ff381bc3062ae","59e62f9d132de4ae"],["35f74dc56386fdc7","1bb8a6745cca1e7d"],["95233b1cdb47b51a","f28505f6cd9a50f4"],["d18b170168501f5d","35f812682983ee26"]]},{"id":"4c5ff381bc3062ae","type":"api-call-service","z":"a787a77.9c16458","name":"HL Scene 1","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.hl_scene_1","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":3720,"wires":[[]]},{"id":"35f74dc56386fdc7","type":"api-call-service","z":"a787a77.9c16458","name":"HL Scene 2","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.hl_scene_2","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":3800,"wires":[[]]},{"id":"95233b1cdb47b51a","type":"api-call-service","z":"a787a77.9c16458","name":"HL Scene 3","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.hl_scene_3","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":3880,"wires":[[]]},{"id":"d18b170168501f5d","type":"api-call-service","z":"a787a77.9c16458","name":"HL Off","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.hl_off","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":770,"y":3960,"wires":[[]]},{"id":"16a02a23072c6cae","type":"api-call-service","z":"a787a77.9c16458","name":"HL select next scene","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"input_select","service":"select_next","entityId":"input_select.hl_scene_selection","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1100,"y":3580,"wires":[[]]},{"id":"59e62f9d132de4ae","type":"api-call-service","z":"a787a77.9c16458","name":"Hall Lamp Off","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.plug_adapter_1","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":800,"y":3760,"wires":[[]]},{"id":"1bb8a6745cca1e7d","type":"api-call-service","z":"a787a77.9c16458","name":"Hall Lamp On","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.plug_adapter_1","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":800,"y":3840,"wires":[[]]},{"id":"f28505f6cd9a50f4","type":"api-call-service","z":"a787a77.9c16458","name":"Hall Lamp On","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.plug_adapter_1","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":800,"y":3920,"wires":[[]]},{"id":"35f812682983ee26","type":"api-call-service","z":"a787a77.9c16458","name":"Hall Lamp Off","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.plug_adapter_1","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":800,"y":4000,"wires":[[]]},{"id":"b798d361a05c84aa","type":"mqtt in","z":"a787a77.9c16458","name":"","topic":"shellies/shellydimmer2-XXXXXX/longpush/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","nl":false,"rap":true,"rh":0,"inputs":0,"x":310,"y":3620,"wires":[["a0b0a8bc6878bdb4","6f353002199fe0ca"]]},{"id":"fef6ef52d795b171","type":"delay","z":"a787a77.9c16458","name":"Delay 1","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":540,"y":3580,"wires":[["b8cdf8c2da446aac"]]},{"id":"b8cdf8c2da446aac","type":"switch","z":"a787a77.9c16458","name":"","property":"longpress","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":690,"y":3580,"wires":[["c5105f8c0c31fdcc"]]},{"id":"a0b0a8bc6878bdb4","type":"change","z":"a787a77.9c16458","name":"","rules":[{"t":"set","p":"longpress","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":3620,"wires":[["b74ef49a641dee22"]]},{"id":"0ba559e1c8dd9c16","type":"change","z":"a787a77.9c16458","name":"","rules":[{"t":"set","p":"longpress","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":3620,"wires":[[]]},{"id":"b74ef49a641dee22","type":"delay","z":"a787a77.9c16458","name":"Delay 2","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":820,"y":3620,"wires":[["0ba559e1c8dd9c16"]]},{"id":"6f353002199fe0ca","type":"api-call-service","z":"a787a77.9c16458","name":"Long press action goes here","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":660,"y":3680,"wires":[[]]},{"id":"3d4fd0c968879c2c","type":"mqtt-broker","name":"Mosquito","broker":"192.168.10.4","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"2278bc1a32e13768","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Both delays are probably too long, but you need to trim them down to where it just works.
“Delay 1” needs to be just long enough for the longpress to occur and do the first change node.
“Delay 2” can be longer, it just makes the button not respond, but it can also be trimmed down probably. This delay is to catch the short press that is unwanted.

I don’t know what the switch with payload == 1 is for but I just left it.

Hi,

The payload of “1” means press, and a payload of “0” means released. What does happen though, is that the relative command is sent every 5 seconds, for example, when the switch is “released” it sends a payload of “0” every 5 seconds.

Here is my working config now:

[{"id":"a3a21d2e40b021ad","type":"tab","label":"Temp Data","disabled":false,"info":"","env":[]},{"id":"a3e4a3b916995ec2","type":"server-state-changed","z":"a3a21d2e40b021ad","name":"MB Scene Selection","server":"2278bc1a32e13768","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.mb_scene_selection","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":250,"y":600,"wires":[["e529ebbeb9dabdaf"]]},{"id":"e529ebbeb9dabdaf","type":"switch","z":"a3a21d2e40b021ad","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Scene 1","vt":"str"},{"t":"eq","v":"Scene 2","vt":"str"},{"t":"eq","v":"Scene 3","vt":"str"},{"t":"eq","v":"Off","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":610,"y":600,"wires":[["7150d15aa3e76c21"],["b27940d642ee7726"],["c95285203c75acb9"],["65ec96d38f2c1885"]]},{"id":"7150d15aa3e76c21","type":"api-call-service","z":"a3a21d2e40b021ad","name":"MB Scene 1","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.mb_scene_1","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":810,"y":540,"wires":[[]]},{"id":"b27940d642ee7726","type":"api-call-service","z":"a3a21d2e40b021ad","name":"MB Scene 2","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.mb_scene_2","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":810,"y":580,"wires":[[]]},{"id":"c95285203c75acb9","type":"api-call-service","z":"a3a21d2e40b021ad","name":"MB Scene 3","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.mb_scene_3","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":810,"y":620,"wires":[[]]},{"id":"65ec96d38f2c1885","type":"api-call-service","z":"a3a21d2e40b021ad","name":"MB Off","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.mb_off","data":"{\"transition\":\"3\"}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":660,"wires":[[]]},{"id":"57d6a9ad1abf3efb","type":"mqtt in","z":"a3a21d2e40b021ad","name":"","topic":"shellies/shellydimmer2-E8DB84D52A92/input/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","nl":false,"rap":true,"rh":0,"inputs":0,"x":340,"y":400,"wires":[["9b5720e60475c4ce"]]},{"id":"41e88cc83355e356","type":"api-call-service","z":"a3a21d2e40b021ad","name":"HL select next scene","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"input_select","service":"select_next","entityId":"input_select.mb_scene_selection","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1040,"y":400,"wires":[[]]},{"id":"58bdc3566c2e9057","type":"mqtt in","z":"a3a21d2e40b021ad","name":"","topic":"shellies/shellydimmer2-E8DB84D52A92/longpush/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","nl":false,"rap":true,"rh":0,"inputs":0,"x":350,"y":440,"wires":[["6309d45c66f36036"]]},{"id":"410a98aa8aa98b83","type":"delay","z":"a3a21d2e40b021ad","name":"Delay 1","pauseType":"delay","timeout":"1000","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":740,"y":400,"wires":[["4cba055d047204a7"]]},{"id":"4bed244882e4d0ca","type":"change","z":"a3a21d2e40b021ad","name":"","rules":[{"t":"set","p":"longpress","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":440,"wires":[["4b7b7d3cb2af7278"]]},{"id":"5f108326a7fd7a1b","type":"change","z":"a3a21d2e40b021ad","name":"","rules":[{"t":"set","p":"longpress","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":440,"wires":[[]]},{"id":"4b7b7d3cb2af7278","type":"delay","z":"a3a21d2e40b021ad","name":"Delay 2","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":980,"y":440,"wires":[["5f108326a7fd7a1b"]]},{"id":"569de3b842af99ad","type":"api-call-service","z":"a3a21d2e40b021ad","name":"Long press action goes here","server":"2278bc1a32e13768","version":3,"debugenabled":false,"service_domain":"cover","service":"toggle","entityId":"cover.mb_roller_blind","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":800,"y":480,"wires":[[]]},{"id":"6309d45c66f36036","type":"switch","z":"a3a21d2e40b021ad","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":440,"wires":[["569de3b842af99ad","4bed244882e4d0ca"]]},{"id":"9b5720e60475c4ce","type":"switch","z":"a3a21d2e40b021ad","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":400,"wires":[["410a98aa8aa98b83"]]},{"id":"4cba055d047204a7","type":"switch","z":"a3a21d2e40b021ad","name":"","property":"longpress","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":870,"y":400,"wires":[["41e88cc83355e356"]]},{"id":"2278bc1a32e13768","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"},{"id":"3d4fd0c968879c2c","type":"mqtt-broker","name":"Mosquito","broker":"192.168.10.4","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

Thanks a lot.

This way you can controll the flow of the payloads. Release will only continue if a press has been done during the last second. Only the latest payload will go on.

[{"id":"297b7842.9913b8","type":"inject","z":"ebd7f2e4.a2afc","name":"1","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":170,"y":1060,"wires":[["b4d995be.eb0f78"]]},{"id":"5030fb2b.83d534","type":"inject","z":"ebd7f2e4.a2afc","name":"0","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":170,"y":1100,"wires":[["970321d2.69abf"]]},{"id":"1feb573e.1c01a9","type":"trigger","z":"ebd7f2e4.a2afc","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"1","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":500,"y":1080,"wires":[["265e7919.1d27e6"]]},{"id":"b4d995be.eb0f78","type":"change","z":"ebd7f2e4.a2afc","name":"switch on","rules":[{"t":"set","p":"switch","pt":"flow","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":1060,"wires":[["1feb573e.1c01a9"]]},{"id":"265e7919.1d27e6","type":"change","z":"ebd7f2e4.a2afc","name":"switch off","rules":[{"t":"set","p":"switch","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1080,"wires":[["e4ae2241.a8df5"]]},{"id":"970321d2.69abf","type":"switch","z":"ebd7f2e4.a2afc","name":"switch on?","property":"switch","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":310,"y":1100,"wires":[["1feb573e.1c01a9"]]},{"id":"e4ae2241.a8df5","type":"debug","z":"ebd7f2e4.a2afc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":1080,"wires":[]}]

Adjusting it to your flow. Adjust the seconds from the trigger node according to your shelly behaviour.

[{"id":"1feb573e.1c01a9","type":"trigger","z":"ebd7f2e4.a2afc","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"1","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":840,"y":1260,"wires":[["265e7919.1d27e6"]]},{"id":"b4d995be.eb0f78","type":"change","z":"ebd7f2e4.a2afc","name":"switch on","rules":[{"t":"set","p":"switch","pt":"flow","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":1240,"wires":[["1feb573e.1c01a9"]]},{"id":"265e7919.1d27e6","type":"change","z":"ebd7f2e4.a2afc","name":"switch off","rules":[{"t":"set","p":"switch","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":1260,"wires":[["800c14e9.fa7058"]]},{"id":"970321d2.69abf","type":"switch","z":"ebd7f2e4.a2afc","name":"switch on?","property":"switch","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":1280,"wires":[["1feb573e.1c01a9"]]},{"id":"d6d8169a.c63798","type":"mqtt in","z":"ebd7f2e4.a2afc","name":"","topic":"shellies/shellydimmer2-E8DB84D52A92/input/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","x":220,"y":1240,"wires":[["9f166770.2e03b8"]]},{"id":"6ec70529.24c49c","type":"mqtt in","z":"ebd7f2e4.a2afc","name":"","topic":"shellies/shellydimmer2-E8DB84D52A92/longpush/0","qos":"0","datatype":"auto","broker":"3d4fd0c968879c2c","x":230,"y":1280,"wires":[["9f166770.2e03b8"]]},{"id":"9f166770.2e03b8","type":"switch","z":"ebd7f2e4.a2afc","name":"payload?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":520,"y":1260,"wires":[["b4d995be.eb0f78"],["970321d2.69abf"]]},{"id":"800c14e9.fa7058","type":"switch","z":"ebd7f2e4.a2afc","name":"short or long?","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"shellies/shellydimmer2-E8DB84D52A92/input/0","vt":"str"},{"t":"eq","v":"shellies/shellydimmer2-E8DB84D52A92/longpush/0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1150,"y":1260,"wires":[["14631aa.fbfb2e5"],["26945ed0.31e422"]],"outputLabels":["short","long"]},{"id":"14631aa.fbfb2e5","type":"switch","z":"ebd7f2e4.a2afc","name":"press or release?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1370,"y":1220,"wires":[[],[]]},{"id":"26945ed0.31e422","type":"switch","z":"ebd7f2e4.a2afc","name":"press or release?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1370,"y":1300,"wires":[[],[]]},{"id":"3d4fd0c968879c2c","type":"mqtt-broker","name":"Mosquito","broker":"192.168.10.4","port":"1883","clientid":"","usetls":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
1 Like