Skip to content

Commit

Permalink
cleanup shadowed vars
Browse files Browse the repository at this point in the history
  • Loading branch information
dwradcliffe committed Apr 26, 2024
1 parent 4d5fa92 commit 8d9651b
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 71 deletions.
20 changes: 10 additions & 10 deletions custom_components/intellicenter/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,39 @@ async def async_setup_entry(

sensors = []

object: PoolObject
for object in controller.model.objectList:
if object.objtype == CIRCUIT_TYPE and object.subtype == "FRZ":
obj: PoolObject
for obj in controller.model.objectList:
if obj.objtype == CIRCUIT_TYPE and obj.subtype == "FRZ":
sensors.append(
PoolBinarySensor(
entry,
controller,
object,
obj,
icon = "mdi:snowflake"
)
)
elif object.objtype == HEATER_TYPE:
elif obj.objtype == HEATER_TYPE:
sensors.append(
HeaterBinarySensor(
entry,
controller,
object,
obj,
)
)
elif object.objtype == "SCHED":
elif obj.objtype == "SCHED":
sensors.append(
PoolBinarySensor(
entry,
controller,
object,
obj,
attribute_key="ACT",
name="+ (schedule)",
enabled_by_default=False,
extraStateAttributes={"VACFLO"},
)
)
elif object.objtype == "PUMP":
sensors.append(PoolBinarySensor(entry, controller, object, valueForON="10"))
elif obj.objtype == "PUMP":
sensors.append(PoolBinarySensor(entry, controller, obj, valueForON="10"))
async_add_entities(sensors)


Expand Down
16 changes: 8 additions & 8 deletions custom_components/intellicenter/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,28 @@ async def async_setup_entry(

lights = []

object: PoolObject
for object in controller.model.objectList:
if object.isALight:
obj: PoolObject
for obj in controller.model.objectList:
if obj.isALight:
lights.append(
PoolLight(
entry,
controller,
object,
LIGHTS_EFFECTS if object.supportColorEffects else None,
obj,
LIGHTS_EFFECTS if obj.supportColorEffects else None,
)
)
elif object.isALightShow:
elif obj.isALightShow:
supportColorEffects = reduce(
lambda x, y: x and y,
(controller.model[obj[CIRCUIT_ATTR]].supportColorEffects for obj in controller.model.getChildren(object)),
(controller.model[obj[CIRCUIT_ATTR]].supportColorEffects for obj in controller.model.getChildren(obj)),
True,
)
lights.append(
PoolLight(
entry,
controller,
object,
obj,
LIGHTS_EFFECTS if supportColorEffects else None,
)
)
Expand Down
14 changes: 7 additions & 7 deletions custom_components/intellicenter/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ async def async_setup_entry(

numbers = []

object: PoolObject
for object in controller.model.objectList:
obj: PoolObject
for obj in controller.model.objectList:
if (
object.objtype == CHEM_TYPE
and object.subtype == "ICHLOR"
and PRIM_ATTR in object.attributes
obj.objtype == CHEM_TYPE
and obj.subtype == "ICHLOR"
and PRIM_ATTR in obj.attributes
):
bodies = controller.model.getByType(BODY_TYPE)
intellichlor_bodies = object[BODY_ATTR].split(" ")
intellichlor_bodies = obj[BODY_ATTR].split(" ")

body: PoolObject
for body in bodies:
Expand All @@ -62,7 +62,7 @@ async def async_setup_entry(
entry,
controller,
# body,
object,
obj,
unit_of_measurement=PERCENTAGE,
attribute_key=attribute_key,
name=f"+ Output % ({body.sname})",
Expand Down
58 changes: 29 additions & 29 deletions custom_components/intellicenter/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,62 +49,62 @@ async def async_setup_entry(

sensors = []

object: PoolObject
for object in controller.model.objectList:
if object.objtype == SENSE_TYPE:
obj: PoolObject
for obj in controller.model.objectList:
if obj.objtype == SENSE_TYPE:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=SensorDeviceClass.TEMPERATURE,
attribute_key=SOURCE_ATTR,
)
)
elif object.objtype == PUMP_TYPE:
if object[PWR_ATTR]:
elif obj.objtype == PUMP_TYPE:
if obj[PWR_ATTR]:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=SensorDeviceClass.POWER,
unit_of_measurement=UnitOfPower.WATT,
attribute_key=PWR_ATTR,
name="+ power",
rounding_factor=25,
)
)
if object[RPM_ATTR]:
if obj[RPM_ATTR]:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=None,
unit_of_measurement=CONST_RPM,
attribute_key=RPM_ATTR,
name="+ rpm",
)
)
if object[GPM_ATTR]:
if obj[GPM_ATTR]:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=None,
unit_of_measurement=CONST_GPM,
attribute_key=GPM_ATTR,
name="+ gpm",
)
)
elif object.objtype == BODY_TYPE:
elif obj.objtype == BODY_TYPE:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=SensorDeviceClass.TEMPERATURE,
attribute_key=LSTTMP_ATTR,
name="+ last temp",
Expand All @@ -114,76 +114,76 @@ async def async_setup_entry(
PoolSensor(
entry,
controller,
object,
obj,
device_class=SensorDeviceClass.TEMPERATURE,
attribute_key=LOTMP_ATTR,
name="+ desired temp",
)
)
elif object.objtype == CHEM_TYPE:
if object.subtype == "ICHEM":
if PHVAL_ATTR in object.attributes:
elif obj.objtype == CHEM_TYPE:
if obj.subtype == "ICHEM":
if PHVAL_ATTR in obj.attributes:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=None,
attribute_key=PHVAL_ATTR,
name="+ (pH)",
)
)
if ORPVAL_ATTR in object.attributes:
if ORPVAL_ATTR in obj.attributes:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=None,
attribute_key=ORPVAL_ATTR,
name="+ (ORP)",
)
)
if QUALTY_ATTR in object.attributes:
if QUALTY_ATTR in obj.attributes:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=None,
attribute_key=QUALTY_ATTR,
name="+ (Water Quality)",
)
)
if PHTNK_ATTR in object.attributes:
if PHTNK_ATTR in obj.attributes:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=None,
attribute_key=PHTNK_ATTR,
name="+ (Ph Tank Level)",
)
)
if ORPTNK_ATTR in object.attributes:
if ORPTNK_ATTR in obj.attributes:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=None,
attribute_key=ORPTNK_ATTR,
name="+ (ORP Tank Level)",
)
)
elif object.subtype == "ICHLOR":
if SALT_ATTR in object.attributes:
elif obj.subtype == "ICHLOR":
if SALT_ATTR in obj.attributes:
sensors.append(
PoolSensor(
entry,
controller,
object,
obj,
device_class=None,
unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
attribute_key=SALT_ATTR,
Expand Down
34 changes: 17 additions & 17 deletions custom_components/intellicenter/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,44 +36,44 @@ async def async_setup_entry(

switches = []

object: PoolObject
for object in controller.model.objectList:
if object.objtype == BODY_TYPE:
switches.append(PoolBody(entry, controller, object))
obj: PoolObject
for obj in controller.model.objectList:
if obj.objtype == BODY_TYPE:
switches.append(PoolBody(entry, controller, obj))
elif (
object.objtype == CHEM_TYPE
and object.subtype == "ICHLOR"
and SUPER_ATTR in object.attributes
obj.objtype == CHEM_TYPE
and obj.subtype == "ICHLOR"
and SUPER_ATTR in obj.attributes
):
switches.append(
PoolCircuit(
entry,
controller,
object,
obj,
attribute_key=SUPER_ATTR,
name="+ Superchlorinate",
icon="mdi:alpha-s-box-outline",
)
)
elif (
object.objtype == CIRCUIT_TYPE
and not (object.isALight or object.isALightShow)
and object.isFeatured
obj.objtype == CIRCUIT_TYPE
and not (obj.isALight or obj.isALightShow)
and obj.isFeatured
):
switches.append(
PoolCircuit(entry, controller, object, icon="mdi:alpha-f-box-outline"))
PoolCircuit(entry, controller, obj, icon="mdi:alpha-f-box-outline"))
elif (
object.objtype == CIRCUIT_TYPE
and object.subtype == "CIRCGRP"
obj.objtype == CIRCUIT_TYPE
and obj.subtype == "CIRCGRP"
):
switches.append(
PoolCircuit(entry, controller, object, icon="mdi:alpha-g-box-outline"))
elif object.objtype == SYSTEM_TYPE:
PoolCircuit(entry, controller, obj, icon="mdi:alpha-g-box-outline"))
elif obj.objtype == SYSTEM_TYPE:
switches.append(
PoolCircuit(
entry,
controller,
object,
obj,
VACFLO_ATTR,
name="Vacation mode",
icon="mdi:palm-tree",
Expand Down

0 comments on commit 8d9651b

Please sign in to comment.