Lay-Z-Spa Hot Tub wi-fi pump automation

FYI - I’m working on the python api here:

A long way off - but any python devs want to give me a sanity check I’d be massively appreciative!

FYI! making good progress!
image

This is a “Water Heater” component and not a climate one so you don’t have a thermostat like you would for a central heating device… it’s not ideal, but it does work.

Looking good. I’ll take a look at the code later.

I’ve not pushed the code for the component yet, only the python library I wrote. There is still a lot to do with the component. Not sure if I should try and get it into home assistant (in which case I can’t put in all the features yet - the PRs must be small) or if I should put it into HACS

I’ve done the absolute bare minimum to get it into HACS - you can add it using this repository https://github.com/rossdargan/lay-z-spa-component

Let me know how you get on with it!

Once added go to add integration and add lay-z spa, then enter your username and password. Hopefully it works!

away mode = heat power off… not sure if I will keep it like that, but it’s possibly the simplest way

1 Like

That’s great. Looks good.
I’m going to use your files to try and learn how to create a component too !

I’ve uploaded my files to:

So you can see what I’ve done.

The funcationality I’ve got running now is…

  1. To get an accurate “water temperature” instead of pump temperature, I only capture the water temperature when the pump is running and the temp is stable.
  2. I run the pump for 5 mins every 30 mins.
  3. If the price of my electric (on Octopus Agile) is below a preset, I heat.
  4. I can set a target time to be ready by and if there are less hours to go, then degrees to heat, it will heat.

Octopus energy was the whole reason I made this component!

That repo is empty - did you forget to push it?

I can see files at:

Can you see them ?

Ah my bad, I was looking on my phone - yes they look great. Hopefully with the component they can be simplified. Do you have HACS installed? I think I might work on getting it looking good in there before trying to submit it to home assistant.

Yes, I’ve already installed your component from HACS.
Looks like a solid starting point.

Fab - feel free to add any issues here: https://github.com/rossdargan/lay-z-spa-component/issues

Also, take a look through them to see what I’m planning (plus feel free to do any PRs :slight_smile: )

Hello!

Im also happy owner of Lay-Z-Spa but in finland as they are also branded under bestway the app is different. With official app i am able to connect my spa to wifi but app wont connect to spa. The app what i use ( becouse instructions told me to) is this https://apps.apple.com/fi/app/bestway-smart-hub/id1456731336?l=fi ( Bestway Smart Hub ). So none of the codes will allow me to capture any data from my spa.I have no experience from fiddler to findout what data is going between app and servers.

They are sold by best way in uk too.
Have you tried the la z spa app ?

Yes. It Will allow to send home wifi data to pump but after that it cant connect to pump. I managed to get api did from bestway app using fiddler but seems like bestway smart hub app users different address for Communicating. What i noticed that those pumps have probably somekind of esp as brains because after connecting to wifi my pump showed as ESP-xxxxx name. Address which fiddler showed was something like usaeapp… I have to check it later

You need to install https certificates so you can decode the https messages between the app and their service.

Ok. I need to check how that is done… Meanwhile i took te pump internals open and heres some pics if someone is interested… Wifi Module is esp-wroom-2uc. I tried to install Https sertificate but don’t really find anything useful information from fiddler while using the app. the address what it uses for communicating is http://usapi.gizwits.com/app/

Update:
I managed to get some data using fiddler. Here’s what i have found:
When controlling pump from app i see POST request made to https://usaepapp.gizwits.com/app/user/control_log with json data:

{
  "appKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "data": {
    "uid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "productKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "mac": "XXXXXXXXXXX",
    "did": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
    "command": {
      "power": true
    }
  },
  "type": "appId",
  "version": "1.0"
}

When opening the app this is the first GET request that is made.

GET http://usapi.gizwits.com/app/users/terms?locate=en HTTP/1.1
Host: usapi.gizwits.com
Origin: http://localhost:9099
Accept-Encoding: gzip, deflate
Connection: keep-alive
X-Gizwits-User-token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Accept: */*
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
X-Gizwits-Application-Id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Referer: http://localhost:9909/
Accept-Language: fi-fi

X-Gizwits-Application-Id is same as appKey on POST requests.

Tried to make manually same POST request via fiddler but device wont respond to it. All i get is this message. (this message also comes when i control pump from my phone).

HTTP/1.1 200
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: X-Gizwits-Application-Id,Accept,Origin,No-Cache,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Version,Authorization
Access-Control-Allow-Methods: POST,GET,OPTIONS,DELETE,PUT
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3600
Content-Type: application/json;charset=UTF-8
Date: Tue, 05 Jan 2021 19:26:10 GMT
Server: nginx/1.16.1
Vary: Accept-Encoding
X-Application-Context: aep-service-composite:prod-us:8077
Content-Length: 87
Connection: keep-alive

{"code":"200","message":"本次请求成功!","data":null,"display":null,"error":false}

message here says that “This request was successfull”

When logging in to app this POST request is made. but this is one time only if you have logged out from the app.

POST https://usaepapp.gizwits.com/app/smart_home/users/privacy HTTP/1.1
Host: usaepapp.gizwits.com
Content-Type: application/json
Origin: http://localhost:9909
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Accept: */*
Version: 1.0
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
Referer: http://localhost:9909/
Content-Length: 147
Accept-Language: fi-fi

{"appKey":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","data":{"privacy":0,"country":"FI","email":"[email protected]"},"type":"appId","version":"1.0"}

Appkey here is same as X-Gizwits-Application-Id and appKey on earlier code.

1 Like

Hi,

Very new here so be gentle. I’m deeply interested in this so thank you all for doing this work! I agree that both the apps (lay-z-spa and bestway hub) are less than ideal. The Lay-z-Spa app is just broken, Bestway Hub works perfectly but only provides remote hands to the spa pump controls. I really want dynamic scheduling

So far I’ve got HACS installed and Ross’ component installed. It’s not working for me however, I get “Unexpected Error” in response to logging in with my lay-z-spa app credentials. I think this is due to my spa currently being connected to the Bestway Hub App. Trying to switch it back to the Lay-Z-Spa app is proving difficult at the moment but I’ll update with my results when I manage it.

This looks like good work on the BestWay App.
Sadly, I switched to BestWay app to take a look and now I can’t switch back to the Lay-Z-Spa app.
So I’ve broken my Hot Tub !

I’m now stuck until one of us figures out this BestWay App.

I can’t seem to get it to respond to replayed commands, so I’m a bit out of my depth.
I’m seeing similar posts and responses to those you have shown above.

The BestWay App and the Lay-Z-Spa app use totally different commands to control the tub.
So the code isn’t interchangeable.
Sadly in investigating the BestWay app for you, I have now broken my own Tub as it won’t switch back to the Lay-Z-Spa app !

Hi Bruce,

I’m also having no luck reverting back to the Lay-z-Spa app. I have a feeling this might have something to do with the lay-z-spa account already having the spa linked to it. I’m very sorry that in your kind attempt to help me you were inconvenienced. I’ll test my theory about the accounts and get back to you.