Skip to content

Commit

Permalink
Slight improvements
Browse files Browse the repository at this point in the history
info.md is now ready
added some missing attributes
light exposes USE attribute
type and subtype exposed as one value
  • Loading branch information
jlvaillant committed Dec 19, 2020
1 parent 870b056 commit 5d6f708
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 38 deletions.
17 changes: 12 additions & 5 deletions custom_components/intellicenter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ def __init__(self, entry: ConfigEntry, controller, poolObject):
self._controller = controller
self._poolObject = poolObject
self._available = True
self._extraStateAttributes = []

_LOGGER.debug(f"mapping {object}")
_LOGGER.debug(f"mapping {poolObject}")

async def async_added_to_hass(self):
self.async_on_remove(
Expand Down Expand Up @@ -216,16 +217,22 @@ def device_state_attributes(self) -> Optional[Dict[str, Any]]:

object = self._poolObject

objectType = object.objtype
if object.subtype:
objectType+= f"/{object.subtype}"

attributes = {
'OBJNAM' : object.objnam,
'OBJTYPE' : object.objtype
'OBJTYPE' : objectType
}
if object.subtype:
attributes['SUBTYPE'] = object.subtype


if object.status:
attributes['Status'] = object.status

for attribute in self._extraStateAttributes:
if object[attribute]:
attributes[attribute] = object[attribute]

return attributes

def requestChanges(self, changes: dict) -> None:
Expand Down
8 changes: 6 additions & 2 deletions custom_components/intellicenter/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities):

for object in controller.model.objectList:
if object.isALight:
_LOGGER.debug(f"mapping {object}")
lights.append(PoolLight(entry, controller, object))
async_add_entities(lights)

class PoolLight(PoolEntity, LightEntity):
"""Representation of an Pentair light."""

def __init__(self, entry: ConfigEntry, controller, poolObject):
super().__init__(entry, controller, poolObject)
# USE appears to contain extra info like color...
self._extraStateAttributes = ['USE']

@property
def is_on(self) -> bool:
"""Return the state of the light."""
Expand All @@ -38,4 +42,4 @@ def turn_off(self, **kwargs: Any) -> None:

def turn_on(self, **kwargs: Any) -> None:
"""Turn off the light."""
self.requestChanges({'STATUS': self._poolObject.onStatus})
self.requestChanges({'STATUS': self._poolObject.onStatus})
6 changes: 3 additions & 3 deletions custom_components/intellicenter/pyintellicenter/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
'OBJTYP', 'SUBTYP', 'STATUS', 'SNAME', 'HITMP', 'MANHT', 'LOCY', 'LOTMP',
'AVAIL', 'HEATING', 'OFFSET', 'STOP', 'SSET', 'ZIP', 'STATE', 'VER', 'VACTIM',
'TEMPNC', 'CITY', 'SERVICE', 'ADDRESS', 'PROPNAME', 'PHONE', 'EMAIL2', 'DAY', 'VALVE',
'HTMODE', 'MODE', 'COUNTRY', 'TIMZON', 'NAME', 'VOL', 'DLSTIM',
'HTMODE', 'MODE', 'COUNTRY', 'TIMZON', 'NAME', 'VOL', 'DLSTIM', 'SELECT',
'LOCX', 'HTSRC', 'PHONE2', 'LSTTMP', 'SRIS', 'HEATER', 'START', 'MIN', 'VACFLO',
'EMAIL', 'CLK24A', 'PROBE', 'PWR', 'GPM', 'RPM', 'USE', 'ACT', 'FEATR',
'EMAIL', 'CLK24A', 'PROBE', 'SPEED', 'PWR', 'GPM', 'RPM', 'BOOST', 'USE', 'ACT', 'FEATR',
'DAY', 'SINGLE', 'TIME', 'TIMOUT', 'CIRCUIT', 'PASSWRD', 'SHOMNU', 'LIMIT', 'LISTORD',
'MANUAL', 'CHILD', 'DNTSTP', 'RLY', 'SYNC', 'SET', 'SWIM', 'USAGE', 'BODY'
'MANUAL', 'PARENT', 'CHILD', 'DNTSTP', 'RLY', 'SYNC', 'SET', 'SWIM', 'USAGE', 'BODY'
]

class PoolObject:
Expand Down
31 changes: 5 additions & 26 deletions custom_components/intellicenter/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities):

for object in controller.model.objectList:
if object.objtype == 'BODY':
_LOGGER.debug(f"mapping {object} to a switch")
switches.append(PoolBody(entry, controller, object))
elif object.objtype == 'CIRCUIT' and not object.isALight and object.isFeatured:
_LOGGER.debug(f"mapping {object} to a switch")
switches.append(PoolCircuit(entry, controller, object))

async_add_entities(switches)
Expand All @@ -46,31 +44,12 @@ def turn_on(self, **kwargs: Any) -> None:
self.requestChanges({'STATUS': self._poolObject.onStatus})

class PoolBody(PoolCircuit):
"""Representation of a body of water."""

def __init__(self, entry: ConfigEntry, controller, poolObject):
super().__init__(entry, controller, poolObject)
self._extraStateAttributes = ['VOL','HEATER','HTMODE']

@property
def icon(self):
return "mdi:pool"

@property
def device_state_attributes(self) -> Optional[Dict[str, Any]]:
"""Return the state attributes of the entity."""

attributes = super().device_state_attributes

object = self._poolObject

if object['VOL']:
attributes['Volume'] = object['VOL']

if object['HEATER']:
attributes['HEATER'] = object['HEATER']

if object['HTMODE']:
attributes['HTMODE'] = object['HTMODE']

# for attribute in self._poolObject.attributes:
# value = self._poolObject[attribute]
# if value:
# attributes[attribute] = value

return attributes
35 changes: 33 additions & 2 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,36 @@

### Features

- Zeroconf discovery
- Local push makes system very responsive
- Connect to a Pentair Intellicenter thru the local (network) inferface
- supports Zeroconf discovery
- reconnects itself grafecully in the Intellicenter reboots and/or gets disconnected
- "Local push" makes system very responsive

### Entities created

- for each body of water (like Pool and Spa) it creates:
- a switch to turn the body on and off
- a sensor for the last temperature
- a sensor for the desired temperature
- a water heater (if applicable):
- set to ON to enable that heater, set to OFF otherwise
- status is 'OFF', 'IDLE' (if heater is enabled but NOT running) or
'HEATING' is the heater is currently running
- creates a swicth for all circuits marked as "Featured" on the IntelliCenter
(for example "Cleaner" or "Spa Blower)
- for each light (and light show) it creates a Light entity
Note that dimming and color effects are currently not implemented
- for each pump, a binary_sensor is created
if the pump supports it, a sensor will reflect how much power the pump uses
- a binary_sensor will indicate if the system is in Freeze prevention mode
- sensors will be created for each sensor in the system (like Water and Air)
Note that a Solar sensor might also be present even if (like in my case) its value
is not relevant

### Caveats

- the use of a password on the IntelliCenter is NOT supported
- schedules are not reflected in HomeAssistant (though they keep running)
- while I tried to make the code as generic as possible I could only test using
my own pool configuration. In particular, I do not have covers, chemistry, cascades,
solar heater, etc... These may work out of the box or not...

0 comments on commit 5d6f708

Please sign in to comment.