Skip to content

Commit

Permalink
replacement of the codified style in literary style for the descripti…
Browse files Browse the repository at this point in the history
…on of events in the calendar
  • Loading branch information
kcofoni committed Nov 18, 2023
1 parent 5fb24c3 commit edbe3b5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
3 changes: 3 additions & 0 deletions custom_components/netro_watering/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
NETRO_SCHEDULE_LOCAL_START_TIME = "local_start_time"
NETRO_SCHEDULE_LOCAL_END_TIME = "local_end_time"
NETRO_SCHEDULE_SOURCE = "source"
NETRO_SCHEDULE_FIX = "FIX"
NETRO_SCHEDULE_SMART = "SMART"
NETRO_SCHEDULE_MANUAL = "MANUAL"

NETRO_MOISTURE_ID = "id"
NETRO_MOISTURE_ZONE = "zone"
Expand Down
53 changes: 49 additions & 4 deletions custom_components/netro_watering/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
NETRO_SCHEDULE_END_TIME,
NETRO_SCHEDULE_EXECUTED,
NETRO_SCHEDULE_EXECUTING,
NETRO_SCHEDULE_FIX,
NETRO_SCHEDULE_MANUAL,
NETRO_SCHEDULE_SMART,
NETRO_SCHEDULE_SOURCE,
NETRO_SCHEDULE_START_TIME,
NETRO_SCHEDULE_STATUS,
Expand Down Expand Up @@ -611,7 +614,7 @@ def calendar_schedules(
schedule[NETRO_SCHEDULE_END_TIME] + TZ_OFFSET
),
"summary": f"{self._active_zones[schedule[NETRO_SCHEDULE_ZONE]].name}",
"description": "Duration: {} min. - Source: {}".format(
"description": "Duration: {} minutes, {}, {}.".format(
round(
(
datetime.datetime.fromisoformat(
Expand All @@ -623,7 +626,26 @@ def calendar_schedules(
).seconds
/ 60
),
schedule[NETRO_SCHEDULE_SOURCE],
{
NETRO_SCHEDULE_FIX: "schedule from programs",
NETRO_SCHEDULE_SMART: "Netro generated schedule",
NETRO_SCHEDULE_MANUAL: "manual watering",
}[schedule[NETRO_SCHEDULE_SOURCE]]
if schedule[NETRO_SCHEDULE_SOURCE]
in (NETRO_SCHEDULE_FIX, NETRO_SCHEDULE_SMART, NETRO_SCHEDULE_MANUAL)
else "unknown source",
{
NETRO_SCHEDULE_EXECUTED: "has been executed",
NETRO_SCHEDULE_EXECUTING: "currently being executed",
NETRO_SCHEDULE_VALID: "is planned",
}[schedule[NETRO_SCHEDULE_STATUS]]
if schedule[NETRO_SCHEDULE_STATUS]
in (
NETRO_SCHEDULE_EXECUTED,
NETRO_SCHEDULE_EXECUTING,
NETRO_SCHEDULE_VALID,
)
else "unknown status",
),
}
for schedule in self._schedules
Expand Down Expand Up @@ -660,7 +682,7 @@ def current_calendar_schedule(self) -> dict | None:
schedule[NETRO_SCHEDULE_END_TIME] + TZ_OFFSET
),
"summary": f"{self._active_zones[schedule[NETRO_SCHEDULE_ZONE]].name}",
"description": "Duration: {} - Source: {}".format(
"description": "Duration: {} minutes, {}, {}.".format(
round(
(
datetime.datetime.fromisoformat(
Expand All @@ -672,7 +694,30 @@ def current_calendar_schedule(self) -> dict | None:
).seconds
/ 60
),
schedule[NETRO_SCHEDULE_SOURCE],
{
NETRO_SCHEDULE_FIX: "schedule from programs",
NETRO_SCHEDULE_SMART: "Netro generated schedule",
NETRO_SCHEDULE_MANUAL: "manual watering",
}[schedule[NETRO_SCHEDULE_SOURCE]]
if schedule[NETRO_SCHEDULE_SOURCE]
in (
NETRO_SCHEDULE_FIX,
NETRO_SCHEDULE_SMART,
NETRO_SCHEDULE_MANUAL,
)
else "unknown source",
{
NETRO_SCHEDULE_EXECUTED: "has been executed",
NETRO_SCHEDULE_EXECUTING: "currently being executed",
NETRO_SCHEDULE_VALID: "is planned",
}[schedule[NETRO_SCHEDULE_STATUS]]
if schedule[NETRO_SCHEDULE_STATUS]
in (
NETRO_SCHEDULE_EXECUTED,
NETRO_SCHEDULE_EXECUTING,
NETRO_SCHEDULE_VALID,
)
else "unknown status",
),
}

Expand Down

0 comments on commit edbe3b5

Please sign in to comment.