Is this considered bad practice, or could it be a bad idea to do this?
Every time I receive a sensor reading from one of many Arduinos around the home, I write the sensor data to a global context object, then read all objects (all sensors) from memory to display on the Dashboard.
To be clear, this happens every time a sensor reading comes in. Although the incoming MQTT message triggers the Dashboard update, the data comes from Global Context, not passed through the flow (hope that makes sense).
Is this a bit over the top? Not so much the fact I write sensor data to Global Context, but that I call on Global Context every time I want to update a Dashboard view etc.?
I could probably update the part of the dashboard that corresponds to that sensor (rather than reading all data from all sensors every time one sensor updates, which is a bit illogical) but I'm doing the whole lot through a template node that displays a table of all sensors so this seems easiest. Also I know technically I could just pass the sensor data straight through to the dashboard but I combine it with stuff from memory to be able to monitor the state and compare it with previous readings etc. (e.g. a "last seen" and "device up status" etc. which would require a notification when the device was previously up, then went down.) A really general answer would be fine!
Right now I have two sensor nodes sending readings every 2 seconds each. So I'm reading an object of objects say every second and displaying on the Dashboard in a template node. I'm going to extend the period to 5 or 10 seconds eventually, but I may also increase the number of nodes in my home to 50 or even 100.
Sorry if my question is a bit "how long is a piece of string"... but is this
- perfectly fine
- keep an eye on performance
- bad idea
- really bad idea, never do this?
I know this question would be downvoted on Stack Exchange (!) because it depends on a lot, e.g. server hardware. To give an idea, I run NodeRED not on a Pi, but on a Hyper-V virtual machine running on a proper Dell server with 192GB RAM and decent dual processors. But it's more of a general "should I or shouldn't I" question and might steer me a little in my design decisions!