Blinds Control Logic?

Hello @all

I've got a little problem with programming my shutter control... I got a Shelly2.5 in use for "smarting" my blinds.
Via MQTT I got 3 "buttons" in my ioBroker. Open, Close, Stop.

Now I want to realize with Node-RED a two button control. I don't want to visualize 3 Buttons. 2 are enought an it looks the same like the Physical Buttons in the wall.

In my visualisation I got the buttons / tasters Open and Close.
When I press Open i get a msg.payload=open and when I'm going to release the button I get a payload=stop.
Some with close.
Pressed -> close
Released -> stop

Logic I want:
Blind are stopped lets say in the middle. When I press open for short time the blinds should only open. When I'm going to press longer (>1 sec) the blinds should roll up. Same with close.
When the blinds are rolling up or down and I press up/down again they should stop....

I cant get it done to create the right logic and flow to get it done...
Is here somebody who can help me? Tried already about 4 hours...
Node-RED isn't something new for myself... already got some flows to ask wifi status, control a switch in bathroom for heating etc.. But this thing won't work...

Thanks for your help
superwinni2

Can you share the flow you have? Please read the following post How to share code or flow json first :slight_smile:

This may also come in handy at some point soon - Momentary button on Dashboard

It's not much...
Deleted much again after it doesn't did the work...
I even can't get a good logic for this... I think thats my biggest problem...

Ahh... I'm german...
Öffnen -> Open
Stop -> Stop
Schließen -> Close

[
    {
        "id": "cda07a0e.4c83f8",
        "type": "ioBroker out",
        "z": "c3d2808b.6dfee",
        "name": "Close",
        "topic": "shelly.0.SHSW-25#687D5C#1.Shutter.Close",
        "ack": "false",
        "autoCreate": "false",
        "x": 1230,
        "y": 200,
        "wires": []
    },
    {
        "id": "3eebf54d.fa1f9a",
        "type": "ioBroker in",
        "z": "c3d2808b.6dfee",
        "name": "Fenster Links Open",
        "topic": "node-red.0.verschattung.fensterllinks.öffnen",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 150,
        "y": 160,
        "wires": [
            [
                "8d8beb40.90a9b8"
            ]
        ]
    },
    {
        "id": "e3df650a.14e228",
        "type": "ioBroker in",
        "z": "c3d2808b.6dfee",
        "name": "Fenster Links Close",
        "topic": "node-red.0.verschattung.fensterllinks.schließen",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 150,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "1a6c2840.0c1598",
        "type": "ioBroker out",
        "z": "c3d2808b.6dfee",
        "name": "Open",
        "topic": "shelly.0.SHSW-25#687D5C#1.Shutter.Open",
        "ack": "false",
        "autoCreate": "false",
        "x": 1230,
        "y": 80,
        "wires": []
    },
    {
        "id": "739ca512.b9c36c",
        "type": "ioBroker out",
        "z": "c3d2808b.6dfee",
        "name": "Stop",
        "topic": "shelly.0.SHSW-25#687D5C#1.Shutter.Pause",
        "ack": "false",
        "autoCreate": "false",
        "x": 1230,
        "y": 140,
        "wires": []
    },
    {
        "id": "2d829dbd.c08822",
        "type": "switch",
        "z": "c3d2808b.6dfee",
        "name": "Drivemode",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "öffnen",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "stop",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "schließen",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 1090,
        "y": 140,
        "wires": [
            [
                "1a6c2840.0c1598"
            ],
            [
                "739ca512.b9c36c"
            ],
            [
                "cda07a0e.4c83f8"
            ]
        ]
    },
    {
        "id": "8d8beb40.90a9b8",
        "type": "switch",
        "z": "c3d2808b.6dfee",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "öffnen",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "stop",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 330,
        "y": 160,
        "wires": [
            [
                "e5ae5d75.7a717"
            ],
            [
                "e5ae5d75.7a717"
            ]
        ]
    },
    {
        "id": "87c363af.65317",
        "type": "delay",
        "z": "c3d2808b.6dfee",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 800,
        "y": 140,
        "wires": [
            [
                "2d829dbd.c08822"
            ]
        ]
    },
    {
        "id": "e5ae5d75.7a717",
        "type": "trigger",
        "z": "c3d2808b.6dfee",
        "op1": "",
        "op2": "",
        "op1type": "pay",
        "op2type": "nul",
        "duration": "0",
        "extend": false,
        "units": "ms",
        "reset": "stop",
        "bytopic": "all",
        "name": "",
        "x": 530,
        "y": 140,
        "wires": [
            [
                "87c363af.65317"
            ]
        ]
    }
]

This may also come in handy at some point soon - Momentary button on Dashboard

The problem is not the momentary button. I can also switch them to toggle Buttons. But because I want to do it "Wall like" I would also like to got them. It's 100% for sure that when I press the Open Button I got the Open (Öffnen) message and when I release it on my visualisation I get the stop message.

I wrote the flow for controlling some doors - it should be just as applicable for blinds - you might have to edit the timer so it's 1% of the full opening/closing time

How do you know if the button was held for 1 second ? Do you get a release event ?

I used context, not sure it is even needed. unless I misunderstand your issue.

[{"id":"930d5524.6de6a","type":"inject","z":"e4ffbcc9.38355","name":"","topic":"","payload":"pressed","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":186,"y":224,"wires":[["49e94e63.58c218"]]},{"id":"16180b6d.5659d5","type":"inject","z":"e4ffbcc9.38355","name":"","topic":"","payload":"released","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":280,"wires":[["49e94e63.58c218"]]},{"id":"af16c5a2.6401d8","type":"inject","z":"e4ffbcc9.38355","name":"","topic":"","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":336,"wires":[["49e94e63.58c218"]]},{"id":"b3aafc04.918f38","type":"inject","z":"e4ffbcc9.38355","name":"","topic":"","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":168,"wires":[["49e94e63.58c218"]]},{"id":"49e94e63.58c218","type":"function","z":"e4ffbcc9.38355","name":"","func":"m = msg.payload\ns = context.get(\"state\")\nif(m ==='pressed'){\n    context.set(\"state\",\"moving\")\n    node.send({payload:'closing...'})\n}\nif(m==='released'){\n    context.set(\"state\",\"stopped\")\n    node.send({payload:'stop'})\n}\n\nif(m ==='open'){\n    if(s===\"moving\"){\n        node.send({payload:\"stop\"})\n    }\n    node.send({payload:\"open\"})\n        \n    \n}\n\nif(m ==='close'){\n    if(s===\"moving\"){\n        node.send({payload:'stop'})\n    }\n    node.send({payload:\"close\"})\n      \n}","outputs":1,"noerr":0,"x":448,"y":252,"wires":[["24d98ce3.3c9b44"]]},{"id":"24d98ce3.3c9b44","type":"debug","z":"e4ffbcc9.38355","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":602,"y":252,"wires":[]}]

Thanks for your flow. Already looked at it if it fits to my situation. But it isn't -.-

I don't know how long the button is pressed...
I get a msgload "open" when I press the button and "stop" when i release it...
So I need a flow or a logic where I can differate between "pressed <1 sec" and "pressed >1 sec"

Thanks for your answer. :+1:
I'm going to take a look at it later...
Need a little bit more time to understand your flow :wink:

You could possibly use a ui_template, add a div or button and use jQuery taphold and click to send distinct msgs to your flow.

https://www.w3schools.com/jquerymobile/tryit.asp?filename=tryjqmob_event_taphold

Or something like that.