Buttons, pressing and when to send messages

(I know: I'm making my own life difficult... but...)

I have a couple of projects - one of which I have already put up here - which are subflows to give you a safety feature that you have to double click a button before it toggles.

So Today's question is about how that should work.
Reason: I am wanting to make a similar subflow that doesn't have the TOGGLE feature.
But to get the button pressed, you still have to double press the button.

1 - I'm torn between making another subflow as opposed to adding to the existing one and adding the option so there is no toggle feature.
2 - Is this worth the effort? Though if you have protection on toggle buttons, you will need/want it on single press buttons. So there isn't much love lost on having a slightly bigger subflow than having TWO that do slightly different things.

With things as they are - on the existing subflow:
As you press the button, the output changes IN TIME with the buttons being pressed.
Then it re-asserts the final selection when you stop pressing the button.
Ok, it doesn't do that. Sorry.

Is this good/bad? -- semi rhetorical, as I can see reasons for doing this and problems if I don't. Although that is only one side of it, I feel it is probably better doing it this way.

So, the extra work needed to modify the existing code to make it Double click to activate has it's own set of questions:

Base line:
You must double click to get the output to change.

So what happens to the output if you quickly press the button THREE times?
(discuss)

Should the output then STAY at that signal or should it send a pulse message starting with .... 0. Send a 1 if/when the button is DOUBLE clicked then go back to the 0?
(discuss)

Or - only to make it more complicated:
Have both?
(again: discuss)

I am going batty thinking about what is the right way

Thanks in advance.

Why don't you just add an Are you sure? Notification node for critical buttons?

1 Like

I could. I just got hung up from my real world experience with buttons and pop up's don't exist. So a Double click option was the idea.

I have no idea what you mean by pop-ups not existing.

Well if you try and do something the complicated way then you must expect problems.

In the real world Colin... Not on computer screens.

I do expect problems. I therefore ask for people's thoughts on how to do things - but within the limits I am prepared to do.

I don't think that is unreasonable.

Such safeguards in real life actually require additional action
image

Or precise handling and/or attention
image

In other words - physically forced "I know what I'm doing" attitude.

If you targeting safety - you can't build it on top of something you can't really trust. If you can even say "but what if...", it is not safe anymore.

1 Like

I agree in a lot of ways.

It is just I am exploring that world.

Touch screens are problematic with on screen push buttons.
So I am just seeing what is/would be a good way to make it a little less possible to get accidental presses.

By using two physical actions like switch to enable action and button to fire the action.

Ok....

But.. (Sorry - brain failure this end) I'm still not equating it easily.

The best I can get from it is to have TWO buttons beside one another. One to enable the other.

Simple example with switch and button

[
    {
        "id": "4acb89a30b69f58e",
        "type": "ui_switch",
        "z": "2e6686c4918f199d",
        "name": "",
        "label": "safety lock",
        "tooltip": "",
        "group": "c7a27394.057878",
        "order": 14,
        "width": 4,
        "height": 1,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 230,
        "y": 2850,
        "wires": [
            [
                "d0fb6010062ab6ed"
            ]
        ]
    },
    {
        "id": "eea3e707e440f91b",
        "type": "ui_button",
        "z": "2e6686c4918f199d",
        "name": "",
        "group": "c7a27394.057878",
        "order": 15,
        "width": 5,
        "height": 1,
        "passthru": false,
        "label": "Action",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 570,
        "y": 2850,
        "wires": [
            [
                "7f2a4ffc73dbf79b",
                "086a722972596909"
            ]
        ]
    },
    {
        "id": "d0fb6010062ab6ed",
        "type": "change",
        "z": "2e6686c4918f199d",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "enabled",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 410,
        "y": 2850,
        "wires": [
            [
                "eea3e707e440f91b"
            ]
        ]
    },
    {
        "id": "7f2a4ffc73dbf79b",
        "type": "change",
        "z": "2e6686c4918f199d",
        "name": "disable ",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 700,
        "y": 2800,
        "wires": [
            [
                "4acb89a30b69f58e"
            ]
        ]
    },
    {
        "id": "44496964eaa7257e",
        "type": "inject",
        "z": "2e6686c4918f199d",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 170,
        "y": 2910,
        "wires": [
            [
                "4acb89a30b69f58e"
            ]
        ]
    },
    {
        "id": "086a722972596909",
        "type": "function",
        "z": "2e6686c4918f199d",
        "name": "actual action goes on",
        "func": "\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 740,
        "y": 2880,
        "wires": [
            []
        ]
    },
    {
        "id": "c7a27394.057878",
        "type": "ui_group",
        "name": "CHART",
        "tab": "54e197d8.7f7fe8",
        "order": 2,
        "disp": false,
        "width": "9",
        "collapse": false
    },
    {
        "id": "54e197d8.7f7fe8",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]
1 Like

Or use a notification 'Are you sure' pop-up as I suggested.

Yes, Colin, but as I have said, I am from a REAL WORLD background.

In the real world things don't just pop up from no where. So that option is a bit out of scope at this time.

Nice.... The only.... problem is there is no time out if you accidentally press the enable button.

But that's easily fixed.

Thanks. Food for thought.

Then perhaps you need to get a REAL WORLD (physical) isolation switch. And yes, you can get them cheap for Arduino/RPi.

Yes, but I am slowly migrating to touch screens and am looking at how to do that with them.

Trying to make sure I understand here. If I understand correctly then you have a button, but you want to make sure it is not pressed accidentally, and am looking for the best strategy to use to prevent this.
I suggested using a popup notification node to ask for confirmation but you said that you don't like this because it is too far removed from what you might expect for a physical button. Instead you are trying to use double click to prevent accidental pressing. As far as I can remember I have never seen a hardware button that you have to press twice to achieve an action. Hardware buttons are usually press once and for on and press again for off, or possibly press once for an action, and press again to repeat the action. So a double press seems as far from the 'real world' as a popup, in fact further from the real world because there one would usually expect a double click to switch it on and then off again.

You are correct. But I am messing around with touch screens.
Real estate is scarce. Although @hotNipi did suggest putting a switch node to act as the enable That is fair enough too.

I have taken that on for a couple of things. It is better in some ways.

If the real life button is a press button, the hardware can do the double press detection.
You press it and a pulse is sent. That awakens the circuit downstream. Then the second press gets the job done.
Yes, that entails a lot of extra stuff with lights/indicators showing what is going on.
But as this is/can all be done with messages..... I thought it would be an interesting way to do it.

I have - since - got a nice subflow working that does both what I originally wanted to do and also does that to which I just eluded.

I'm kind of pleased with myself as I have very little understanding of what I am actually doing at a programatic level.
I don't know/can't talk javascript.
I don't know the commands.
I just dig around until I get something doing what I want.

I am trying to make it tidy, as I write messy code. Just ask a few people with whom I have been getting help.

OK, so 'real life' means something that can be done by hardware, even though it is never (or rarely) done in practice. It would not be that difficult to arrange that when a button is pressed it levers up a little notice that says "Press to Confirm" and when it is pushed back down it triggers the action. So a notification popup is just as much 'real life' as a double press, and much more intuitive for the user.

In real life, sometimes you find panels where critical functions are activated by simultaneously pressing two buttons which I find not too bad. Like the panel below, you have to press SOS on both sides (is a double button) at the same time when calling for help. But if it would be possible with a touch panel, I do not know

image

I suggest you create one small button "Enable Controls". Touch that and the other buttons on the screen are active for 5 seconds.

Pretty easy to implement: the enable button opens a simple-logic-gate, a trigger node closes it again.

As for popups: I've lost count of the number of Windows PCs I've defenestrated due to infuriating "are you sure?" popups.

1 Like