QuickSander / homebridge-http-curtain

Homebridge plugin to operate web based/http curtains with push position updates.
Other
2 stars 3 forks source link

Unable to use a pattern to retrieve current position #1

Closed ThomB63 closed 4 years ago

ThomB63 commented 4 years ago

Hello,

First of all, excuse my English because I'm French. Then, thanks for the plugin :)

I try to configure the config.json to have the current status position of my curtain. My url request gives the results : "{ "success": 1, "body":{"last_value": 0} }" where the last_value starts from 0 to 100 and gives the current position.

The plugin can't read the current status and it gives the value "Position value is currently at: NaN%" in Homebridge. Have you got an idea to solve my problem ?

This is my configuration

"name": "Lames Pergola", "notificationID": "my-http-curtain", "getCurrentPosUrl": { "url": "https://api.eedomus.com.......", "method": "GET", "statusPattern": "([0-9]{1,3})" }, "setTargetPosUrl": { "url": "http://..........value=%d", "method": "POST" }, "pullInterval": 30000, "debug": true, "accessory": "HttpCurtain"

Thanks in advance, Thomas

QuickSander commented 4 years ago

Hi Thomas, pardon my English, I'm from The Netherlands.

The plugin currently does not support parsing JSON body data to retrieve the position. From the README: "It currently expects the http server to return a integer ranging from 0-100 (step 1) leaving out any html markup.".

However, I do foresee I should be able to add it quite easily. currently your "statusPattern" keyword is being ignored.

ThomB63 commented 4 years ago

Hello, Thank you for your response and your responsiveness. I will wait impatiently for the evolutions of the plugin. Do you have an idea of ​​the deadline? Thank you Thomas

QuickSander commented 4 years ago

Please update to 1.0.1 and use getCurrentPosRegEx = '([0-9]{1,3})' (not within the getCurentPosUrl object). Let me know if it works.

ThomB63 commented 4 years ago

Thanks for the update.

It doesn't work with this config:

"name": "Lames Pergola", "notificationID": "my-http-curtain", "getCurrentPosUrl": { "url": "http://xxxx", "method": "GET" }, "getPositionStateUrl": { "method": "GET" }, "setTargetPosUrl": { "url": "http://xxxvalue=%d", "method": "POST" }, "setCurrentPosRegEx": "([0-9]{1,3})", "getTargetPosUrl": { "method": "GET" }, "identifyUrl": { "method": "GET" }, "pullInterval": 60000, "debug": true, "accessory": "HttpCurtain"

This is the log : "[2020-6-15 22:34:24] [Lames Pergola] Target position retrived from cache: 20% [2020-6-15 22:34:25] [Lames Pergola] Position value is currently at: NaN%"

I think there is an other problem with the regex pattern because with this one, it reads only "1" if I don't make a mistake (the result of my url is "{ "success": 1, "body":{"last_value": 0} }").

ThomB63 commented 4 years ago

I also try with this config and it's the same.

{ "name": "Lames Pergola", "notificationID": "my-http-curtain", "getCurrentPosUrl": { "url": "http://", "method": "GET", "setCurrentPosRegEx": "([0-9]{1,3})" }, "getPositionStateUrl": { "method": "GET" }, "setTargetPosUrl": { "url": "http:value=%d", "method": "POST" }, "getTargetPosUrl": { "method": "GET" }, "identifyUrl": { "method": "GET" }, "pullInterval": 60000, "debug": true, "accessory": "HttpCurtain" }

QuickSander commented 4 years ago

My apologies I used set instead of get in my original example. Please use: getCurrentPosRegEx.

You should see something similar to "...regular expression match: ..." in the debug log.

You can also use config-ui-x to graphically edit settings.

ThomB63 commented 4 years ago

It works, thanks !

But the regex is not good because it reads only the first 1. I'm not familiar with regex, have you got an idea of which one I have to write ?

QuickSander commented 4 years ago

“\”last_value\”: *([0-9]{1,3})”

May I ask what brand of curtains or window blinds you use?

ThomB63 commented 4 years ago

Thanks for help :)

I try this pattern but it doesn’t work….This is the error message in the log :

[2020-6-16 21:07:33] TypeError: Cannot read property 'length' of null at /usr/lib/node_modules/homebridge-http-curtain/index.js:191:32 at Request._callback (/usr/lib/node_modules/homebridge-http-curtain/node_modules/homebridge-http-base/src/http.ts:95:13) at Request.self.callback (/usr/lib/node_modules/homebridge-http-curtain/node_modules/request/request.js:185:22) at Request.emit (events.js:315:20) at Request. (/usr/lib/node_modules/homebridge-http-curtain/node_modules/request/request.js:1154:10) at Request.emit (events.js:315:20) at IncomingMessage. (/usr/lib/node_modules/homebridge-http-curtain/node_modules/request/request.js:1076:12) at Object.onceWrapper (events.js:421:28) at IncomingMessage.emit (events.js:327:22) at endReadableNT (_stream_readable.js:1221:12) [2020-6-16 21:07:33] Got SIGTERM, shutting down Homebridge... [2020-6-16 21:07:38] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null [2020-6-16 21:07:43] [HB Supervisor] Restarting Homebridge...

Do you have an idea of the problem ?

Thanks

Tom

Le 16 juin 2020 à 07:39, Sander notifications@github.com a écrit :

“\”last_value\”: *([0-9]{1,3})”

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/QuickSander/homebridge-http-curtain/issues/1#issuecomment-644542491, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3QU66BXWVUWGKTJXOAMZLRW4AS3ANCNFSM4N22XOLQ.

QuickSander commented 4 years ago

It means it didn't match anything in the result returned by the server. If you copy/pasted the example, make sure to replace the quotes with normal double-quotes.

ThomB63 commented 4 years ago

It works perfectly. Thanks a lot and thanks for your job ! You’re very talented !

Le 16 juin 2020 à 22:06, Sander notifications@github.com a écrit :

It means it didn't match anything in the result returned by the server. If you copy/pasted the example, make sure to replace the quotes with normal double-quotes.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/QuickSander/homebridge-http-curtain/issues/1#issuecomment-644984740, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3QU64KIXNU3WOEN7BEKKLRW7GFFANCNFSM4N22XOLQ.

ThomB63 commented 4 years ago

Hello,

Is it possible to have regex on the other « get » url ? When I open Home on iPhone and the state of the accessory have been changed from an other way (like the radiocommand for example), Home doesn’t arrive to know the actual position and there is « opening » on the app without changing...

Thank you very much

Le 16 juin 2020 à 07:39, Sander notifications@github.com a écrit :

“\”last_value\”: *([0-9]{1,3})”

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/QuickSander/homebridge-http-curtain/issues/1#issuecomment-644542491, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3QU66BXWVUWGKTJXOAMZLRW4AS3ANCNFSM4N22XOLQ.

QuickSander commented 4 years ago

HomeKit compares targetPos and currentPos. If these are equal, HomeKit considers it open or closed. Does your curtain support targetPos? If not, then you can leave the getTargetPosUrl empty and the plugin will take care to cache and return the targetPos.

ThomB63 commented 4 years ago

The plugin seems to keep in memory the last value given in HomeKit and I think that’s the reason, when I changed the value from an other way, HomeKit doesn’t recognize the new « target » position and it shows « closing » or « opening » with no ending.

For me, the target position is the same value that current position, that’s why I think if I have pattern on the gettargetpos, I can resolve my problem...

Le 20 juin 2020 à 09:30, Sander notifications@github.com a écrit :

HomeKit compares targetPos and currentPos. If these are equal, HomeKit considers it open or closed. Does your curtain support targetPos? If not, then I need to check if targetPos is set in the plugin automatically.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/QuickSander/homebridge-http-curtain/issues/1#issuecomment-646957565, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3QU627NW5UZWBFLQHG7A3RXRQPVANCNFSM4N22XOLQ.

ThomB63 commented 4 years ago

Hello QuickSander,

I let myself revive you. Do you have a solution for my problem? Whenever the value is modified by a device other than Homekit, Homekit no longer recognizes the value and systematically marks "opening" or "closing". thank you in advance Tom

QuickSander commented 4 years ago

Thanks, slipped my mind, will try to free up some evening to apply the same trick to the getTargetPosition. Do realise that if you use the same URL for target and current position, homekit will always think it is directly closed or opened. So it is sort of the inverse of your current behaviour.

ThomB63 commented 4 years ago

Thanks. I think it will be perfect for me :)

Thanks for your good job

Le 28 juin 2020 à 23:12, Sander notifications@github.com a écrit :

Thanks, slipped my mind, will try to free up some evening to apply the same trick to the getTargetPosition. Do realise that if you use the same URL for target and current position, homekit will always think it is directly closed or opened. So it is sort of the inverse of your current behaviour.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/QuickSander/homebridge-http-curtain/issues/1#issuecomment-650822408, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3QU677JUPRUE5PCIPAK2DRY6W5LANCNFSM4N22XOLQ.

QuickSander commented 4 years ago

Hi, see: https://github.com/QuickSander/homebridge-http-curtain/releases/tag/v1.2.0 please don't hesitate if it doesn't function according to your likings.

ThomB63 commented 4 years ago

Thank you very much, I just did the installation and it seems that everything is ok. Thanks again

Le 30 juin 2020 à 22:47, Sander notifications@github.com a écrit :

Hi, see: https://github.com/QuickSander/homebridge-http-curtain/releases/tag/v1.1.2 https://github.com/QuickSander/homebridge-http-curtain/releases/tag/v1.1.2 please don't hesitate if it doesn't function according to your likings.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/QuickSander/homebridge-http-curtain/issues/1#issuecomment-652034365, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3QU66QGBR5H3C7IOWDDHDRZJFNBANCNFSM4N22XOLQ.