add zone status attribute so we can know if queued (#39133)

Before this proposed change, all of the zones related to a running program turn "on", but it's not possible to know which zone is actually running (vs. queued). Adding the mapped state values (they are the same as program status values) as an attribute will allow inspection of all 3 states.
This commit is contained in:
ktownsend-personal 2020-08-22 16:19:20 -05:00 committed by GitHub
parent 69de68c025
commit fa09a93cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,7 +45,7 @@ ATTR_ZONES = "zones"
DAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] DAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
PROGRAM_STATUS_MAP = {0: "Not Running", 1: "Running", 2: "Queued"} RUN_STATUS_MAP = {0: "Not Running", 1: "Running", 2: "Queued"}
SOIL_TYPE_MAP = { SOIL_TYPE_MAP = {
0: "Not Set", 0: "Not Set",
@ -233,7 +233,7 @@ class RainMachineProgram(RainMachineSwitch):
ATTR_ID: self._switch_data["uid"], ATTR_ID: self._switch_data["uid"],
ATTR_NEXT_RUN: next_run, ATTR_NEXT_RUN: next_run,
ATTR_SOAK: self._switch_data.get("soak"), ATTR_SOAK: self._switch_data.get("soak"),
ATTR_STATUS: PROGRAM_STATUS_MAP[self._switch_data["status"]], ATTR_STATUS: RUN_STATUS_MAP[self._switch_data["status"]],
ATTR_ZONES: ", ".join(z["name"] for z in self.zones), ATTR_ZONES: ", ".join(z["name"] for z in self.zones),
} }
) )
@ -290,6 +290,7 @@ class RainMachineZone(RainMachineSwitch):
self._attrs.update( self._attrs.update(
{ {
ATTR_STATUS: RUN_STATUS_MAP[self._switch_data["state"]],
ATTR_AREA: details.get("waterSense").get("area"), ATTR_AREA: details.get("waterSense").get("area"),
ATTR_CURRENT_CYCLE: self._switch_data.get("cycle"), ATTR_CURRENT_CYCLE: self._switch_data.get("cycle"),
ATTR_FIELD_CAPACITY: details.get("waterSense").get("fieldCapacity"), ATTR_FIELD_CAPACITY: details.get("waterSense").get("fieldCapacity"),