Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Can see spa information and status but can't control it #5

Open
kaotix opened this issue Aug 19, 2022 · 9 comments
Open

Can see spa information and status but can't control it #5

kaotix opened this issue Aug 19, 2022 · 9 comments

Comments

@kaotix
Copy link

kaotix commented Aug 19, 2022

I've recently installed this to control my new hot tub but unfortunately can't get any actions to work.
It shows me all the relevant information, temperatures, heater/bubble status etc but if I try to turn off the heater for instance, it just toggles the option back to the way it was and doesn't command the hot tub to do anything.

Any help would be appreciated

@Wh1terat
Copy link
Owner

Not sure why your reply didn't get appended here (but I did get the email).

I'm guessing it's a different product and someone at Cleverspa isn't being consistent as it still works perfectly for me with the lowercase.

I'd suggest setting up mitmproxy and see whats sent when you use the official app for your model of spa.

@kaotix
Copy link
Author

kaotix commented Aug 21, 2022

Sorry, I deleted the reply as I realised what I'd put was actually incorrect. Although I can get it to work manually, the methodology of what I was doing was the same as your code.

From what I can tell, since you're just using MAP_KEYS table to rename the keys for the code side of things, you're still sending back "Heater". Much like "Temperature_setup" is just re-pointed to "target_temperature" and then when it gets sent back to the API it uses the original name.

Is there any way I can debug what the integration is doing? Get more verbose returns from the functions or something?
I've tried things like just turning on/off the filter and it simply just doesn't do anything. But I tested Bubbles and that worked without issue.

@Wh1terat
Copy link
Owner

Sorry, meant heater with a capital H.

map_keys just converts the key names to something more natural english sounding (superheating/undercooling aren't 100% obvious)

HA did add some functionality for user debugging a few releases ago but this is such a seldom used integration I really don't intend on extending it's functionality at all.

It's a pretty trivial API; best bet is still to look and see what the official client is doing first.

@Wh1terat
Copy link
Owner

Just to rule anything else out, I've put my local branch into dev:
https://github.com/Wh1terat/cleverspa-component/tree/dev

Don't recall actually fixing anything other than the 6monthly reauth flow; but who knows. Worth a try

@kaotix
Copy link
Author

kaotix commented Aug 21, 2022

Thanks, I'll give it a go tomorrow and let you know how I get on.
I had been looking at the Lay-z spa integration (Bestway) as that does things slightly different, I believe it sets it up like climate control rather than a water heater which seems to offer a bit more flexibility.
I'm yet to go down the rabbit hole of writing integrations for HA but I am tempted.

@Wh1terat
Copy link
Owner

The water heater entity was a forked subset of climate originally but seems like the unloved, poorer cousin at this point.
There's a number of patches into climate that have never been back ported.

This is the only one I ever bothered making and purely because one didn't exist before!

Personally I find HA as a framework to be a complete maze of incomplete (or more commonly, outdated) and conflicting documentation with very little in the way of guidance of the best way to do certain things. The only guidance being existing well maintained integrations. (and even then you'll often see a multitude of differing approaches to the same task).

But if you're proficient in Python, why not give it a go!

@Wh1terat
Copy link
Owner

Wh1terat commented Sep 4, 2022

Thought I'd check in to see how you're doing.

I'd forgotten to mention you'd be better of breaking the water heater out into a separate sensor and switch, you can just use a standard button then and will have the correct on/off state colour.

sensor:
  - platform: template
    sensors:
      cleverspa_current_temperature:
        friendly_name: "CleverSpa Current Temperature"
        unique_id: "cleverspa_qhadrjyhd2r2yh9td22upj_temp"
        unit_of_measurement: "°C"
        value_template: "{{ state_attr('water_heater.cleverspa_qhadrjyhd2r2yh9td22upj_water_heater', 'current_temperature') }} "
        device_class: temperature

switch:
  - platform: template
    switches:
      cleverspa_heater:
        friendly_name: "CleverSpa Heater"
        unique_id: "cleverspa_qhadrjyhd2r2yh9td22upj_heater"
        value_template: "{{ is_state('water_heater.cleverspa_qhadrjyhd2r2yh9td22upj_water_heater', 'electric') }}"
        turn_on:
          service: water_heater.turn_on
          target:
            entity_id: water_heater.cleverspa_qhadrjyhd2r2yh9td22upj_water_heater
        turn_off:
          service: water_heater.turn_off
          target:
            entity_id: water_heater.cleverspa_qhadrjyhd2r2yh9td22upj_water_heater

@kaotix
Copy link
Author

kaotix commented Sep 4, 2022

Thanks for checking in, I actually opted to combine both your code and another piece of code to create a climate version instead of the water heater version and it's been working fine for what I needed. I have some errors in my code but it does definitely work as intended for now.
Feel free to check it out on my profile, I won't link it directly as to not take away from your implementation but I do appreciate the code you've written as it was definitely a huge help and you've been credited appropriately in my code.

I can now manage the temperature like a true thermostat/climate control system and I can turn the heater on/off as required.
This suits me as it matches with my other Nest thermostats I have in the house and I have some nice automations to help me maintain temperature without running the heater all the time.

@Wh1terat
Copy link
Owner

Wh1terat commented Sep 5, 2022

Ah glad to hear you've got something working as you wanted 👍

Thank you for the credit, always nice to inspire others to build on and improve! 🚀
I might tidy up what I've written (fixed the 6 monthly reauth now), reformat some bits and then set the project as archived.

The water heater entity does actually work like a true thermostat, you simply set a target temperature (water_heater.set_temperature) - as well as supporting standard on/off features by calling water_heater.turn_on / water_heater.turn_off.

Climate works the same way as water heater is just a subset; but admittedly somewhat unloved by comparison - the lack of any decent lovelace card out of the box somewhat doomed it in my opinion 😞

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

No branches or pull requests

2 participants