openhems.modules.energy_strategy.offpeak_strategy.OffPeakStrategy
- class openhems.modules.energy_strategy.offpeak_strategy.OffPeakStrategy(mylogger, network: Network, strategyId: str)
- This is in case we just base on “off-peak” range hours to control output.
Classic use-case is some grid contract (Like Tempo on EDF).
- The strategy is to switch on electric devices only on “off-peak” hours
with check to not exceed authorized max consumption
Methods
__init__(mylogger, network, strategyId)apply(cycleDuration, now)This function must be overload
check([now])Check and eval if necessary - EMHASS optimization - power margin - conformity to EMHASS plan
check4MissingOffeakTime(now)Switch on nodes wich must be switch on during peak-periods due to missing time during offpeak period to respect timeout
checkRange([nowDatetime])Check if nowDatetime (Default now) is in off-peak range (offpeakHoursRange)
eval()This function must be overload
getDeferrable(node, durationInSecs)return: a Deferable device witch can be encapsulated if usefull This function can be overload.
getMissingTime(schedule, now)Evaluate if a schedule can't be honor during offpeak periods only (regarding timeout) Return: Time in seconds to switch on during peak periods.
getNodes([encapsulated])Return nodes concerned by a defined strategy
getOnPeriods(now, schedule)Check a schedule wich must be switch on during peak-time due to missing time during offpeak period to respect timeout return: List of periods to switch on device during peaktime.
getPeakPeriods(now, schedule)Check a schedule wich must be switch on during peak-time due to missing time during offpeak period to respect timeout return: List of peak periods before scheduled timeout.
getSchedulableNodes()Return the list of nodes that should be scheduled by the user, using the HTTP UI
getVal(key)Function for eval in self.testCondition to get Home-Assistant entity value.
switchOffAll()Switch of all connected devices with this strategy.
switchOnMax()Switch on nodes, but
switchSchedulable(node, doSwitchOn)param node: Node to switch on param doSwitchOn: Set if we want to switch on or off return: True if node is on
updateDeferables()Update scheduled devices list. It evolved if a node as been manually added or scheduled duration have been manually changed or duration evolved due to switched on Return true if schedule has been updated.
updateNetwork(cycleDuration[, now])Decide what to do during the cycle:
updateTimes(schedule, myrange, times)While searching if there is missing time (check getMissingTime() to know more about it)