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

I have the exact same problem but with a cleverspa using the same API.

My binary_sensor.hottub_online shows as off and this is the same if I run a curl command outside HA

But my sensor.hottub_status shows

Heater: 0
Undercooling: 0
Current_temperature: 15
Filter: 1
Temperature_setup: 40
Superheat: 0
Bubble: 0
Overtime_filter: 1
Timing: 0
Check: 0
Time_filter: 10200
friendly_name: hottub_status
device_class: timestamp

And has a timestamp as the state

Could this be something to do with only able to register the tub on a single phone ?

If I run a curl command to switch on the bubbles for example

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-Gizwits-User-token: TOKEN' --header 'X-Gizwits-Application-Id: 805cc6a3f41b48aeae471e2fcb6ebc73' -d '{"attrs": {"bubble": 1} } ' 'https://api.gizwits.com/app/control/DID'

I get

{
    "error_message": "device offline!",
    "error_code": 9042,
    "detail_message": null
}

But my phone is working fine which is where I got the DID, Token etc from.

EDIT - it was the tub, realised the app opens but couldn’t send any commands, maybe tub got confused whilst settings everything up don’t know.

Switched the tub off and back on and now all working.

Thank you Bruce for all the initial work and thank you musicman for the cleverspa specific bits.

Really appreciated

I am using the latest code in your GitHub. In my Sensor.yaml, I have this:

  • platform: rest
    name: hottub_status
    scan_interval: 30
    timeout: 20
    resource: https://usapi.gizwits.com/app/devdata/XXXYYYZZZ/latest
    device_class: timestamp
    headers:
    Content-Type: application/json
    X-Gizwits-Application-Id: 98754e684ec045528b073876c34c7348
    method: GET
    value_template: “{{ value_json.updated_at | timestamp_custom (’%Y-%m-%dT%H:%M:%S+00:00’) }}”
    json_attributes_path: “$.attr”
    json_attributes:
    • temp_now # Temperature of Water in Pump
    • temp_set # Target Temperature
    • temp_set_unit # Temperature displayed in C or F
    • power # Power - 1:On, 0:Off
    • filter_appm_min # Start Filter in x minutes
    • filter_power # Power - 1:On, 0:Off
    • filter_timer_min # Filter for x minutes
    • heat_appm_min # Start Heat in x minutes
    • heat_power # Heater - 1:On, 0:Off
    • heat_timer_min # Heat for x minutes
    • heat_temp_reach # Target Temperature Reached
    • wave_power # Bubbles - 1:On, 0:Off
    • wave_appm_min # Start Bubbles in x minutes
    • wave_timer_min # Bubbles for x minutes
    • locked # Pump Keypad Locked
    • earth # Earth Fault
    • system_err1 # Error 1 - Sensor Error / Water Flow Error / Debris Buildup
    • system_err2 # Error 2 - Water Flow Error
    • system_err3 # Error 3 - Temperature too low / Thermostat broken
    • system_err4 # Error 4 - Temperature too high / Thermostat broken / Thermostat needs reset
    • system_err5 # Error 5 - Temperature too high / Thermostat broken / Thermostat needs reset
    • system_err6 # Error 6 - Electrical Fault (Current Variation)
    • system_err7 # Error 7 - Electrical Fault
    • system_err8 # Error 8 - Thermostat needs reset
    • system_err9 # Error 9 - Internal Fuse Failure

In Configuration.yaml, this code:

binary_sensor:

  • platform: template
    sensors:
    hottub_online:
    friendly_name: “HotTub Online”
    value_template: “{{ (now() | as_timestamp - states(‘sensor.hottub_status’) | as_timestamp ) < 2000.0 }}”

123

Notice hotttub_status shows 5 hours ago. But I can click on it, and it will show an update a few minutes back. All of the individual items show correct (temp now, temp set, etc…see my pic in my last post).

The binary sensor never reads correct (HotTub Online) never shows on. I am assuming this is preventing the others from working correctly.

To keep things simple, just focused on the two pieces of code: hottub_status and HotTub online.

What am I missing or not doing correctly? Its killing me that I can figure this out.

I had the same thing, switched hottub off and on and it all came alive.

I’ve restarted it several times, no change.

This is great. Thanks for the work this made my life so much asier and managed to create some Automations from this,

Anyone located in the US, whom has this working? Would love to compare configs. I’m so close, and still stuck.,

How far have you got? What is working? what is not working?
Which app is your pump linked to?
Bestway app?

The app is linked to the Bestway app.

The is in my sensory.yaml, and works:

  • platform: rest
    name: hottub_status
    scan_interval: 30
    timeout: 20
    resource: https://usapi.gizwits.com/app/devdata/XXXYYYZZZ/latest
    device_class: timestamp
    headers:
    Content-Type: application/json
    X-Gizwits-Application-Id: 98754e684ec045528b073876c34c7348
    method: GET
    value_template: “{{ value_json.updated_at | timestamp_custom (’%Y-%m-%dT%H:%M:%S+00:00’) }}”
    json_attributes_path: “$.attr”
    json_attributes:
    • temp_now # Temperature of Water in Pump
    • temp_set # Target Temperature
    • temp_set_unit # Temperature displayed in C or F
    • power # Power - 1:On, 0:Off
    • filter_appm_min # Start Filter in x minutes
    • filter_power # Power - 1:On, 0:Off
    • filter_timer_min # Filter for x minutes
    • heat_appm_min # Start Heat in x minutes
    • heat_power # Heater - 1:On, 0:Off
    • heat_timer_min # Heat for x minutes
    • heat_temp_reach # Target Temperature Reached
    • wave_power # Bubbles - 1:On, 0:Off
    • wave_appm_min # Start Bubbles in x minutes
    • wave_timer_min # Bubbles for x minutes
    • locked # Pump Keypad Locked
    • earth # Earth Fault
    • system_err1 # Error 1 - Sensor Error / Water Flow Error / Debris Buildup
    • system_err2 # Error 2 - Water Flow Error
    • system_err3 # Error 3 - Temperature too low / Thermostat broken
    • system_err4 # Error 4 - Temperature too high / Thermostat broken / Thermostat needs reset
    • system_err5 # Error 5 - Temperature too high / Thermostat broken / Thermostat needs reset
    • system_err6 # Error 6 - Electrical Fault (Current Variation)
    • system_err7 # Error 7 - Electrical Fault
    • system_err8 # Error 8 - Thermostat needs reset
    • system_err9 # Error 9 - Internal Fuse Failure

and I get this. Notice HotTub_status says 5 hours. It always says 5 hours (greyed out back window)

But when I click it, I get the following; and it is correctly reading the details from the HotTub. I confirmed this work by changing the status of the tub on the control panel, and it reflects here.

But anything post this refuses to work.
To keep things simple…I literally only have the above code and the earlier code for HotTub_login and HotTub_bindings.

The only other code I place was the one binary sensor…

binary_sensor:

  • platform: template
    sensors:
    hottub_online:
    friendly_name: “HotTub Online”
    value_template: “{{ (now() | as_timestamp - states(‘sensor.hottub_status’) | as_timestamp ) < 2000.0 }}”

No matter what I do…it only shows as it being Off. If I create a sensor for HotTub pump temperature, It comes back as unavailable.

In an earlier post, I have a view shows this detail. At this point I’m not even trying any switches or commands…Just displaying data.

Could this be a problem with time and date formatting? Hence why something is not working? In your above code, I notice a “T” was inserted between date and time.

I’m so close, but yet so far. I’m stumped.

it’s a timezone issue.
The +00:00 bit on the end of the time format works for me because I’m in the UK.

I’m guessing you need +05:00
Or possibly -05:00

Give that a go and see what happens.

And away we “go”. That was it! -05:00, and now we got something working. Now to work through the rest, and make it work. Appreciate the help! I’m sure I will have a few more questions along the way.

23

Be aware that I use c and you are using f.
(Temp units)

So the calculations in the scheduling code will need to be adjusted if you use them.

Hi. i copyied the whole bruces_homeassistant_config/packages/areas/garden/hottub-bestway at main · B-Hartley/bruces_homeassistant_config · GitHub
and got every sensor working but when i try the switches i get this in my log.

Logger: homeassistant.components.rest_command
Source: components/rest_command/init.py:136
Integration: RESTful Command (documentation, issues)
First occurred: 20:02:42 (2 occurrences)
Last logged: 20:02:51
Error. Url: https://euapi.gizwits.com/app/control/HyxxxXXxXxxxxX4. Status code 400. Payload: b’{“attrs”: {“power”: 0} }’
Error. Url: https://euapi.gizwits.com/app/control/HyxxxXXxXxxxxX4. Status code 400. Payload: b’{“attrs”: {“heat_power”: 1} }’

i dont understand why i get this payload:b’

Working! Superb :slight_smile:

Hello everybody,

I’m new to Hassio and I feel a little lost.

So far I have only added and configured add-ons via the store. Now I don’t know how to properly start with the code. Where do I have to install the first part? I think the further procedure is already described very well here, I just know how to start correctly :slight_smile:

Many Thanks

Hi Yagyu,

I guess you want to know where to put the bits of code to get you API token and DID? I have done this for a Lay Z Spa.

Paste the hottub_login code into your configuration.yaml.

As the code uses !secret for hiding passwords you also need to put some information in a file called secrets.yaml. This should be in the same folder (config) as your configuration.yaml.

Add the hottub_email_password line to secrets.yaml, but change the bits for your email address and password. It needs the ones you use with the official app.

If your email is [email protected] and your password is MY_PASSWORD it would look like this
hottub_email_password: email=name%40hotmail.com&password=MY_PASSWORD

Restart HA. Add an entity card (I think). From memory the default card offered had the bits in I needed. If not look for entities with hottub. in the name.

If it works this card will give you your API token and DID. You then need to add these to your secrets.yaml as below.
hottub_api_did: did=AAaAaAAAAAAaaaaAAA9A9b&api_token=a1a1a1a1a2a2a2a2a12a1a1a1a2a2a2a2

2 Likes

Thanks, I did it :slight_smile:

I have now set it up so far:

  • hottub login: shows the token
  • hottub binding: shows my did
  • hottub status: shows Temp now, Temp set, active status power, filter, heat…

I now see a lot of code in the github. How do I use this now to have a control in the dashboard?
There are:

  • automation
  • Binary sensor
  • sensor
  • scripts

  • Do I have to include all of these or only the sensors and, in the case of automation and scripts, only those that I would like to use?

Where do I then integrate this?

Many Thanks

Yagyu,

I think there are multiple ways to integrate the rest of the code but I am also just scratching the surface of HA so I copied the way that Bruce does it and put all the code in its own folder and then told HA where they are. Seems sensible.

I added the following two lines to the end of my configuration.yaml.

homeassistant:
 packages: !include_dir_named packages

Then I put all the sensors etc in a folder under a directory called packages. I cannot remember if I had to create the packages directory as well. If it doesn’t exist it, you create it in your config directory.

You also need to create the 4 Helpers mentioned in post #72. If it works you should have lots of new automations and sensors etc.

That is as far as I have got. It works for me apart from the scheduling. The automation Hottub_on_every_thirty won’t run for me. The issue seems to be with the HoursLeft variable.

If you get past that bit please let me know!

1 Like

You could be missing this…

sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_utc'
      - 'date_time_iso'
      - 'time_date'

Hello,

it works really well :slight_smile:

I just added all the “hottub” items to the dashboard. Two things don’t work right now:

  • Hottub Heating this Weak. Status: Unknown.
  • Hottub at or below max charge cost: not available

Two additional questions:

  • My target temp is just a slider. In post 72 there is something like a thermostat. how can i remodel this?
  • My goal would be to incorporate the whole thing as a rule. for example every other day at 9 p.m. 38 ° C or Monday, Wednesday, Friday … Would something like this be “easy” to implement with Home Assistant?

Many Thanks.

You could create an automation that ran every day at 00:01.
with a choose you could say if it was Mon, Wed, Fri to turn on hot tub scheduled, otherwise turn it off.
Set the temp to 38 and that should do it.