Skip to content

Commit

Permalink
Adding appreciation phase
Browse files Browse the repository at this point in the history
  • Loading branch information
valleedelisle committed Jan 8, 2022
1 parent 47c5f53 commit 27ad4d3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions custom_components/hilo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@

from .config_flow import STEP_OPTION_SCHEMA
from .const import (
CONF_APPRECIATION_PHASE,
CONF_CHALLENGE_LOCK,
CONF_GENERATE_ENERGY_METERS,
CONF_HIGH_PERIODS,
CONF_HQ_PLAN_NAME,
CONF_LOG_TRACES,
CONF_TARIFF,
CONF_UNTARIFICATED_DEVICES,
DEFAULT_APPRECIATION_PHASE,
DEFAULT_CHALLENGE_LOCK,
DEFAULT_GENERATE_ENERGY_METERS,
DEFAULT_HQ_PLAN_NAME,
Expand Down Expand Up @@ -204,6 +206,9 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry, api: API) -> None:
1: self.subscribe_to_attributes,
}
self.hq_plan_name = entry.options.get(CONF_HQ_PLAN_NAME, DEFAULT_HQ_PLAN_NAME)
self.appreciation = entry.options.get(
CONF_APPRECIATION_PHASE, DEFAULT_APPRECIATION_PHASE
)
self.challenge_lock = entry.options.get(
CONF_CHALLENGE_LOCK, DEFAULT_CHALLENGE_LOCK
)
Expand Down
14 changes: 14 additions & 0 deletions custom_components/hilo/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
import voluptuous as vol

from .const import (
CONF_APPRECIATION_PHASE,
CONF_CHALLENGE_LOCK,
CONF_GENERATE_ENERGY_METERS,
CONF_HQ_PLAN_NAME,
CONF_LOG_TRACES,
CONF_UNTARIFICATED_DEVICES,
DEFAULT_APPRECIATION_PHASE,
DEFAULT_CHALLENGE_LOCK,
DEFAULT_GENERATE_ENERGY_METERS,
DEFAULT_HQ_PLAN_NAME,
Expand Down Expand Up @@ -59,6 +61,10 @@
CONF_CHALLENGE_LOCK,
default=DEFAULT_CHALLENGE_LOCK,
): cv.boolean,
vol.Optional(
CONF_APPRECIATION_PHASE,
default=DEFAULT_APPRECIATION_PHASE,
): cv.positive_int,
vol.Optional(CONF_HQ_PLAN_NAME, default=DEFAULT_HQ_PLAN_NAME): cv.string,
vol.Optional(CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL): (
vol.All(cv.positive_int, vol.Range(min=MIN_SCAN_INTERVAL))
Expand Down Expand Up @@ -191,6 +197,14 @@ async def async_step_init(
)
},
): cv.string,
vol.Optional(
CONF_APPRECIATION_PHASE,
description={
"suggested_value": self.config_entry.options.get(
CONF_APPRECIATION_PHASE
)
},
): cv.positive_int,
vol.Optional(
CONF_SCAN_INTERVAL,
description={
Expand Down
3 changes: 3 additions & 0 deletions custom_components/hilo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
CONF_ENERGY_METER_PERIOD = "energy_meter_period"
DEFAULT_ENERGY_METER_PERIOD = DAILY

CONF_APPRECIATION_PHASE = "appreciation_phase"
DEFAULT_APPRECIATION_PHASE = 0

DEFAULT_SCAN_INTERVAL = 60
MIN_SCAN_INTERVAL = 15

Expand Down
6 changes: 4 additions & 2 deletions custom_components/hilo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,10 @@ async def _async_update(self):
details = await self._hilo._api.get_events(
self._hilo.devices.location_id, event_id=raw_event["id"]
)
event = Event(**details).as_dict()
self._next_events.append(event)
event = Event(**details)
if self._hilo.appreciation > 0:
event.appreciation(self._hilo.appreciation)
self._next_events.append(event.as_dict())
self._state = "off"
if len(self._next_events):
self._state = self._next_events[0]["state"]
Expand Down
3 changes: 2 additions & 1 deletion custom_components/hilo/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"hq_plan_name": "Hydro Quebec rate plan name ('rate d' or 'flex d')",
"scan_interval": "Scan interval (min: 15s)",
"log_traces": "Also log request data and websocket messages (requires debug log level on both the integration and pyhilo)",
"challenge_lock": "Lock climate entities during Hilo challenges, preventing any changes when a challenge is in progress."
"challenge_lock": "Lock climate entities during Hilo challenges, preventing any changes when a challenge is in progress.",
"appreciation_phase": "Add an appreciation phase of X hours before the preheat phase."
}
}
}
Expand Down

4 comments on commit 27ad4d3

@skimaniac
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ça sert à quoi au juste "appreciation_phase"?

@aomann
Copy link

@aomann aomann commented on 27ad4d3 Jan 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci @valleedelisle ! C'est une bonne idée !

C'est une phase créée par l'intégration avant la phase preheat. Tu choisis dans la config de l'intégration le nombre d'heures avant la phase préheat. C'est particulièrement utile si tu souhaites faire des ajustements avant la phase de preheat.

Par exemple, je l'ai configuré pour durer une période de deux heures:

image

@skimaniac
Copy link

@skimaniac skimaniac commented on 27ad4d3 Jan 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est une phase créée par l'intégration avant la phase preheat. Tu choisis dans la config de l'intégration le nombre d'heures avant la phase préheat. C'est particulièrement utile si tu souhaites faire des ajustements avant la phase de preheat.

Ok cool! merci pour l'explication.
J'ai testé le "challenge_lock" ça fonctionne le changement de température ne se faisait pas, mais il affichait quand même les nouvelles valeurs mais ils restaient en rouge.

@valleedelisle
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normalement la température devrait se refresh à la courante quand on reçoit un reading d'Hilo. Je ne suis pas sur de savoir comment prévenir le changement de l'entité, ou bien le rétablir.

Please sign in to comment.