I am not a programmer, but i like to tinker with home assistant and electronics. I work in the HVAC and i installed a ventilation system.
I am controlling the following:
Fan speed 0-10V
Zone valve for bedroom
Zone valve for living room
Everything is connected to home assistant and for automations i am using a node red integration.
I have 2 flows:
1 for the speeds and zones (this is full of booleans)
1 for the actual logic based on CO2 (unstable)
My program is working (it took me a long time to get it this far) but sometimes it becomes unstable. The cause is that the CO2 values fluctuate too fast for the controle system.
One annoying bug in the dimmer is that if i go from 100% to 80% it turns off. If i turn it to 78% first and then back up to 80% it works. Thats why the flows in the speed and zones are so large.
What i am trying to do is use the smooth function to get the average of the previous 3 values. Every 5 minutes i retrieve the CO2 value, and this starts the logic.
My problem is that my CO2 value is in an object. And even though i have the smooth function and set to number, the original value of the CO2 is sent to the next node.
What i think is the solution:
-Change the object to a number
Run number through the smooth node
Change back to object ( because all logic is looking to the specific entity payload)
That's quite a comprehensive flow you have built. To me it seems full of HA nodes - I can't see any Node-RED nodes. Not many people on this forum use HA, so you may get a better response from the HA forum.
Thank you for your message. I tried it, but no luck. See image for config and input/output. The debug at the end does not show up, but somehow the original CO2 value still reaches the end.
Well. Of course it doesn't & does. As I had no idea how your data object looks like, I tried to make a guess. At least you should have adapted this guess to your real situation.
Based on what I see here, there's even no need to shuffle things around with the change nodes. msg.payload already seems to hold the co2 value. What do you expect to get at the end of this flow?
Thanks for your reply. With the smooth node i would like to get the average of the 4 latest values. So if someone walks by the co2 sensor sometimes you see a spike.
According to the picture you provided, this flow should do exactly what you expect.
If it doesn't you needed to share the flow source to allow a deeper view into the details.
Please substitute the first HA node then with an inject node that send representative data.