The following works for my Lay Z Spa San Francisco model using the Bestway App, ive done the minimum to get it working, once i find the time to make it decent i will post here again. (No error codes,… at this time) Modify the api links depending on if you registerd in EU or USA, if one does not work, try the other. (Im using usapi while im in EU, somehow)
Bruce’s Scripts that ive used & modified with the needed input for the HydroJet models, you can find the codes for login in here since that part is all the same:
Before we start, create the map ‘packages’ and open configuration.yaml. Enter:
homeassistant:
packages: !include_dir_named packages
Now you can download & place the needed pieces of code in the packages directory.
- Start with this one: secrets.yaml.example, enter your login information and rename to secrets.yaml, token & did will be aquired in the following steps.
- Next is: sensor_rest_hottub_bestway_initial_login.yaml.disabled, rename to sensor_rest_hottub_bestway_initial_login.yaml and restart HA.
- Add an entities card inside HA using this sensor, this will return your bestway token. Replace {your token} inside secrets.yaml with the received token.
- Next: sensor_rest_hottub_bindings.yaml.disabled, rename to sensor_rest_hottub_bindings.yaml and restart HA.
- Add an entities card inside HA using this sensor. This will return your did and some other information. Go to secrets.yaml and update this with your did.
- This is the login part done, now you can create the following file: sensor_rest_hottub_status.yaml
sensor:
- platform: rest
name: hottub_status
scan_interval: 30
timeout: 20
resource: !secret bestway_status_url
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+01:00') }}"
json_attributes_path: "$.attr"
json_attributes:
- Tnow # Temperature of Water in Pump
- Tset # Target Temperature
- power # Power - 1:On, 0:Off
- filter # Power - 1:On, 0:Off
- heat # Heater - 1:On, 0:Off
- wave # Bubbles - 1:On, 0:Off
- jet # Jet Status
# https://support.bestwayaftersales.co.uk/faq/get-help-with-your-lay-z-spa-pump/
Now, restart HA again and when you add this sensor to an entity card you should be able to see the configured values under ‘Attributes’.
If this works, you dont need sensor_rest_hottub_bestway_initial_login.yaml & sensor_rest_hottub_bindings.yaml anymore so you can rename them back to *.disabled.
With the following codes under packages you then should be able to configure it like ive got:
sensor_rest_hottub_temperature.yaml
sensor:
- platform: template
sensors:
hottub_temperature:
friendly_name: "Hot Tub Temperature"
value_template: "{{ state_attr('sensor.hottub_status', 'Tnow') }}"
unit_of_measurement: "\u00B0C"
rest_command_hottub_command.yaml
rest_command:
hottub_command:
method: POST
headers:
content_type: "application/json"
X-Gizwits-Application-Id: "98754e684ec045528b073876c34c7348"
X-Gizwits-User-token: !secret bestway_token
url: !secret bestway_control_url
payload: "{{hottub_command}}"
sensor_template_hottub_jets.yaml
switch:
- platform: template
switches:
hottub_jets:
availability_template: "{{ states('binary_sensor.hottub_online') }}"
unique_id: hottub_jets
friendly_name: Jets
value_template: "{% if state_attr('sensor.hottub_status', 'jet') == 1 %}on{% else %}off{% endif %}"
turn_on:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"jet": 1} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
turn_off:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"jet": 0} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
switch_template_hottub_bubbles_high.yaml
switch:
- platform: template
switches:
hottub_bubbles_high:
availability_template: "{{ states('binary_sensor.hottub_online') }}"
unique_id: hottub_bubbles_high
friendly_name: Bubbles
value_template: "{% if state_attr('sensor.hottub_status', 'wave') == 100 %}on{% else %}off{% endif %}"
turn_on:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"wave": 100} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
turn_off:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"wave": 0} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
switch_template_hottub_bubbles_medium.yaml
switch:
- platform: template
switches:
hottub_bubbles_medium:
availability_template: "{{ states('binary_sensor.hottub_online') }}"
unique_id: hottub_bubbles_medium
friendly_name: Bubbles
value_template: "{% if state_attr('sensor.hottub_status', 'wave') == 40 %}on{% else %}off{% endif %}"
turn_on:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"wave": 40} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
turn_off:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"wave": 0} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
switch_template_hottub_filter.yaml
switch:
- platform: template
switches:
hottub_filter:
availability_template: "{{ states('binary_sensor.hottub_online') }}"
unique_id: hottub_filter
friendly_name: Filter
value_template: "{% if state_attr('sensor.hottub_status', 'filter') == 2 %}on{% else %}off{% endif %}"
turn_on:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"filter": 2} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
turn_off:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"filter": 0} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
switch_template_hottub_heat.yaml
switch:
- platform: template
switches:
hottub_heat:
availability_template: "{{ states('binary_sensor.hottub_online') }}"
unique_id: Heater
friendly_name: Heater
value_template: "{% if state_attr('sensor.hottub_status', 'heat') != 0 %}on{% else %}off{% endif %}"
turn_on:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"heat": 1} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
turn_off:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"heat": 0} }
- delay: 00:00:03
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
switch_template_hottub_power.yaml
switch:
- platform: template
switches:
hottub_power:
availability_template: "{{ states('binary_sensor.hottub_online') }}"
friendly_name: Power
unique_id: hottub_power
value_template: "{% if state_attr('sensor.hottub_status', 'power') == 1 %}on{% else %}off{% endif %}"
turn_on:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"power": 1} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
turn_off:
- service: rest_command.hottub_command
data_template:
hottub_command: >
{"attrs": {"power": 0} }
- delay: 00:00:05
- service: homeassistant.update_entity
entity_id: sensor.hottub_status
That should be it, if you ran into any issues let me know, ill try to help as good as i can.