lprhodes / homebridge-broadlink-rm

Broadlink RM Mini and Pro plugin for homebridge: https://github.com/nfarina/homebridge
Apache License 2.0
571 stars 285 forks source link

Add config key in window-covering to offset motor response lag time #706

Open willhains opened 3 years ago

willhains commented 3 years ago

The window-covering config has keys totalDurationOpen and totalDurationClose, and accepts hex codes for open, close, and stop, allowing for percentage-open control, based on linear time interpolation.

This is great, except that I find with my curtains, there is a small delay after sending the open/close command before the motor actually starts moving, and this introduces error for percentage-open controls. When setting to the same percentage-open value, the physical result depends on whether it started fully open or fully closed.

To fix this, how about adding another key, say, motorLagTime, to compensate for this delay?

For example: with the following config:

"totalDurationOpen" = 6000,
"totalDurationClose" = 6000,
"motorLagTime" = 400

Starting at the fully-closed (0%) position, setting the curtain to 50% would send the open hex code, wait 6000 / 2 + 400 = 3400ms, and then send the stop hex code. It would be the same 3400ms in the opposite direction, from fully-open (100%) to 50%. The waiting time is asymmetrical, but because of the motor delay, the curtain ends up physically at the same position.