Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeat STATELESS button with same http command multiple times with a delay. #30

Closed
Tangheta opened this issue Jan 29, 2019 · 24 comments
Closed
Assignees

Comments

@Tangheta
Copy link

Is your feature request related to a problem? Please describe.
Not really a problem.
I have an Auping connect bed and currently use this plugin to rise or lower the bed using https calls like this:

"url" : "http://IP:80/api/cbu/motor?move=1&cbu=0&motor=2",
"method" : "GET",
"headers" : {
"accept" : "/",
"connection" : "keep-alive",
"accept-charset" : "utf-8",
"proxy-connection" : "keep-alive",
"host" : "IP:80",
"accept-language" : "en-us",
"user-agent" : "Auping%20Connect/17 CFNetwork/976 Darwin/18.2.0",
"X-Key" : "xxxx",
"accept-encoding" : "gzip, deflate"

However, this only moves the bed a little bit.
I have to do this action 8 times to get the bed to a good level.
I currently use the series option and add a
},
"delay(1000)",
{ in between the URL ubjects.
This unfortunately makes my config.json file huge.

Describe the solution you'd like
I would love an option where you can add 2 extra parameters to a URL object.
==> Repeat:
==> DelayBeforeRepeat

"url" : "http://IP:80/api/cbu/motor?move=1&cbu=0&motor=2",
"method" : "GET",
"Repeat": 6,
"DelayBeforeRepeat": 1000,

"headers" : {
"accept" : "/",
"connection" : "keep-alive",
"accept-charset" : "utf-8",
"proxy-connection" : "keep-alive",
"host" : "IP:80",
"accept-language" : "en-us",
"user-agent" : "Auping%20Connect/17 CFNetwork/976 Darwin/18.2.0",
"X-Key" : "xxxx",
"accept-encoding" : "gzip, deflate"

Thanks for the great work. Love the plugin!

@Supereg Supereg self-assigned this Feb 8, 2019
@Tangheta
Copy link
Author

Thanks for self-assigning this. Any plans to integrate the new TV iOS 12.2 options in this plugin?

@Supereg
Copy link
Owner

Supereg commented Feb 22, 2019

I didn't have that much time to work on this feature request. I try to get my head around it in the coming week.
What do you have in mind regarding the iOS 12.2 TV services? Since this plugin only represents a switch I don't know what it should have to do with TVs?

@Tangheta
Copy link
Author

Well, I haven't looked into the new accessory type, but it would be nice if we could define a "tv" where you can place HTTP commands behind the input types. Like
on: httpcommand
off: httpcommaand
HDMI1: HTTPcommand
HDMI2: HTTPcommand

But I still have to look into the api of my Hisense tv to see if I can control it with http commands.

@Supereg
Copy link
Owner

Supereg commented Feb 28, 2019

Yeah, I already though about creating a dedicated http tv plugin. However I’m still waiting for things to get more stable on the iOS beta side. Though I’m already experimenting with things ☺️

@Supereg
Copy link
Owner

Supereg commented Mar 3, 2019

v0.5.20 is live

An extract from the urlObject section of the README

  • repeat <number> optional (Default: 1): Defines how often the execution of this urlObject should be repeated.
    Notice that this property only has an effect on ulrObject specified in onUrl or offUrl.
    Also have a look at the multipleUrlExecutionStrategy property. Using "parallel" execution could result in unpredictable behaviour.
  • delayBeforeExecution <number> optional (Default: 0): Defines the time in milliseconds to wait before executing the urlObject.
    Notice that this property only has an effect on ulrObject specified in onUrl or offUrl.
    Also have a look at the multipleUrlExecutionStrategy property.

@Supereg Supereg closed this as completed Mar 3, 2019
@Tangheta
Copy link
Author

Tangheta commented Mar 3, 2019

Looking forward to testing this. Thanks a bunch!

@Tangheta
Copy link
Author

Tangheta commented Mar 3, 2019

Hmm, first tests seem to crash my homebridge. Same if i restore previous config.

@Supereg
Copy link
Owner

Supereg commented Mar 3, 2019

Could you check the logs what caused the crash?
I pushed also an updated version v0.5.21 which fixes an issue introduced in 0.5.20. It would cause that http success codes got handled as error codes 😅

@Supereg
Copy link
Owner

Supereg commented Mar 3, 2019

If you still have issues you can always downgrade by installing a specific version like
npm install -g homebridge-http-switch@0.5.19 (maybe requires root privileges)

However your help is definitely wanted to identify the crash

@Supereg
Copy link
Owner

Supereg commented Mar 3, 2019

The crash should be fixed in the latest release v0.5.22

@Jens-Wymeersch
Copy link

@Tangheta Did you ever get this to work and can you share what you have done ? I want to find a way to integrate Auping Connect to my Home Assistant environment.

@f7byu3e4jn
Copy link

@Jens-Wymeersch Hi, a few months ago, i have tried to sniff the network traffic between the Auping Connect app (on my iPhone) and the controller underneath the bed. It seems that the communication has slightly changed since 2019. See below for a first attempt to control the bed via Home Assistant. The ‘yyyyyyyy’ code is the same 8 character authorization code as found in the Auping app.

I hear that the motor (or the controller) makes a clicking sound when i execute this, but unfortunately no movement is witnessed.

rest_command:
auping_test:
url: http://xxx.xxx.xxx.xxx/api/cbu/motor/extended
method: POST
headers:
Host: 'xxx.xxx.xxx.xxx'
Content-type: 'application/x-www-form-urlencoded'
Connection: 'keep-alive'
Accept: '/'
X-Key: 'yyyyyyyy’
Accept-Language: 'en-us'
Content-Length: '121'
Accept-Encoding: 'gzip, deflate'
User-Agent: 'Auping%20Connect/4 CFNetwork/1197 Darwin/20.0.0'
payload: '{"motor_1":{"Action":0,"TimeInMs":0},"CBU":1,"motor_2":{"TimeInMs":30000,"Action":2},"motor_3":{"TimeInMs":0,"Action":0}}' `

@Jens-Wymeersch
Copy link

@f7byu3e4jn Hi there, currently I'm not able to use the Auping connect app and waiting for a fix. That said, I'm very interested in your project. I'm not sure how to abstract the 8 character authorization code. How do I find this one once I get the app up again ?

Thank you so much,
Jens

@Jens-Wymeersch
Copy link

@f7byu3e4jn Any progress since we chatted ?

@f7byu3e4jn
Copy link

f7byu3e4jn commented Mar 19, 2021

@Jens-Wymeersch Hi, sorry no. Things have been a bit too hectic recently. This is still somewhere on the higher regions of my to-do list, as my Auping bed is one of the only IoT devices in my home which has not yet been integrated into Home Assistant.

I am still (silently) hoping for Auping to release an open-API, but i guess that will take them 100 years, as they seem to have quite some challenges just to build a stable smartphone app.

@Jens-Wymeersch
Copy link

@f7byu3e4jn At this point, I have Auping and NetroHome still on the list to be integrated. Hence my desire... Just for the record, I have been struggling keeping the smartphone app stable. Somehow, it doesn't like my network, Unifi, that much. I've been talking to support for months but in the end they referred me to the reseller. It looks like they have only 1 developer working on this probably with a lot of other tasks.
I heard that homey integrates with it out of the box but I'm not planning to pay 200euro+ just for this use case. And by the way, I didn't find any Homey integration with Home Assistant. So I put all my faith in you !

@Expaso
Copy link

Expaso commented Apr 2, 2021

Should be doable as the API is fairly straight-forward.

@f7byu3e4jn Do you know if the authorization-key is visible somewhere within the app?

BTW, It could be your rest command is not working because the payload could be sensitive to the location where your properties live (it's an embedded device, so perhaps a full-blown JSON parser is nor implemented).

Try something like:

{ "CBU": 1, "motor_1": { "Action": 1, "TimeInMs": 30000 }, "motor_2": { "Action": 0, "TimeInMs": 0 }, "motor_3": { "Action": 0, "TimeInMs": 0 } }

@f7byu3e4jn
Copy link

@f7byu3e4jn Do you know if the authorization-key is visible somewhere within the app?

It certainly is. In the Auping Connect (ios) app, via ‘Settings’ > ‘Share’ you are shown a page with a QR-code and the 8 character key. This key can be specified manually in the app during set-up (e.g. when you own multiple mobile devices)

BTW, It could be your rest command is not working because the payload could be sensitive to the location where your properties live (it's an embedded device, so perhaps a full-blown JSON parser is nor implemented).

Try something like:

{ "CBU": 1, "motor_1": { "Action": 1, "TimeInMs": 30000 }, "motor_2": { "Action": 0, "TimeInMs": 0 }, "motor_3": { "Action": 0, "TimeInMs": 0 } }

Thanks. I am going to try this weekend!

@Jens-Wymeersch
Copy link

@f7byu3e4jn Were you able to progress this weekend on this topic ?

@Expaso
Copy link

Expaso commented Apr 4, 2021

@f7byu3e4jn Do you know if the authorization-key is visible somewhere within the app?

It certainly is. In the Auping Connect (ios) app, via ‘Settings’ > ‘Share’ you are shown a page with a QR-code and the 8 character key. This key can be specified manually in the app during set-up (e.g. when you own multiple mobile devices)

Nice! Well, that certainly makes things more user friendly.

I currently call my beds like this:

rest_command:
  beds_tv:
    url: "http://10.xxx.xxx.xxx/api/cbu/motor/extended"
    method: post
    content_type: "application/json"
    headers:
      X-Key: "xxxxxxxx"
      accept: "application/json"
    payload: '{"CBU":0,"motor_1":{"Action":0,"TimeInMs":0},"motor_2":{"Action":1,"TimeInMs":6000},"motor_3":{"Action":1,"TimeInMs":9000}}'

  beds_flat:
    url: "http://10.xxx.xxx.xxx/api/cbu/motor/extended"
    method: post
    content_type: "application/json"
    headers:
      X-Key: "xxxxxxxx"
      accept: "application/json"
    payload: '{"CBU":0,"motor_1":{"Action":0,"TimeInMs":0},"motor_2":{"Action":2,"TimeInMs":30000},"motor_3":{"Action":2,"TimeInMs":30000}}'

It works fine (only have the 2 motor version, hence only motor 2 and 3) when called from Home Assistant.
I have routed the command to Google Assistant, to assist in TV-mode and sleep-mode.

@f7byu3e4jn
Copy link

I currently call my beds like this:

rest_command:
  beds_tv:
    ...

Awesome! These simplified rest-commands worked perfectly for me as well! I can now control my Auping bed without any issues using Home Assistant.

I have slightly modified your code for my setup (a double Auping bed with only one motor on each bed side, supporting the main back part: https://www.auping.com/en/bed-bases/smart-base-1m). This main motor seems to be referred to as 'motor_2'. I have also split up the commands in one command to control both back parts at once ("CBU":0) and commands to individually control the left bed part ("CBU":2) and the right bed part ("CBU":1). Lastly, I have moved the X-Key to my secrets.yaml file. See below for my code.

@Expaso Thanks a lot. This really was the last piece of the puzzle for me!!

# configuration.yaml
# rest commands
rest_command:
  auping_position0:
    url: "http://10.x.x.x/api/cbu/motor/extended"
    method: post
    content_type: "application/json"
    headers:
      X-Key: !secret auping_x_key
      accept: "application/json"
    payload: '{"CBU":0,"motor_1":{"Action":0,"TimeInMs":0},"motor_2":{"Action":2,"TimeInMs":30000},"motor_3":{"Action":0,"TimeInMs":0}}'
  auping_right_position0:
    url: "http://10.x.x.x/api/cbu/motor/extended"
    method: post
    content_type: "application/json"
    headers:
      X-Key: !secret auping_x_key
      accept: "application/json"
    payload: '{"CBU":1,"motor_1":{"Action":0,"TimeInMs":0},"motor_2":{"Action":2,"TimeInMs":30000},"motor_3":{"Action":0,"TimeInMs":0}}'
  auping_right_position1:
    url: "http://10.x.x.x/api/cbu/motor/extended"
    method: post
    content_type: "application/json"
    headers:
      X-Key: !secret auping_x_key
      accept: "application/json"
    payload: '{"CBU":1,"motor_1":{"Action":0,"TimeInMs":0},"motor_2":{"Action":1,"TimeInMs":6000},"motor_3":{"Action":0,"TimeInMs":0}}'
  auping_right_position2:
    url: "http://10.x.x.x/api/cbu/motor/extended"
    method: post
    content_type: "application/json"
    headers:
      X-Key: !secret auping_x_key
      accept: "application/json"
    payload: '{"CBU":1,"motor_1":{"Action":0,"TimeInMs":0},"motor_2":{"Action":1,"TimeInMs":12000},"motor_3":{"Action":0,"TimeInMs":0}}'
  auping_left_position0:
    url: "http://10.x.x.x/api/cbu/motor/extended"
    method: post
    content_type: "application/json"
    headers:
      X-Key: !secret auping_x_key
      accept: "application/json"
    payload: '{"CBU":2,"motor_1":{"Action":0,"TimeInMs":0},"motor_2":{"Action":2,"TimeInMs":30000},"motor_3":{"Action":0,"TimeInMs":0}}'
  auping_left_position1:
    url: "http://10.x.x.x/api/cbu/motor/extended"
    method: post
    content_type: "application/json"
    headers:
      X-Key: !secret auping_x_key
      accept: "application/json"
    payload: '{"CBU":2,"motor_1":{"Action":0,"TimeInMs":0},"motor_2":{"Action":1,"TimeInMs":6000},"motor_3":{"Action":0,"TimeInMs":0}}'
  auping_left_position2:
    url: "http://10.x.x.x/api/cbu/motor/extended"
    method: post
    content_type: "application/json"
    headers:
      X-Key: !secret auping_x_key
      accept: "application/json"
    payload: '{"CBU":2,"motor_1":{"Action":0,"TimeInMs":0},"motor_2":{"Action":1,"TimeInMs":12000},"motor_3":{"Action":0,"TimeInMs":0}}'
# secrets.yaml
# Use this file to store secrets like usernames and passwords.
# Learn more at https://www.home-assistant.io/docs/configuration/secrets/
auping_x_key: abcdwxyz

@Expaso
Copy link

Expaso commented Apr 7, 2021

Haha nice! Glad could help.

If you want to keep the list of services short, you could consider 1 service, and set the payload using template parameters.
See https://community.home-assistant.io/t/auping-connect-integration/267770/8 (bottom post).

@f7byu3e4jn
Copy link

Thanks! I will have a look at that home-assistant community post to further simplify my code.

@Jens-Wymeersch
Copy link

@f7byu3e4jn
Did you look at the new Auping Connect ? If so, were you able to build a new integration ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants