Skip to content

Commit

Permalink
Merge pull request #100 from jm-73/develop
Browse files Browse the repository at this point in the history
Ready to release 2.0.2x
  • Loading branch information
jm-73 authored Jul 6, 2020
2 parents 0774457 + 4c38981 commit bc08dd5
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ indego.update_location() | | |
indego.update_network() | ? | ? | ?
indego.update_next_mow() | | |
indego.update_operating_data() | | X |
indego.update_predictive_calendar()| X | |
indego.update_predictive_schedule()| X | |
indego.update_security() | X | |
indego.update_setup() | X | |
indego.update_state() | X | |
Expand Down Expand Up @@ -135,6 +137,20 @@ Update the indego.operating_data with data about battery, runtime, garden data a
OperatingData(hmiKeys=1768, battery=Battery(percent=357, voltage=35.7, cycles=0, discharge=0.0, ambient_temp=26, battery_temp=26, percent_adjusted=83), garden=Garden(id=8, name=1, signal_id=1, size=769, inner_bounds=3, cuts=15, runtime=166824, charge=37702, bumps=6646, stops=29, last_mow=1, map_cell_size=None), runtime=Runtime(total=RuntimeDetail(operate=1715, charge=387, cut=1328), session=RuntimeDetail(operate=9, charge=0, cut=0)))
```

### indego.predictive_calendar()
Updates the predictive_calendar with the timeslots (days and hours) where the user wants smart mowing not to mow the lawn.

```python
PredictiveCalendar(cal=1, days=[CalendarDay(day=0, day_name='monday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr=None), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr=None)]), CalendarDay(day=1, day_name='tuesday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr=None), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr=None)]), CalendarDay(day=2, day_name='wednesday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr=None), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr=None)]), CalendarDay(day=3, day_name='thursday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr=None), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr=None)]), CalendarDay(day=4, day_name='friday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr=None), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr=None)]), CalendarDay(day=5, day_name='saturday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr=None), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr=None)]), CalendarDay(day=6, day_name='sunday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=23, EnMin=59, Attr=None)])])
```

### indego.predictive_schedule()
Updates the predictive_schedule with the next planned mows (schedule_days) and the days where the smart mowing will not mow the lawn. The latter is combined by the time slots where the user does not want the Indego to mow (Attr='C') and the slots where the weather conditions prevent the mowing (e.g., Attr='pP').

```python
PredictiveSchedule(schedule_days=[CalendarDay(day=0, day_name='monday', slots=[CalendarSlot(En=True, StHr=10, StMin=0, EnHr=13, EnMin=0, Attr=None)]), CalendarDay(day=2, day_name='wednesday', slots=[CalendarSlot(En=True, StHr=10, StMin=0, EnHr=13, EnMin=0, Attr=None)]), CalendarDay(day=4, day_name='friday', slots=[CalendarSlot(En=True, StHr=10, StMin=0, EnHr=13, EnMin=0, Attr=None)])], exclusion_days=[CalendarDay(day=0, day_name='monday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr='C'), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr='C')]), CalendarDay(day=1, day_name='tuesday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr='C'), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr='C')]), CalendarDay(day=2, day_name='wednesday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr='C'), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr='C')]), CalendarDay(day=3, day_name='thursday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr='C'), CalendarSlot(En=True, StHr=8, StMin=0, EnHr=12, EnMin=0, Attr='pP'), CalendarSlot(En=True, StHr=13, StMin=0, EnHr=15, EnMin=0, Attr='Pp'), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr='C')]), CalendarDay(day=4, day_name='friday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr='C'), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr='C')]), CalendarDay(day=5, day_name='saturday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=8, EnMin=0, Attr='C'), CalendarSlot(En=True, StHr=20, StMin=0, EnHr=23, EnMin=59, Attr='C')]), CalendarDay(day=6, day_name='sunday', slots=[CalendarSlot(En=True, StHr=0, StMin=0, EnHr=23, EnMin=59, Attr='C')])])
```

### indego.update_security()
Updates the indego.security with information about the Indego security state.

Expand Down Expand Up @@ -364,6 +380,7 @@ get
/alms/<serial>/predictive/lastcutting
/alms/<serial>/predictive/location
/alms/<serial>/predictive/nextcutting
/alms/<serial>/predictive/schedule
/alms/<serial>/predictive/useradjustment
/alms/<serial>/predictive/weather
/alms/<serial>/security
Expand Down
2 changes: 1 addition & 1 deletion pyIndego/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class Methods(Enum):

DAY_MAPPING = {
0: "monday",
1: "teusday",
1: "tuesday",
2: "wednesday",
3: "thursday",
4: "friday",
Expand Down
8 changes: 8 additions & 0 deletions pyIndego/indego_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ async def update_operating_data(self):
await self.get(f"alms/{self._serial}/operatingData")
)

async def update_predictive_calendar(self):
"""Update predictive_calendar."""
self._update_predictive_calendar(await self.get(f"alms/{self._serial}/predictive/calendar"))

async def update_predictive_schedule(self):
"""Update predictive_schedule."""
self._update_predictive_schedule(await self.get(f"alms/{self._serial}/predictive/schedule"))

async def update_security(self):
"""Update security."""
self._update_security(await self.get(f"alms/{self._serial}/security"))
Expand Down
22 changes: 22 additions & 0 deletions pyIndego/indego_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
Setup,
Security,
OperatingData,
PredictiveCalendar,
PredictiveSchedule,
Runtime,
State,
Users,
Expand Down Expand Up @@ -79,6 +81,8 @@ def __init__(
self.network = Network()
self.next_mow = None
self.operating_data = OperatingData()
self.predictive_calendar = PredictiveCalendar()
self.predictive_schedule = PredictiveSchedule()
self.security = Security()
self.state = State()
self.setup = Setup()
Expand Down Expand Up @@ -226,6 +230,24 @@ def _update_operating_data(self, new):
else:
self._online = False

@abstractmethod
def update_predictive_calendar(self):
"""Update predictive_calendar."""

def _update_predictive_calendar(self, new):
"""Update predictive_calendar."""
if new:
self.predictive_calendar = replace(self.predictive_calendar, **new["cals"][0])

@abstractmethod
def update_predictive_schedule(self):
"""Update predictive schedule."""

def _update_predictive_schedule(self, new):
"""Update predictive schedule."""
if new:
self.predictive_schedule = replace(self.predictive_schedule, **new)

@abstractmethod
def update_security(self):
"""Update security."""
Expand Down
8 changes: 8 additions & 0 deletions pyIndego/indego_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ def update_operating_data(self):
"""Update operating data."""
self._update_operating_data(self.get(f"alms/{self._serial}/operatingData"))

def update_predictive_calendar(self):
"""Update predictive_calendar."""
self._update_predictive_calendar(self.get(f"alms/{self._serial}/predictive/calendar"))

def update_predictive_schedule(self):
"""Update predictive_schedule."""
self._update_predictive_schedule(self.get(f"alms/{self._serial}/predictive/schedule"))

def update_security(self):
"""Update security."""
self._update_security(self.get(f"alms/{self._serial}/security"))
Expand Down
26 changes: 25 additions & 1 deletion pyIndego/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from typing import List
from dataclasses import dataclass, field, is_dataclass
from datetime import datetime
from datetime import datetime, time

from .const import (
ALERT_ERROR_CODE,
Expand Down Expand Up @@ -90,8 +90,18 @@ class CalendarSlot:
En: bool = None
StHr: int = None
StMin: int = None
start: time = None
EnHr: int = None
EnMin: int = None
end: time = None
Attr: str = None

def __post_init__(self):
"""Convert start and end in time format."""
if (self.StHr is not None and self.StMin is not None):
self.start = time(self.StHr, self.StMin)
if (self.EnHr is not None and self.EnMin is not None):
self.end = time(self.EnHr, self.EnMin)


@nested_dataclass
Expand All @@ -115,6 +125,20 @@ class Calendar:
cal: int = None
days: List[CalendarDay] = field(default_factory=lambda: [CalendarDay])

@nested_dataclass
class PredictiveCalendar:
"""Class for PredictiveCalendar."""

cal: int = None
days: List[CalendarDay] = field(default_factory=lambda: [CalendarDay])

@nested_dataclass
class PredictiveSchedule:
"""Class for PredictiveSchedule."""

schedule_days: List[CalendarDay] = field(default_factory=lambda: [CalendarDay])
exclusion_days: List[CalendarDay] = field(default_factory=lambda: [CalendarDay])


@nested_dataclass
class GenericData:
Expand Down

0 comments on commit bc08dd5

Please sign in to comment.