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

Thank you.
This looks great, I’ll give it a go and report back.

Amazing stuff Chris!

Btw the whole thing here looks like MQTT…port 1883…eum2m.gizwits.com…maybe MQTT-Broker M2M…
→ inline update: yes mitt…mentioned here: Gizwits Open API - Gizwits
Would be a direct MQTT connection possible?! Perhaps a local connection to the “egg”? I’ll do some research on that…

This is precisely what I was looking for. Ideally HA will make calls directly to the “egg” bypassing the cloud entirely. That way if you’re internet goes away scheduling will work as normal :slight_smile:

I’ll see what I can do myself but very interested in the progress.

Graham

Additionally to sikksakks lyzspa2mqtt we could easily adapt the heatzy MQTT gateway here

to the new Bestway method. Everything’s there incl. openhab how to - even if we are here on the HA forum :slight_smile: Thanks a lot Nicolas Bernaerts :slight_smile:

http://www.bernaerts-nicolas.fr/iot/362-linux-setup-heatzy-pilote-mqtt-gateway

This is all great ! Thanks for the pointers in the right direction.
It’s weird, as it doesn’t match the calls the iOS app seems to make, but it works so I’m very happy !

I’ve adapted my Lay-Z-Spa code into Bestway code and it is available on

Please let me know if you have any questions.

1 Like

Very stupid question but I’m unsure where to place the file and code to make this work?

I have all my code split into many packages to make it easier to read and share.
If all your is in configuration.yaml (as it is by default) then you will add the code there.

First you need a sensor to give you your token:

sensor:
  - platform: rest
    name: hottub_login
    scan_interval: 172000
    resource: "https://euapi.gizwits.com/app/login"
    headers:
      Content-Type: application/json
      X-Gizwits-Application-Id: "98754e684ec045528b073876c34c7348"
    method: POST
    payload: '{ "username": "[email protected]", "password": "xxxxxxxx", "lang": "en" }'
    value_template: "{{ value_json.token }}"    
    json_attributes:
      - uid
      - expire_at

The value of this sensor can then be used in the next sensor…

sensor:
  - platform: rest
    name: hottub_bindings
    scan_interval: 172000
    resource: "https://euapi.gizwits.com/app/bindings?limit=20&skip=0"
    headers:
      Content-Type: application/json
      X-Gizwits-Application-Id: "98754e684ec045528b073876c34c7348"
      X-Gizwits-User-token: "xxxxxxxxxxxxxxxx" 
      # xxxxxxxxxxxx is The token from the login sensor
    method: GET
    value_template: "{{ value_json.devices[0].did }}"    
    json_attributes_path: "$.devices[0]"
    json_attributes:
      - dev_alias
      - mac
      - product_key
      - passcode
      - product_name

With the did you get from that sensor, you can make this sensor…

sensor:
  - platform: rest
    name: hottub_status
    resource: https://euapi.gizwits.com/app/devdata/xxxxxxxxxxxx/latest  
    # xxxxxxxxxxxx is the did from the bindings sensor
    headers:
      Content-Type: application/json
      X-Gizwits-Application-Id: 98754e684ec045528b073876c34c7348
    method: GET
    value_template: "{% if value_json.attr.temp_set > 0%}online{% else %}offline{%endif%}"    
    json_attributes_path: "$.attr"
    json_attributes:
      - system_err2
      - wave_appm_min
      - heat_timer_min
      - heat_power
      - earth
      - wave_timer_min
      - system_err6
      - system_err7
      - system_err4
      - system_err5
      - heat_temp_reach
      - system_err3
      - system_err1
      - system_err8
      - system_err9
      - filter_timer_min
      - heat_appm_min
      - power
      - temp_set_unit
      - filter_appm_min
      - temp_now
      - wave_power
      - locked
      - filter_power
      - temp_set

Once you’ve got to his point, you don’t need the login or bindings sensors any more.

Let me know how you get on and I can explain the rest if required.

I think that’s enough to get me started figuring it out for myself. Thanks for your patience!

Brilliant. Got that working which gives me a reading I can use. I can start working the rest out now I think.

that’s great.
Let me know if you have any more questions.
Some of my stuff might be a bit over complicated, but hopefully you can get what you need from it.

We will have to figure out how to link the two methods into the component!

1 Like

I’ve now got switches for power, heat, filter, bubbles and reports on current and set temperature but what I’m struggling with is how to actually set the target temperature. I’ve added the automations but I can’t quite see how I would set the temp using them in the UI. Is there something basic I’m missing?

Graham

Made it in the end. Here’s what I did:

  • Added the various yaml from @BruceH5200’s repo
  • Created a thermostat (config below)
  • Installed HACS and then installed Scheduler card/custom component
  • Set a scheduler card to do a heating cycle that suits my needs and can be altered easily
  • Made a dashboard :slight_smile: - The cards are mostly to prove what can be done

Thermostat code:

climate:
  - platform: generic_thermostat
    name: Hottub
    heater: switch.hottub_heat
    target_sensor: sensor.hottub_pump_temp
    min_temp: 21
    max_temp: 40
    target_temp: 35
    precision: 1.0

Notes:

All of this works on the basis that the target temp is set to 40 degrees C and left that way. I’ve not actually figured out a way to set that explicitly through the UI. The thermostat reads the pump temp and turn the heating off or on based on that reading. Thus if your target temp is set to 30 and the thermo is trying to heat to 40 it’s never going to turn off. This will work better if the thermostat is actually manipulating the pumps target temp rather than just switching the heater on or off. It also doesn’t control the filter.

To do

  • work out if the target temp can be set from the generic thermostat setting
  • understand the automations better as the idea of turning on the pump for a few minutes to sample temp and then turning off if it’s high enough seems good. Ditto running the filter on it’s own regularly.
  • look at the Octopus agile automations.

For now I’ve got much more than I had. A easy to use scheduler that actually works and is probably trustworthy!

Thank you all for getting me started one this :slight_smile:

You shouldn’t need scheduler or the climate component.
All of this can be done with just my code.
You need to create the helpers that the code mentions.

Eg.
Input_number.hottub_water_temp

The main automation : pump every 30 or similar then handles the schedule to get the tub to a certain temperature by a defined fine.

If you use octopus agile for your electric it will use the cheapest electric price slots too.

This is my interface :slight_smile:

Hi Bruce,

Very nice!

I’ve pulled the main automation for the moment as it seemed to be throwing some errors which I’ll check over and report back on. It’s more than likely my error.

I did, after I posted last night, create a helper for hottub_water_target which is useful. I’m currently fiddling with having the generic thermo temperature set the hottub_water_target via an automation but I suspect that’s probably wasted energy. I’ve created the other helpers and will have a further play when I’ve got time. Right now the tub has hit a good temp just as my lunch break is due so I’m off for a dip :smiley:

Anything new on HACS update? =)

Hi Bruce, and all the other contributors on this page. Excellent work.
Just purchased a Lazy-Z-spa Milan and by following the detailed work on this page I have been able to get the hot tub fully integrated in to home assistant. I used the BESTWAY app on android to get the hottub registered. The official apps are junk and took many attempts to get registered but once registered I’m delighted with the integration capable through your many configuration files. This integration is everything I could of hope for and more. Many Many Thanks for posting this.

Welcome!

It’s been quiet of late as I think most of us got what we needed. I’ve just been switched to Octopus agile so am looking forward to using Bruce’s automations to benefit from that.

As for the component/HACS idea, it’s on my hobby time to do list but it’ll be a while before I can find space to do the learning I need to do to get started. If anyone else is having a shot, shout out and I’ll be happy to help in any way I can.

Ok. I am having some problems with this. hottub login sensor is not returning any values? no errors in log but it wont show anything…

Have you tried posting to the URL using postman or similar to see what you are getting ?