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 authored and GitHub committed 2020-08-22 15:19:20 -06:00
1 parent 69de68c025
commit fa09a93cfe
1 file changed
+3 -2
@@ -45,7 +45,7 @@ ATTR_ZONES = "zones"
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 = {
0: "Not Set",
@@ -233,7 +233,7 @@ class RainMachineProgram(RainMachineSwitch):
ATTR_ID: self._switch_data["uid"],
ATTR_NEXT_RUN: next_run,
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),
}
)
@@ -290,6 +290,7 @@ class RainMachineZone(RainMachineSwitch):
self._attrs.update(
{
ATTR_STATUS: RUN_STATUS_MAP[self._switch_data["state"]],
ATTR_AREA: details.get("waterSense").get("area"),
ATTR_CURRENT_CYCLE: self._switch_data.get("cycle"),
ATTR_FIELD_CAPACITY: details.get("waterSense").get("fieldCapacity"),