Skip to content

Commit

Permalink
Merge pull request #67 from philipflesher/main
Browse files Browse the repository at this point in the history
Adding support for IntelliChlor primary and secondary body output percentage controls
  • Loading branch information
jlvaillant committed Mar 8, 2024
2 parents 52ad832 + cf4eaee commit a89352a
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 35 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
5 changes: 2 additions & 3 deletions custom_components/intellicenter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
16 changes: 13 additions & 3 deletions custom_components/intellicenter/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -57,7 +62,6 @@ async def async_setup_entry(
)
)
elif object.isALightShow:

supportColorEffects = reduce(
lambda x, y: x and y,
map(
Expand Down Expand Up @@ -94,20 +98,26 @@ def __init__(
self._extra_state_attributes = [USE_ATTR]

self._features = 0
self._supported_color_modes = ColorMode.ONOFF

self._lightEffects = colorEffects
self._reversedLightEffects = (
dict(map(reversed, colorEffects.items())) if colorEffects else None
)

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."""
Expand Down
8 changes: 4 additions & 4 deletions custom_components/intellicenter/manifest.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
39 changes: 28 additions & 11 deletions custom_components/intellicenter/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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)


Expand Down
2 changes: 2 additions & 0 deletions custom_components/intellicenter/pyintellicenter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
RPM_ATTR,
SALT_ATTR,
SCHED_TYPE,
SEC_ATTR,
SELECT_ATTR,
SENSE_TYPE,
SHOMNU_ATTR,
Expand Down Expand Up @@ -117,6 +118,7 @@
READY_ATTR,
RPM_ATTR,
SALT_ATTR,
SEC_ATTR,
SELECT_ATTR,
SHOMNU_ATTR,
SNAME_ATTR,
Expand Down
9 changes: 5 additions & 4 deletions custom_components/intellicenter/pyintellicenter/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -114,7 +115,6 @@
VOL_ATTR, # (int) Volume in Gallons
}


CHEM_ATTRIBUTES = {
"ALK", # (int) IntelliChem: Alkalinity setting
BODY_ATTR, # (objnam) BODY being managed
Expand All @@ -133,17 +133,18 @@
"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
SUBTYP_ATTR, # 'ICHLOR' for IntelliChlor, 'ICHEM' for IntelliChem
SUPER_ATTR, # (ON/OFF) IntelliChlor: turn on Boost mode (aka Super Chlorinate)
TIMOUT_ATTR, # (int) IntelliChlor: in seconds ??
}

CIRCGRP_ATTRIBUTES = {
ACT_ATTR,
CIRCUIT_ATTR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 2 additions & 2 deletions custom_components/intellicenter/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions custom_components/intellicenter/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit a89352a

Please sign in to comment.