openhems.modules.energy_strategy.solarnosell_strategy.SolarNoSellStrategy

class openhems.modules.energy_strategy.solarnosell_strategy.SolarNoSellStrategy(mylogger, network: Network, configurationGlobal: ConfigurationManager, configurationStrategy: dict, *, strategyId: str = 'nosell')

Could be named too NoBuy * Start the device when production > consommation + X * consommationDevice (during Y cycles?) * Stop a device if production < consommation - (1-X) * consommationDevice (during Y cycles?) If X==0 we could never sell electricity (If there is enough device consumption and the cycle duration is enough quick). If X==1 we could never buy electricity (If produce enough and the cycle duration is enough quick). But with a margin every thing get harder because we want “+ margin” for no-sell and “- margin” for no-buy. We found a solution using “- ratio*margin” and ratio between on interval [-1 ; 1] Problem is that precedent solutions do not whork with X = -1, So X = - (((ratio-1)²-4)/4) then even if ratio is in [-1 ; 1] X stay in [0 ; 1] * Ratio = -1, production<consumption : no sell * Ratio = 1, consumption<production : no buy The good news is that for 0 it’s something between, and even for 2 or -2.

__init__(mylogger, network: Network, configurationGlobal: ConfigurationManager, configurationStrategy: dict, *, strategyId: str = 'nosell')

Methods

__init__(mylogger, network, ...[, strategyId])

apply(cycleDuration, now)

Called on each loop to switch on/off devices. Switch on devices if production > consommation + X * consommationDevice Switch off devices if production < consommation - (1-X) * consommationDevice Chances are we avoid ping-pong effect because when start device, we use max power,* but usually the real power is lower, and it's this we use to switch off.

check([now])

Nothing todo

eval()

This function must be overload

getAutonomousRatio()

Get a ratio of autonomy from last 24h.

getDeferrable(node, durationInSecs)

return: a Deferable device witch can be encapsulated if usefull This function can be overload.

getNodes([encapsulated])

Return nodes concerned by a defined strategy

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.

isDayTime([now])

Return True if it's daytime, else return false if it's nighttime usefull for solar production management

isOffPeakTime()

@return: True if we are in off-peak time. If there is none off-peak's return true (Like we are always on off-peak time, so we can use electricity all the time as we want nethermind.).

itsStressyDay()

Return true if we should lack energy today

switchOffAll()

Switch of all connected devices with this strategy.

switchOffDevices(powerMargin)

Switch off devices if production < consommation - (1-X) * consommationDevice Can switch off many devices if there is enought power powerMargin

switchOnCriticDevices([switchOffOthers])

Switch on devices witch must start now to finish on time.

switchOnDevices(powerMargin)

Switch on devices if production > consommation + X * consommationDevice Can switch on many devices if there is enought power powerMargin

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])

Generic function to updateNetwork base on algorythm In that case, sub-strategy must implement : - eval() - apply(cycleDuration, now)