Return to home screen - monitor user screen activity

I am trying to build a flow to return to the home dashboard (with time and date) after x minutes of inactivity:

  • ui_control signals the change of dashboard.
  • function node starts a countdown timer if the dashboard name is not equal to home
  • when the countdown timer expires, it triggers a ui control to switch to the home dashboard.

I want to reset the timer in case of user activity so it will not time-out and trigger a dashboard switch if a user is active on a dashboard.

How can I trigger a timer reset if there is user activity without having to modify each and every button? (sort off on_click or on_touch event) Is there a node that I can use that will trigger an output if a user clicks any of the buttons on a dashboard? Note, the primary interface is a touchscreen.

Node-red v1.0.6
Node-red-dashboard v2.21.0
Running on a Raspberry PI 4+
Connected to an ELO touchscreen with USB

This is not completely what you want but it can help you started.
Designed it for a touchpanel, but never used in production so not sure if it works flawless.

The GetChanges Ui_control keeps a track on what client is clicking, it identifies the client with the ip number. Handy if you want the touchscreen in the bedroom uses an other default tab then the touchscreen in the living room.
In NotMydefaultTab the flow will check if the default tab (in this case tab 0) is active. If not then the trigger node will start and after 60 seconds the default tab "Verlichting" will be shown.
If tab is already the default tab 0 the trigger node will be reset.
You need to add yourself that the trigger node get trigger by the elements on your dashboard to reset the 60s countdown.

Have fun.

[{"id":"c6c67e1c.63cb1","type":"ui_ui_control","z":"b3f31bbd.8966b8","name":"GetChanges","x":130,"y":140,"wires":[["3b5784d6.3a6fc4"]]},{"id":"3b5784d6.3a6fc4","type":"switch","z":"b3f31bbd.8966b8","name":"Device 192.168.1.22","property":"socketip","propertyType":"msg","rules":[{"t":"eq","v":"192.168.1.22","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":360,"y":140,"wires":[["75e63278.81e8bc"]]},{"id":"75e63278.81e8bc","type":"switch","z":"b3f31bbd.8966b8","name":"NotMyDefaultTab","property":"tab","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":140,"wires":[["b26b3f08.05074","c90ba11a.63bb58"],["19f67583.822112","d1c8b53d.5e7f3"]]},{"id":"b26b3f08.05074","type":"trigger","z":"b3f31bbd.8966b8","op1":"","op2":"Verlichting","op1type":"nul","op2type":"str","duration":"60","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":1090,"y":140,"wires":[["215cff6e.0a66b"]]},{"id":"215cff6e.0a66b","type":"ui_ui_control","z":"b3f31bbd.8966b8","name":"","x":1300,"y":140,"wires":[[]]},{"id":"d1c8b53d.5e7f3","type":"change","z":"b3f31bbd.8966b8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":180,"wires":[["b26b3f08.05074"]]},{"id":"c90ba11a.63bb58","type":"debug","z":"b3f31bbd.8966b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":860,"y":100,"wires":[]}]

Thanks for your prompt reply. With respect to: "The GetChanges Ui_control keeps a track on what client is clicking" :

I understand this is based on a ui_control node that responds to changes of the dashboard tab, I have taken a closer look t the output but it does not seem to respond to buttons clicked, sliders changed or other controls on the dashboard that have been updated?

I am looking for a node that will respond to these kind of events. Every time a button is clicked or a slider is moved (indicating the user is still active), the node should create an event that resets the timer. If the user is inactive, there will not be a timer reset and after the timer reaches zero, the ui-control triggers a change to the home screen.

respond to buttons clicked, sliders changed or other controls on the dashboard that have been updated?
I am looking for a node that will respond to these kind of events.

The buttons, sliders, other controls have an output port on the node, which emit these changes.

I have it setup like that right now but with many elements its a lot of wiring. I am trying to avoid having to wire up every single button, slider, etc. to the reset of the countdown timer. It would be nice to have a node that triggers an output if any element.

You can use a status node, that will emit all changes on the flow tab (ie changes per tab only).

Bakman2, yes that provides the functionality I am looking for. Definitely less hassle than wiring the output of every UI element.

Thank you all for thinking with me, hope to be able to return the favor in the future :slight_smile:

The setup:

  • Home screen with two buttons (Date and Time)
  • Clicking either of the buttons will change to the Main screen and start a count down timer
  • When the time expires, the UI control changes the screen back to the Home screen
  • If a button or slider is touched on the Main screen, the timer is reset.

Background: using this setup because if the screensaver blanks the touchscreen when the Main screen is shown, waking it up by touch the screen will also click a button you cannot see.

2 Likes

Nice idea, I had the same challenge with a raspberry pi screen. Pushing a button when trying to wake up the screen. But using the strength of node red and the pi, I connected a movement sensor to a gpio and with an exec node I can wake the screen up.

xset -display :0 s reset && xset -display :0 dpms force on

This command is for the raspberry pi screen, it should be also available for the signal for the ELO

I have used vcgencmd display_power 0 to turn the screen off and vcgencmd display_power 1 to turn it back on remotely if I for example want to show a camera that is triggered by motion. Using an Exe node that responds to a MQTT message. My home automation system gathers wake-up triggers from a wealth of signals and decides to wake up the screen based on time of day, security system status, etc.. Have not yet managed to put a motion sensor in place that is accurate enough to turn on the touchscreen if the user is close, and more important, not trigger if a user just walks by...

Indeed this! For this you should find a proximity sensor. Except the ultrasonic standard arduino I have no experience with them but a quick google search shows some nice stuff.

Emil,

This might be a basic question (caused by my very limited knowledge of Linux) but maybe you can point me in he right direction.

When I open a command prompt in a VNC session using xset dpms force on and xset dpms force off work as expected, but when I try to use a exec_node the execution fails with the following error message:
Code 128
/bin/sh: 1: xset dpms force on: not found

Any idea how to solve this?

Try putting the full path to the xset command. The environment that node-red runs in may not have the path setup. You can find where it is by running which xset which will say something like /usr/bin/xset, in which case us the command /usr/bin/xset dpms force on. Also make sure Append Payload is not set in the exec node config. I am not certain that it will work in an exec node though, it may need to be running in an X session.

[Edit] You might need the display: specification in the command.

Thx Colin.

I tried the path
image

but that does not work either.
image

I am confused about the additional path shown:
image

I guess that is wat is causing the issues.

/bin/sh is the shell programme trying to run the command. Why have you got quotes round the command? Try taking those off. I think the quotes are telling the shell to look for a script called /usr/bin/xset dbps force off which isn't what you want.

Well I finally got it sorted out, thanks for all suggestions!

I first tried the suggestion to leave out the quotes (just /usr/bin/xset dbps force off in the exec_node) but that ended in an error message: /usr/bin/xset: unable to open display Searching for this error I found many posts but no solution until this morning.

Following the guidance in the script, I created a script (DispON)
#!/bin/sh
export DISPLAY=:0.0
# Turn off display
xset dpms force off

And refer to the script in the exec node: /home/pi/DispON

That works like a charm :slight_smile:

2 Likes

Did you try using that technique, suggested by @EmilWesselink a few posts back in this thread? I did say you might need to specify which display you wanted to control.

Yes I did but could not get anything to work that did not use a script as an intermediate... Not sure if this was maybe caused by using the quotes, and me mis-understanding the guidance provide by the node: Commands or parameters with spaces should be enclosed in quotes

When I have the time later today, I will give it another try and report back.

That means if the actual command (xset in this case) or individual parameters (such as dpms or force or on in this case) had spaces then that individual parameter or command should be in quotes. So if, for example, you wanted to use the mv command to rename a file called some filename to some other filename then you would use
mv "some filename" "some other filename"

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.