nikkow / node-red-contrib-tahoma

Node-RED module to control a Somfy Tahoma box (Roller shutters...). Used for home automation flows.
Apache License 2.0
19 stars 11 forks source link

Add buffer for the final position of the blinds #34

Closed marekhalmo closed 4 years ago

marekhalmo commented 4 years ago

If you command the blinds to go to a specific position the motor might go a bit too far or a bit too short.

The code checks the actual position already and if this happens the node wont be in the proper state and will still be marked as moving.

Example: Command: customPositon, position 60 Blind goes to 58 and stops (good enough).. the node is stuck in state "Going to 60%"

I assume there should be some sort of buffer (e.g. 2-5%) in the code in tahoma.ts (line 28) if (currentPosition === expectedState.position)

.. i'm not that good with javascript, i'm sure it would be easy to add some sort of (abs(currentPosition-expectedState.position) < 5) check

would also be nice to have some sort of status reporting output (actual state)

Thank you!

nikkow commented 4 years ago

Hi @marekhalmo,

Thanks for the improvement suggestion. This is indeed a good idea. I will definitely add a buffer. I will run some tests on my appliances to determine the best value for this.

marekhalmo commented 4 years ago

@nikkow how long does it take from the command untill your blinds move? It seems that the somfy app has a latency somewhere around 500ms but my blinds take sometimes more than 5seconds to move.. might be someting wrong with my setup..

nikkow commented 4 years ago

Hi @marekhalmo,

Sorry, I kinda missed your last comment. I did a couple of tests and did not observe any high latency. The blinds tend to move instantly after being triggered. Can you be a bit more specific about your setup? Mine is pretty basic:

node-red instance hosted on a wired RPi on the same LAN than the Tahoma (even if it should not have any impacts, since everything goes through their cloud). Also tried to set up a brand-new instance of node-red on my (wireless) MacBook and did not manage to reproduce high latencies.

marekhalmo commented 4 years ago

Hello @nikkow. It seems that it depends on the connection to some US servers + latest update seems to decrease the time between when the next blind moves (if you command multiple blinds). The original issue still persists, did you make any proggress??

nikkow commented 4 years ago

@marekhalmo, I have added a 5% buffer to the expected position check. If you set a customPosition of 50, the node will consider the range 47,5-52,5 as valid (though I'm not sure Somfy returns decimals).

I've also added an exception. When the expected position is 0 or 100, then the buffer is disabled (if I want to fully close the blinds, I'd expect them to be fully closed, not 95% closed).

This will be included in the next release.

marekhalmo commented 4 years ago

@nikkow That is awesome.. thank you!