dxdc/homebridge-blinds

Add polling for position_url

dxdc opened this issue · 10 comments

dxdc commented
  • Add a refresh frequency to config which correlates to position_url.
  • Poll before sending move commands

Hi,

any idea when you could implement this ? I have the issue that when my domotica system changes the state of the blinds (using wall inputs for example), the status in homekit becomes either "opening ..." or "closing..." because the pos is different from the last requested target position.

or do you see any other way around this ?

Thanks by the way for all your great work !

Benjamin

dxdc commented

Hi Benjamin,

I've been quite busy, but thanks for the reminder. I just implemented it, but have no way of testing it. Can you please enable verbose as well for the settings, and let me know how this works for you? I'm curious especially to see the logs.

sudo npm install -g homebridge-blinds@1.3.24-beta
# restart homebridge

Hi, Thanks !

I get a bind error, probably for the webhook I configured ... Downgraded to 1.3.23 and works again.
what are the config settings for the polling frequency by the way ?

[6/29/2021, 11:03:02 AM] [bureau screen] Initializing BlindsHTTP accessory...
[6/29/2021, 11:03:02 AM] TypeError: Cannot read property 'bind' of undefined
    at BlindsHTTPAccessory.updatePositionByUrl (/homebridge/node_modules/homebridge-blinds/index.js:362:7)
    at new BlindsHTTPAccessory (/homebridge/node_modules/homebridge-blinds/index.js:107:14)
    at /usr/local/lib/node_modules/homebridge/src/server.ts:350:50
    at Array.forEach (<anonymous>)
    at Server.loadAccessories (/usr/local/lib/node_modules/homebridge/src/server.ts:270:29)
    at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:162:12)
dxdc commented

Thanks for the quick reply. I made a slight change to the code, please try

sudo npm install -g homebridge-blinds@1.3.25-beta.2
# restart homebridge

Seems to work ! Great stuff, thanks ! Now I can get rid of the webhook workaround I had scripted.

[6/29/2021, 5:28:49 PM] [slaapkamer screen] Polling started (updatePositionByUrl)
[6/29/2021, 5:28:49 PM] [slaapkamer screen] Request succeeded in 4 ms after 1 / 5 attempts
[6/29/2021, 5:28:49 PM] [slaapkamer screen] Body (200): 100
[6/29/2021, 5:28:49 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 100
[6/29/2021, 5:28:49 PM] [slaapkamer screen] Polling finished (updatePositionByUrl)
dxdc commented

Great! Please keep me posted throughout testing. If it's all working as expected, I can push it as a new official release soon.

maybe spoke to soon. I tried to drop the blind down to 82% (in homekit) and then used the domotics system to open it up to 100% again, but it won't poll:

[6/29/2021, 5:45:33 PM] [slaapkamer screen] Requested Move down (to 82%)
[6/29/2021, 5:45:33 PM] [slaapkamer screen] Request succeeded in 98 ms after 1 / 5 attempts
[6/29/2021, 5:45:33 PM] [slaapkamer screen] Body (200): {"status":"OK","success":true}

[6/29/2021, 5:45:33 PM] [slaapkamer screen] Move request sent (98 ms), waiting 3.6s (+ 0s response lag)...
[6/29/2021, 5:45:33 PM] [slaapkamer screen] Stop command will be requested
[6/29/2021, 5:45:33 PM] [slaapkamer screen] Timeout finished
[6/29/2021, 5:45:37 PM] [slaapkamer screen] Requesting stop
[6/29/2021, 5:45:37 PM] [slaapkamer screen] Request succeeded in 99 ms after 1 / 5 attempts
[6/29/2021, 5:45:37 PM] [slaapkamer screen] Body (200): {"status":"OK","success":true}

[6/29/2021, 5:45:37 PM] [slaapkamer screen] Stop request sent
[6/29/2021, 5:45:37 PM] [slaapkamer screen] Request succeeded in 6 ms after 1 / 5 attempts
[6/29/2021, 5:45:37 PM] [slaapkamer screen] Body (200): 100
[6/29/2021, 5:45:37 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 100
[6/29/2021, 5:45:41 PM] [slaapkamer screen] Request succeeded in 6 ms after 1 / 5 attempts
[6/29/2021, 5:45:41 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:41 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:42 PM] [slaapkamer screen] Request succeeded in 3 ms after 1 / 5 attempts
[6/29/2021, 5:45:42 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:42 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:42 PM] [slaapkamer screen] Blinds position didn't change: skipping 3 cycles
[6/29/2021, 5:45:43 PM] [slaapkamer screen] Requested TargetPosition: 82%
[6/29/2021, 5:45:43 PM] [slaapkamer screen] Request succeeded in 5 ms after 1 / 5 attempts
[6/29/2021, 5:45:43 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:43 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:44 PM] [slaapkamer screen] Request succeeded in 5 ms after 1 / 5 attempts
[6/29/2021, 5:45:44 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:44 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:44 PM] [slaapkamer screen] Blinds position didn't change: skipping 4 cycles
[6/29/2021, 5:45:45 PM] [slaapkamer screen] Request succeeded in 4 ms after 1 / 5 attempts
[6/29/2021, 5:45:45 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:45 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:45 PM] [slaapkamer screen] Blinds position didn't change: skipping 5 cycles
[6/29/2021, 5:45:47 PM] [slaapkamer screen] Request succeeded in 4 ms after 1 / 5 attempts
[6/29/2021, 5:45:47 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:47 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:47 PM] [slaapkamer screen] Blinds position didn't change: skipping 6 cycles
[6/29/2021, 5:45:49 PM] [slaapkamer screen] Request succeeded in 6 ms after 1 / 5 attempts
[6/29/2021, 5:45:49 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:49 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:49 PM] [slaapkamer screen] Blinds position didn't change: skipping 7 cycles
[6/29/2021, 5:45:49 PM] [slaapkamer screen] Polling skipped (updatePositionByUrl); stopTimeout: 81523, stepInterval: 81529, lagTimeout: 81524
[6/29/2021, 5:45:51 PM] [slaapkamer screen] Request succeeded in 6 ms after 1 / 5 attempts
[6/29/2021, 5:45:51 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:51 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:51 PM] [slaapkamer screen] Blinds position didn't change: skipping 8 cycles
[6/29/2021, 5:45:54 PM] [slaapkamer screen] Request succeeded in 8 ms after 1 / 5 attempts
[6/29/2021, 5:45:54 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:54 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:54 PM] [slaapkamer screen] Blinds position didn't change: skipping 9 cycles
[6/29/2021, 5:45:56 PM] [slaapkamer screen] Request succeeded in 4 ms after 1 / 5 attempts
[6/29/2021, 5:45:56 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:56 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:56 PM] [slaapkamer screen] Blinds position didn't change: skipping 10 cycles
[6/29/2021, 5:45:59 PM] [slaapkamer screen] Request succeeded in 4 ms after 1 / 5 attempts
[6/29/2021, 5:45:59 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:59 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:59 PM] [slaapkamer screen] Didn't reach target after 11 tries
[6/29/2021, 5:45:59 PM] [slaapkamer screen] Request succeeded in 4 ms after 1 / 5 attempts
[6/29/2021, 5:45:59 PM] [slaapkamer screen] Body (200): 85
[6/29/2021, 5:45:59 PM] [slaapkamer screen] Requested setCurrentPositionByUrl: 85
[6/29/2021, 5:45:59 PM] [slaapkamer screen] Reached target: 82, currentPosition: 85, manualStop: Y
[6/29/2021, 5:45:59 PM] [slaapkamer screen] End Move down to 85% (target 82%)
[6/29/2021, 5:46:19 PM] [slaapkamer screen] Polling skipped (updatePositionByUrl); stopTimeout: 81523, stepInterval: null, lagTimeout: 81524
[6/29/2021, 5:46:49 PM] [slaapkamer screen] Polling skipped (updatePositionByUrl); stopTimeout: 81523, stepInterval: null, lagTimeout: 81524
[6/29/2021, 5:47:19 PM] [slaapkamer screen] Polling skipped (updatePositionByUrl); stopTimeout: 81523, stepInterval: null, lagTimeout: 81524
[6/29/2021, 5:47:49 PM] [slaapkamer screen] Polling skipped (updatePositionByUrl); stopTimeout: 81523, stepInterval: null, lagTimeout: 81524
[6/29/2021, 5:48:19 PM] [slaapkamer screen] Polling skipped (updatePositionByUrl); stopTimeout: 81523, stepInterval: null, lagTimeout: 81524
[6/29/2021, 5:48:49 PM] [slaapkamer screen] Polling skipped (updatePositionByUrl); stopTimeout: 81523, stepInterval: null, lagTimeout: 81524
dxdc commented

Your log was quite helpful. Please try:

sudo npm install -g homebridge-blinds@1.3.25-beta.3
# restart homebridge

Looks OK now, did some tests and all seems to be fine now. I'll keep you updated if I find some other issues.
Thanks !

dxdc commented

Great. Please do keep me posted if you notice any other behavior. Thanks for testing!