diff --git a/README.md b/README.md index fcca559..2fcb454 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ### From HACS 1. Install HACS if you haven't already (see [installation guide](https://hacs.netlify.com/docs/installation/manual)). -2. Add custom repository `https://github.com/jlvaillant/intellicenter` as "Integration" in the settings tab of HACS. +2. Add custom repository `https://github.com/dwradcliffe/intellicenter` as "Integration" in the settings tab of HACS. 3. Find and install "Pentair Intellicenter" integration in HACS's "Integrations" tab. 4. Restart your Home Assistant. 5. 'Pentair Intellicenter' should appear thru discovery in your Home Assistant Integration's page @@ -69,6 +69,6 @@ - In general it is recommended to reload the integration where significant changes are done to the pool configuration [hacs]: https://github.com/hacs/integration -[hacsbadge]: https://img.shields.io/badge/HACS-Default-orange -[releases-shield]: https://img.shields.io/github/v/release/jlvaillant/intellicenter -[releases]: https://github.com/jlvaillant/intellicenter/releases +[hacsbadge]: https://img.shields.io/badge/HACS-Custom-orange +[releases-shield]: https://img.shields.io/github/v/release/dwradcliffe/intellicenter +[releases]: https://github.com/dwradcliffe/intellicenter/releases diff --git a/custom_components/intellicenter/__init__.py b/custom_components/intellicenter/__init__.py index 042f9a8..1099763 100644 --- a/custom_components/intellicenter/__init__.py +++ b/custom_components/intellicenter/__init__.py @@ -13,8 +13,7 @@ from homeassistant.const import ( CONF_HOST, EVENT_HOMEASSISTANT_STOP, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfTemperature ) from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady @@ -348,5 +347,5 @@ def _connection_callback(self, is_connected): def pentairTemperatureSettings(self): """Return the temperature units from the Pentair system.""" return ( - TEMP_CELSIUS if self._controller.systemInfo.usesMetric else TEMP_FAHRENHEIT + UnitOfTemperature.CELSIUS if self._controller.systemInfo.usesMetric else UnitOfTemperature.FAHRENHEIT ) diff --git a/custom_components/intellicenter/light.py b/custom_components/intellicenter/light.py index a80541c..e2b52ec 100644 --- a/custom_components/intellicenter/light.py +++ b/custom_components/intellicenter/light.py @@ -4,7 +4,12 @@ import logging from typing import Any, Dict -from homeassistant.components.light import ATTR_EFFECT, SUPPORT_EFFECT, LightEntity +from homeassistant.components.light import ( + ATTR_EFFECT, + ColorMode, + LightEntity, + LightEntityFeature, +) from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType @@ -57,7 +62,6 @@ async def async_setup_entry( ) ) elif object.isALightShow: - supportColorEffects = reduce( lambda x, y: x and y, map( @@ -94,6 +98,7 @@ def __init__( self._extra_state_attributes = [USE_ATTR] self._features = 0 + self._supported_color_modes = ColorMode.ONOFF self._lightEffects = colorEffects self._reversedLightEffects = ( @@ -101,13 +106,18 @@ def __init__( ) if self._lightEffects: - self._features |= SUPPORT_EFFECT + self._features |= LightEntityFeature.EFFECT @property def supported_features(self) -> int: """Return supported features.""" return self._features + @property + def supported_color_modes(self) -> set[ColorMode] | set[str] | None: + """Return supported color modes.""" + return self._supported_color_modes + @property def effect_list(self) -> list: """Return the list of supported effects.""" diff --git a/custom_components/intellicenter/manifest.json b/custom_components/intellicenter/manifest.json index 31d034f..2607a02 100644 --- a/custom_components/intellicenter/manifest.json +++ b/custom_components/intellicenter/manifest.json @@ -1,10 +1,10 @@ { "domain": "intellicenter", "name": "Pentair IntelliCenter", - "version": "1.4.0", - "documentation": "https://github.com/jlvaillant/intellicenter", - "issue_tracker": "https://github.com/jlvaillant/intellicenter/issues", - "codeowners": ["@jlvaillant"], + "version": "1.4.0a3", + "documentation": "https://github.com/dwradcliffe/intellicenter", + "issue_tracker": "https://github.com/dwradcliffe/intellicenter/issues", + "codeowners": ["@dwradcliffe"], "requirements": [], "dependencies": [], "config_flow": true, diff --git a/custom_components/intellicenter/number.py b/custom_components/intellicenter/number.py index e727522..6d309c3 100644 --- a/custom_components/intellicenter/number.py +++ b/custom_components/intellicenter/number.py @@ -12,11 +12,14 @@ from homeassistant.helpers.typing import HomeAssistantType from . import PoolEntity -from .const import CONST_RPM, DOMAIN +from .const import DOMAIN from homeassistant.const import PERCENTAGE from .pyintellicenter import ( + BODY_ATTR, + BODY_TYPE, CHEM_TYPE, PRIM_ATTR, + SEC_ATTR, ModelController, PoolObject, ) @@ -42,16 +45,30 @@ async def async_setup_entry( and object.subtype == "ICHLOR" and PRIM_ATTR in object.attributes ): - numbers.append( - PoolNumber( - entry, - controller, - object, - unit_of_measurement=PERCENTAGE, - attribute_key=PRIM_ATTR, - name="+ Output %", - ) - ) + bodies = controller.model.getByType(BODY_TYPE) + intellichlor_bodies = object[BODY_ATTR].split(" ") + + body: PoolObject + for body in bodies: + intellichlor_index = intellichlor_bodies.index(body.objnam) + attribute_key = None + if intellichlor_index == 0: + attribute_key = PRIM_ATTR + elif intellichlor_index == 1: + attribute_key = SEC_ATTR + if attribute_key is not None: + numbers.append( + PoolNumber( + entry, + controller, + # body, + object, + unit_of_measurement=PERCENTAGE, + attribute_key=attribute_key, + name=f"+ Output % ({body.sname})", + ) + ) + async_add_entities(numbers) diff --git a/custom_components/intellicenter/pyintellicenter/__init__.py b/custom_components/intellicenter/pyintellicenter/__init__.py index 477ab94..1a1a839 100644 --- a/custom_components/intellicenter/pyintellicenter/__init__.py +++ b/custom_components/intellicenter/pyintellicenter/__init__.py @@ -41,6 +41,7 @@ RPM_ATTR, SALT_ATTR, SCHED_TYPE, + SEC_ATTR, SELECT_ATTR, SENSE_TYPE, SHOMNU_ATTR, @@ -117,6 +118,7 @@ READY_ATTR, RPM_ATTR, SALT_ATTR, + SEC_ATTR, SELECT_ATTR, SHOMNU_ATTR, SNAME_ATTR, diff --git a/custom_components/intellicenter/pyintellicenter/attributes.py b/custom_components/intellicenter/pyintellicenter/attributes.py index 4d47eca..0f06ab5 100644 --- a/custom_components/intellicenter/pyintellicenter/attributes.py +++ b/custom_components/intellicenter/pyintellicenter/attributes.py @@ -44,6 +44,7 @@ READY_ATTR = "READY" RPM_ATTR = "RPM" SALT_ATTR = "SALT" +SEC_ATTR = "SEC" SELECT_ATTR = "SELECT" SHOMNU_ATTR = "SHOMNU" SNAME_ATTR = "SNAME" @@ -114,7 +115,6 @@ VOL_ATTR, # (int) Volume in Gallons } - CHEM_ATTRIBUTES = { "ALK", # (int) IntelliChem: Alkalinity setting BODY_ATTR, # (objnam) BODY being managed @@ -133,10 +133,10 @@ "PHSET", # (float) IntelliChem Ph level setting PHTNK_ATTR, # (int) IntelliChem: Ph Tank Level PHVAL_ATTR, # (float) IntelliChem: Ph Level - PRIM_ATTR, # (int) Intellichor: output setting in % - QUALTY_ATTR, # (float) Intellichem: Water Quality (Saturation Index) + PRIM_ATTR, # (int) IntelliChlor: primary body output setting in % + QUALTY_ATTR, # (float) IntelliChem: Water Quality (Saturation Index) SALT_ATTR, # (int) Salt level - "SEC", # (int) IntelliChlor ?? + SEC_ATTR, # (int) IntelliChlor: secondary body output setting in % "SHARE", # (objnam) ?? "SINDEX", # (int) ?? SNAME_ATTR, # friendly name @@ -144,6 +144,7 @@ SUPER_ATTR, # (ON/OFF) IntelliChlor: turn on Boost mode (aka Super Chlorinate) TIMOUT_ATTR, # (int) IntelliChlor: in seconds ?? } + CIRCGRP_ATTRIBUTES = { ACT_ATTR, CIRCUIT_ATTR, diff --git a/custom_components/intellicenter/pyintellicenter/protocol.py b/custom_components/intellicenter/pyintellicenter/protocol.py index 8c0a99e..d369cb2 100644 --- a/custom_components/intellicenter/pyintellicenter/protocol.py +++ b/custom_components/intellicenter/pyintellicenter/protocol.py @@ -99,7 +99,6 @@ def _writeToTransport(self, request): f"PROTOCOL: writing to transport: (size {len(request)}): {request}" ) self._transport.write(request.encode()) - self._transport.write(b"\r\n") def sendRequest(self, request: str) -> None: """Either send the request to the wire or queue it for later.""" diff --git a/custom_components/intellicenter/sensor.py b/custom_components/intellicenter/sensor.py index 6bf4741..6518f90 100644 --- a/custom_components/intellicenter/sensor.py +++ b/custom_components/intellicenter/sensor.py @@ -6,7 +6,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, - POWER_WATT, + UnitOfPower, ) from homeassistant.components.sensor import ( SensorDeviceClass, @@ -72,7 +72,7 @@ async def async_setup_entry( controller, object, device_class=SensorDeviceClass.POWER, - unit_of_measurement=POWER_WATT, + unit_of_measurement=UnitOfPower.WATT, attribute_key=PWR_ATTR, name="+ power", rounding_factor=25, diff --git a/custom_components/intellicenter/water_heater.py b/custom_components/intellicenter/water_heater.py index 71907f4..958c5ce 100644 --- a/custom_components/intellicenter/water_heater.py +++ b/custom_components/intellicenter/water_heater.py @@ -4,9 +4,8 @@ from typing import Any, Dict, Optional from homeassistant.components.water_heater import ( - SUPPORT_OPERATION_MODE, - SUPPORT_TARGET_TEMPERATURE, WaterHeaterEntity, + WaterHeaterEntityFeature, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, STATE_IDLE, STATE_OFF, STATE_ON @@ -123,7 +122,7 @@ def unique_id(self): @property def supported_features(self): """Return the list of supported features.""" - return SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE + return WaterHeaterEntityFeature.TARGET_TEMPERATURE | WaterHeaterEntityFeature.OPERATION_MODE @property def temperature_unit(self):