Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] ControlMySpa integration for Home Assistant based on this libary #28

Open
Hedda opened this issue Oct 24, 2022 · 18 comments
Open
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Hedda
Copy link
Contributor

Hedda commented Oct 24, 2022

@arska Would you consider writing a native "ControlMySpa" integration component for Home Assistant based on this library?

https://community.home-assistant.io/t/integration-for-a-spa-question-about-available-entities/156760/

Or alternatively, maybe extend the existing "Balboa Spa Client" to also add support for ControlMySpa cloud API as an option?

https://www.home-assistant.io/integrations/balboa/

There is also this other custom component Spa Client that is compatible with Balboa BP System + bwa WiFi module as well:

https://github.com/plmilord/Hass.io-custom-component-SpaClient

See Home Assistant Developer documentation on Starting with Development and building a new integration component for it:

https://developers.home-assistant.io/

https://developers.home-assistant.io/docs/development_index/

https://developers.home-assistant.io/docs/creating_component_index

https://developers.home-assistant.io/docs/integration_fetching_data/

@arska
Copy link
Owner

arska commented Oct 31, 2022

Hello @Hedda, thanks for reaching out! Unfortunately, I don't have the bandwidth to create a HA integration at this time. Feel free to start one and I might be able to help at a later time. Best, Aarno

@arska arska self-assigned this Oct 31, 2022
@arska arska added enhancement New feature or request help wanted Extra attention is needed labels Oct 31, 2022
@JSkier21
Copy link

@arska Would you please consider writing a new "ControlMySpa" integration for Home Assistant based on this library?

https://community.home-assistant.io/t/integration-for-a-spa-question-about-available-entities/156760/

Or alternatively, maybe extend the existing "Balboa Spa Client" to also add support for ControlMySpa cloud API as an option?

https://www.home-assistant.io/integrations/balboa/

See Home Assistant Developer documentation about Starting with Development and building/adding a new integration for it:

https://developers.home-assistant.io/

https://developers.home-assistant.io/docs/development_index/

Have you seen this project @Hedda? I have some interest in an MQTT client for it in Python instead of JS. HA would be a great add-on; however, I believe MQTT is the way to go to allow other compatibility beyond HA.
controlmyspa-ha-mqtt

@garysargentpersonal
Copy link

I've got this working in Home Assistant but it's somewhat clunky. First install this integration: https://github.com/custom-components/pyscript/

Then in your config folder create a "pyscript" folder, and in there place the file controlmyspa.py from this repository: https://raw.githubusercontent.com/arska/controlmyspa/main/controlmyspa.py

Then in the same "pyscript" folder create a file called cmsConfig.py as follows:

class CMSConfig:

    email = "[CMS email]"
    password = "[CMS password]" 

Then in the same "pyscript" folder create a file called cmsGetCurrentTemp.py as follows:

@pyscript_executor
def cms_update_current_temp_action(action=None, id=None):
    import sys
    sys.path.insert(0, "/config/pyscript")
    
    from controlmyspa import ControlMySpa
    from cmsConfig import CMSConfig

        
    API = ControlMySpa(CMSConfig.email, CMSConfig.password)
    return {"temp":API.current_temp}
    
@service
def cms_update_spa_temperature(action=None, id=None):
    status = cms_update_current_temp_action()
    input_number.set_value(entity_id="input_number.hot_tub_temperature", value=status["temp"])    

The above requires a "helper" number device created with id input_number.hot_tub_temperature

Call HA service "Pyscript Python scripting: cms_update_spa_temperature" to run the script, which will update the helper number with the temperature of the spa.

You can have more scripts to do other things, for example I have one called cmsSpaOn.py as follows:

@pyscript_executor
def cms_spa_on_action(action=None, id=None):
    import sys
    sys.path.insert(0, "/config/pyscript")
    
    from controlmyspa import ControlMySpa
    from cmsConfig import CMSConfig

        
    API = ControlMySpa(CMSConfig.email, CMSConfig.password)
    
    jet0Value = API.get_jet_value(0)
    jet1Value = API.get_jet_value(1)
    if jet0Value == "LOW":
      API.set_jet(0, True)
    if jet0Value == "OFF":
      API.set_jet(0, True)
      API.set_jet(0, True)
      
    
    if jet1Value == "LOW":
      API.set_jet(1, True)
    if jet1Value == "OFF":
      API.set_jet(1, True)
      API.set_jet(1, True)

@service
def cms_spa_on(action=None, id=None):
    cms_spa_on_action()

(my jets go off/low/high so I need to call set_jet twice to go to high)

@msupczenski
Copy link

@garysargentpersonal I have been trying to get the cmsGetCurrentTemp working but running into this error. Any ideas? Referenced entities input_number.hot_tub_temperature are missing or not currently available

@garysargentpersonal
Copy link

@garysargentpersonal I have been trying to get the cmsGetCurrentTemp working but running into this error. Any ideas? Referenced entities input_number.hot_tub_temperature are missing or not currently available

You need to create a helper device of type number with ID hot_tub_temperature

Helpers are created in settings in HA near devices. They have their own screen.

@msupczenski
Copy link

@garysargentpersonal I have been trying to get the cmsGetCurrentTemp working but running into this error. Any ideas? Referenced entities input_number.hot_tub_temperature are missing or not currently available

You need to create a helper device of type number with ID hot_tub_temperature

Helpers are created in settings in HA near devices. They have their own screen.

Thanks. I had the helper set to "input_number.hot_tub_temperature" and change it to "hot_tub_temperature" my inexperience with custom HA intragrations shows. Thanks for the help. Ever see this before? Sorry to bother. Exception in <file.cmsGetCurrentTemp.cms_update_spa_temperature> line 15: status = cms_update_current_temp_action() ^ KeyError: 'currentTemp'

@garysargentpersonal
Copy link

Not sure on that sorry, but since my original post I also had to add a root certificate into HA to support the new certificate they started using. Can't recall the exact details though.

@msupczenski
Copy link

Not sure on that sorry, but since my original post I also had to add a root certificate into HA to support the new certificate they started using. Can't recall the exact details though.

Got it to work. If the pump does not run, the current_temp does not show in the json data. Thanks again for the help!

@djjassu
Copy link

djjassu commented Mar 24, 2024

Can this script also update the temperature setting? Would be lovely to adjust the temperature according to electricity price.

@arska
Copy link
Owner

arska commented Mar 25, 2024

Can this script also update the temperature setting? Would be lovely to adjust the temperature according to electricity price.

I don't know about the HA script, this library can set the temperature, which is how I'm currently adjusting the temperature according to electricity price: https://github.com/arska/controlmyspa-porssari

@Hedda
Copy link
Contributor Author

Hedda commented Mar 25, 2024

Can this script also update the temperature setting? Would be lovely to adjust the temperature according to electricity price.

Understand component only provides integration with information about device, services, and ability to change exposed settings.

This request posted #28 is only for requesting a native custom component integration for Home Assistant.

https://developers.home-assistant.io/docs/creating_component_index/

Question off-topic for specific request as such type of features would need to be done via separate an automation and/or script:

What you could possible separately request or search for is "Blueprint(s)" that would make creating such an automation easier:

https://www.home-assistant.io/docs/automation/using_blueprints/

https://www.home-assistant.io/get-blueprints

PS: Again this is off-topic so you should ask any follow-up questions elseware but if search can for get ideas from these:

https://community.home-assistant.io/search?q=price%20%23blueprints-exchange

https://www.google.com/search?q=home+assistant+automations+electricity+price

Example:

https://www.creatingsmarthome.com/index.php/2022/09/17/home-assistant-nord-pool-spot-prices-and-how-to-automate-devices-for-cheapest-hours/

https://community.home-assistant.io/t/automating-for-hourly-energy-prices/546923

https://community.home-assistant.io/t/ideas-for-electricity-price-based-heating-automation/448491

https://community.home-assistant.io/t/calculate-device-energy-costs-using-dynamic-electricity-price-like-nordpool/682847

@jpgazerro
Copy link

Hello,

Has anyone found a way to integrate controlmyspa into Home Assistant?

I tried looking at your different code but I can't figure it out. I don't have enough knowledge.

Thank you very much for your work

@Hedda
Copy link
Contributor Author

Hedda commented Jun 5, 2024

Has anyone found a way to integrate controlmyspa into Home Assistant?

I have not heard of any native Home Assistant integration for ControlMySpa cloud API nor Local API hacks, see discussion here:

https://community.home-assistant.io/t/controlmyspa-integration-to-home-assistant/693076

Closest thing is still running ControlMySpa Home Assistant Addon by @mikakoivisto via MQTT which is not user-friendly to setup:

Personally I gave up and ordered the old bwa™ Wi-Fi module (50350) to run the native Balboa Spa Client integration compoent for Home Assistant instead, so that way is all running locally:

Hoping for others that someone will make a true native Home Assistant integration component for ControlMySpa in the future.

Alternativly that someone will start selling an pre-made ESP32 based device or similar that can do all these same things locally.

@garysargentpersonal
Copy link

I did the same but the wifi module is awful and won't stay connected for more than ten minutes. Constantly up and down.

@Hedda
Copy link
Contributor Author

Hedda commented Jun 5, 2024

I did the same but the wifi module is awful and won't stay connected for more than ten minutes. Constantly up and down.

FYI, the old bwa Wi-Fi module (50350) is infamously known for having issues with dropping/loosing WiFi connection, but really both my ControlMySpa Gateway Ultra (59303) and my bwa Wi-Fi module (50350) originally had similar WiFi connection issues until I finally created a dedicated SSID WPA2 WiFi network with 2.4GHz-only and 20 MHz Channel Width for just IoT devices, as well as reserved IP-address in DHCP-scope to each device. I also disabled all advanced features like Fast Roaming, BSS Transition, PMF (Protected Management Frames), etc. of that specific WiFi network.

So this could be because using a shared SSID for 2.4GHz and 5GHz as well as using 40 MHz Channel Width are known to cause issues with older WiFi devices. Same with not reserving IP-address for the decvice in DHCP-scope.

Since then those and some other older IoT WiFi devices I was having issues with seems to work almost all of the time, (including Withings products I were having similar problems with). For reference, I am using several Unifi WiFi Access Point series products from Ubiquiti so coverage it very good too.

Otherwise the only other tip I have seen is having a continious ping to the WiFi module in order to force it to keep the connection alive.

@gary-sargent
Copy link

I've tried all those things, I've tried four different access points (including a really old one), I've had the access point a metre away from the module. In all cases the same happens - connects for 10 to 15 mins, disconnects for a long period, repeat.

I'm going to try to get it swapped out as I can only think it must be faulty.

@gary-sargent
Copy link

@Hedda look at these times! Each time it reconnects, it is dead on the hour mark! That is no coincidence.

image

@Hedda
Copy link
Contributor Author

Hedda commented Jun 5, 2024

@gary-sargent ok but if that is the old bwa module the. please post that to Home Assistent community forum instead of here in this issue as this is request is only about ControlMySpa cloud API and the new gateway, not the old module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants