Skip to content

Commit 5d6f708

Browse files
committed
Slight improvements
info.md is now ready added some missing attributes light exposes USE attribute type and subtype exposed as one value
1 parent 870b056 commit 5d6f708

File tree

5 files changed

+59
-38
lines changed

5 files changed

+59
-38
lines changed

custom_components/intellicenter/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ def __init__(self, entry: ConfigEntry, controller, poolObject):
152152
self._controller = controller
153153
self._poolObject = poolObject
154154
self._available = True
155+
self._extraStateAttributes = []
155156

156-
_LOGGER.debug(f"mapping {object}")
157+
_LOGGER.debug(f"mapping {poolObject}")
157158

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

217218
object = self._poolObject
218219

220+
objectType = object.objtype
221+
if object.subtype:
222+
objectType+= f"/{object.subtype}"
223+
219224
attributes = {
220225
'OBJNAM' : object.objnam,
221-
'OBJTYPE' : object.objtype
226+
'OBJTYPE' : objectType
222227
}
223-
if object.subtype:
224-
attributes['SUBTYPE'] = object.subtype
225-
228+
226229
if object.status:
227230
attributes['Status'] = object.status
228231

232+
for attribute in self._extraStateAttributes:
233+
if object[attribute]:
234+
attributes[attribute] = object[attribute]
235+
229236
return attributes
230237

231238
def requestChanges(self, changes: dict) -> None:

custom_components/intellicenter/light.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities):
2020

2121
for object in controller.model.objectList:
2222
if object.isALight:
23-
_LOGGER.debug(f"mapping {object}")
2423
lights.append(PoolLight(entry, controller, object))
2524
async_add_entities(lights)
2625

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

29+
def __init__(self, entry: ConfigEntry, controller, poolObject):
30+
super().__init__(entry, controller, poolObject)
31+
# USE appears to contain extra info like color...
32+
self._extraStateAttributes = ['USE']
33+
3034
@property
3135
def is_on(self) -> bool:
3236
"""Return the state of the light."""
@@ -38,4 +42,4 @@ def turn_off(self, **kwargs: Any) -> None:
3842

3943
def turn_on(self, **kwargs: Any) -> None:
4044
"""Turn off the light."""
41-
self.requestChanges({'STATUS': self._poolObject.onStatus})
45+
self.requestChanges({'STATUS': self._poolObject.onStatus})

custom_components/intellicenter/pyintellicenter/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
'OBJTYP', 'SUBTYP', 'STATUS', 'SNAME', 'HITMP', 'MANHT', 'LOCY', 'LOTMP',
1010
'AVAIL', 'HEATING', 'OFFSET', 'STOP', 'SSET', 'ZIP', 'STATE', 'VER', 'VACTIM',
1111
'TEMPNC', 'CITY', 'SERVICE', 'ADDRESS', 'PROPNAME', 'PHONE', 'EMAIL2', 'DAY', 'VALVE',
12-
'HTMODE', 'MODE', 'COUNTRY', 'TIMZON', 'NAME', 'VOL', 'DLSTIM',
12+
'HTMODE', 'MODE', 'COUNTRY', 'TIMZON', 'NAME', 'VOL', 'DLSTIM', 'SELECT',
1313
'LOCX', 'HTSRC', 'PHONE2', 'LSTTMP', 'SRIS', 'HEATER', 'START', 'MIN', 'VACFLO',
14-
'EMAIL', 'CLK24A', 'PROBE', 'PWR', 'GPM', 'RPM', 'USE', 'ACT', 'FEATR',
14+
'EMAIL', 'CLK24A', 'PROBE', 'SPEED', 'PWR', 'GPM', 'RPM', 'BOOST', 'USE', 'ACT', 'FEATR',
1515
'DAY', 'SINGLE', 'TIME', 'TIMOUT', 'CIRCUIT', 'PASSWRD', 'SHOMNU', 'LIMIT', 'LISTORD',
16-
'MANUAL', 'CHILD', 'DNTSTP', 'RLY', 'SYNC', 'SET', 'SWIM', 'USAGE', 'BODY'
16+
'MANUAL', 'PARENT', 'CHILD', 'DNTSTP', 'RLY', 'SYNC', 'SET', 'SWIM', 'USAGE', 'BODY'
1717
]
1818

1919
class PoolObject:

custom_components/intellicenter/switch.py

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities):
2121

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

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

4846
class PoolBody(PoolCircuit):
47+
"""Representation of a body of water."""
48+
49+
def __init__(self, entry: ConfigEntry, controller, poolObject):
50+
super().__init__(entry, controller, poolObject)
51+
self._extraStateAttributes = ['VOL','HEATER','HTMODE']
4952

5053
@property
5154
def icon(self):
5255
return "mdi:pool"
53-
54-
@property
55-
def device_state_attributes(self) -> Optional[Dict[str, Any]]:
56-
"""Return the state attributes of the entity."""
57-
58-
attributes = super().device_state_attributes
59-
60-
object = self._poolObject
61-
62-
if object['VOL']:
63-
attributes['Volume'] = object['VOL']
64-
65-
if object['HEATER']:
66-
attributes['HEATER'] = object['HEATER']
67-
68-
if object['HTMODE']:
69-
attributes['HTMODE'] = object['HTMODE']
70-
71-
# for attribute in self._poolObject.attributes:
72-
# value = self._poolObject[attribute]
73-
# if value:
74-
# attributes[attribute] = value
75-
76-
return attributes

info.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,36 @@
22

33
### Features
44

5-
- Zeroconf discovery
6-
- Local push makes system very responsive
5+
- Connect to a Pentair Intellicenter thru the local (network) inferface
6+
- supports Zeroconf discovery
7+
- reconnects itself grafecully in the Intellicenter reboots and/or gets disconnected
8+
- "Local push" makes system very responsive
9+
10+
### Entities created
11+
12+
- for each body of water (like Pool and Spa) it creates:
13+
- a switch to turn the body on and off
14+
- a sensor for the last temperature
15+
- a sensor for the desired temperature
16+
- a water heater (if applicable):
17+
- set to ON to enable that heater, set to OFF otherwise
18+
- status is 'OFF', 'IDLE' (if heater is enabled but NOT running) or
19+
'HEATING' is the heater is currently running
20+
- creates a swicth for all circuits marked as "Featured" on the IntelliCenter
21+
(for example "Cleaner" or "Spa Blower)
22+
- for each light (and light show) it creates a Light entity
23+
Note that dimming and color effects are currently not implemented
24+
- for each pump, a binary_sensor is created
25+
if the pump supports it, a sensor will reflect how much power the pump uses
26+
- a binary_sensor will indicate if the system is in Freeze prevention mode
27+
- sensors will be created for each sensor in the system (like Water and Air)
28+
Note that a Solar sensor might also be present even if (like in my case) its value
29+
is not relevant
30+
31+
### Caveats
32+
33+
- the use of a password on the IntelliCenter is NOT supported
34+
- schedules are not reflected in HomeAssistant (though they keep running)
35+
- while I tried to make the code as generic as possible I could only test using
36+
my own pool configuration. In particular, I do not have covers, chemistry, cascades,
37+
solar heater, etc... These may work out of the box or not...

0 commit comments

Comments
 (0)