Add Hot Spring Connected Spa integration
Unofficial cloud integration for Watkins/Hot Spring "Connected Spa" hot tubs. Reverse-engineered from the official Android app. - climate entity (setpoint + current water temp) via heater/control - sensors: water temperature, salt output level, salt cartridge - REST (JWT) login + spa discovery; mTLS fetch of rotating HiveMQ broker creds; MQTT subscribe (telemetry) / publish (control) - config flow prompts for account email + password (stored encrypted, never in repo) - no secrets committed: vendor mTLS client cert is loaded from host PEM files (see README); .gitignore blocks pem/p12/der/key/env Fixes bug-41mqxddz7zeh Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F6B8b3iYNv6QUftK2FDfYb
This commit is contained in:
commit
8cda06f7f3
17 files changed
+1006
No files matched your search
@@ -0,0 +1,88 @@
|
||||
"""Climate entity: the spa's water heater setpoint + current temperature."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ClimateEntity,
|
||||
ClimateEntityFeature,
|
||||
HVACMode,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from . import HotSpringConfigEntry
|
||||
from .const import DOMAIN, MANUFACTURER
|
||||
from .coordinator import HotSpringCoordinator
|
||||
|
||||
# Hot Spot spas run 80-104 F.
|
||||
MIN_TEMP_F = 80
|
||||
MAX_TEMP_F = 104
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: HotSpringConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
async_add_entities([HotSpringClimate(entry.runtime_data)])
|
||||
|
||||
|
||||
class HotSpringClimate(CoordinatorEntity[HotSpringCoordinator], ClimateEntity):
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None # use the device name
|
||||
_attr_hvac_modes = [HVACMode.HEAT]
|
||||
_attr_hvac_mode = HVACMode.HEAT
|
||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
_attr_target_temperature_step = 1
|
||||
_enable_turn_on_off_backwards_compatibility = False
|
||||
|
||||
def __init__(self, coordinator: HotSpringCoordinator) -> None:
|
||||
super().__init__(coordinator)
|
||||
root = coordinator.spa_info.root_topic if coordinator.spa_info else "spa"
|
||||
self._attr_unique_id = f"{root}_climate"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, root)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=coordinator.spa_info.name if coordinator.spa_info else "Hot Spring Spa",
|
||||
model="Connected Spa",
|
||||
)
|
||||
|
||||
@property
|
||||
def _celsius(self) -> bool:
|
||||
return (self.coordinator.spa and self.coordinator.spa.temperature_unit()) == "DegC"
|
||||
|
||||
@property
|
||||
def temperature_unit(self) -> str:
|
||||
return UnitOfTemperature.CELSIUS if self._celsius else UnitOfTemperature.FAHRENHEIT
|
||||
|
||||
@property
|
||||
def min_temp(self) -> float:
|
||||
return MIN_TEMP_F if not self._celsius else round((MIN_TEMP_F - 32) / 1.8)
|
||||
|
||||
@property
|
||||
def max_temp(self) -> float:
|
||||
return MAX_TEMP_F if not self._celsius else round((MAX_TEMP_F - 32) / 1.8)
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> float | None:
|
||||
return self.coordinator.spa.current_temperature() if self.coordinator.spa else None
|
||||
|
||||
@property
|
||||
def target_temperature(self) -> float | None:
|
||||
return self.coordinator.spa.setpoint() if self.coordinator.spa else None
|
||||
|
||||
async def async_set_temperature(self, **kwargs) -> None:
|
||||
temp = kwargs.get(ATTR_TEMPERATURE)
|
||||
if temp is None:
|
||||
return
|
||||
# The spa expects an integer in its configured unit.
|
||||
await self.coordinator.async_publish_control(
|
||||
"heater", {"temperatureABS": str(int(round(temp)))}
|
||||
)
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
self.async_write_ha_state()
|
||||
Reference in new issue
Block a user