Que messages and send with specific rate

I have a feeling that when messages comes too fast the call service gets clogged up and drops the messages.

So to test my theory I want to be able to set a rate the messages is passed to the call service.

I’ll explain it with an example:

time     message      delay        time of call service
0          1            0                 0
0.1        2            0                 0.1
0.15       3            0.05              0.2
0.3        4            0                 0.3  
0.5        5            0                 0.5
0.52       6            0.08              0.6

So if messages comes with less than 0.1 second delay between each other then delay them to happen with at least 0.1 seconds in between them, and if the time between this message and the previous is more than 0.1 second then there is no need for a delay.

I’m not sure the delay should be 0.1 seconds, maybe it needs to be 0.3.
The only node I know of is the delay node, but I don’t want to delay if no delay is needed.
Does anyone have an idea on how to test the above?

So the logic would need to compute in less than 0.1 as well. The interval length node can be set to send a message based on min message interval. Then could be sent to a change to program a delay node.

I just don’t think it will happen fast enough. The second message and the message containing the interval info are sent at the same time. It’s too bad that the node doesn’t allow you to just set a min delay.

This probably be best accomplished with a function node. I also, personally, would pose this question on the nodered forum since this a nodered processing question.

I don’t think this should be an issue unless your call-service node is receiving thousands of inputs every couple of milliseconds.

I tested it with 10, 100, 1000, and 1 million requests and it was HA that closed the connection because it NR filled its message queue. It still was able to process around 7k messages before the queue filled.

2021-09-01 00:32:07 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140315601471088] Client exceeded max pending messages [2]: 2048

Create the counter helper in HA to see if HA is receiving all the requests.

image

[{"id":"713c5c3373faee7f","type":"inject","z":"ffbd7f06.4a014","name":"send 10","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":306,"y":1440,"wires":[["7e78d6a151f90482"]]},{"id":"337001fea73b3039","type":"api-call-service","z":"ffbd7f06.4a014","name":"","server":"","version":3,"debugenabled":true,"service_domain":"counter","service":"increment","entityId":"counter.test","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":644,"y":1440,"wires":[[]]},{"id":"7e78d6a151f90482","type":"function","z":"ffbd7f06.4a014","name":"","func":"for (let index = 0; index < msg.payload; index++) {\n    node.status(index);\n    node.send(msg);    \n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":462,"y":1440,"wires":[["337001fea73b3039"]]},{"id":"f8c37e9387308d6f","type":"inject","z":"ffbd7f06.4a014","name":"send 100","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":318,"y":1472,"wires":[["7e78d6a151f90482"]]},{"id":"4631dc7b1441743d","type":"inject","z":"ffbd7f06.4a014","name":"send 1000","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1000","payloadType":"num","x":318,"y":1504,"wires":[["7e78d6a151f90482"]]},{"id":"86444728cc6238c2","type":"inject","z":"ffbd7f06.4a014","name":"send 1000000","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1000000","payloadType":"num","x":328,"y":1536,"wires":[["7e78d6a151f90482"]]}]
2 Likes

I’ll have a look at this then.
Thank you both for your suggestions.

The reason I think it’s clogged up is because I use the IKEA volume control and if I spin it at a speed of say 100%, I get 100% volume control.
But if I go to 120% I only get 50-70% volume control (estimated).
It feels like every other message is dropped.

It’s counter intuitive to slow down to get a better output