-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathengine_progressive.yaml
130 lines (124 loc) · 4.36 KB
/
engine_progressive.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# ----------------------------------------------------------------------------------------------------
# User interaction
# ----------------------------------------------------------------------------------------------------
<<: !include engine_common.yaml
switch:
# Define is router is active or not
# When switch is ON, pooling timer will trigger every seconds
- platform: template
name: "Activate Solar Routing"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
id: activate
on_turn_on:
then:
- light.turn_on: green_led
- lambda: id(power_meter_activated) = 1;
on_turn_off:
then:
- light.turn_off: green_led
- number.to_min: router_level
- lambda: |-
id(real_power).publish_state(NAN);
id(consumption).publish_state(NAN);
id(power_meter_activated) = 0;
number:
# Router level from 0 to 100
# This value serves two purposes:
# 1. When solar routing is disabled: Acts as a manual control to set the router level
# 2. When solar routing is enabled: Automatically updated to reflect the current router level
# Note: Manual adjustments via slider while routing is enabled are not recommended as they will be
# immediately overridden by the solar router's automatic control
- platform: template
name: "Router Level"
id: router_level
min_value: 0
max_value: 100
step: 1
unit_of_measurement: "%"
optimistic: True
mode: slider
on_value:
then:
- number.set:
id: regulator_opening
value: !lambda return id(router_level).state;
- if:
condition:
number.in_range:
id: router_level
above: 1
then:
- light.turn_on:
id: green_led
effect: blink
else:
- light.turn_off: green_led
- if:
condition:
- switch.is_on: activate
then:
- light.turn_on: green_led
- platform: template
name: "Regulator Opening"
id: regulator_opening
min_value: 0
max_value: 100
step: 1
unit_of_measurement: "%"
optimistic: True
mode: slider
internal: ${hide_regulators}
on_value:
then:
- script.execute: regulation_control
# Define the reactivity of router level
- platform: template
name: "Reactivity"
id: reactivity
optimistic: True
restore_value: True
mode: box
min_value: 1
max_value: 100
initial_value: 10
unit_of_measurement: ""
step: 1
# Define the target level of grid exchange
# 0 : no exchange
# <0 : continue the send energy to the grid
# >0 : pull energy from the grid to better confort
- platform: template
name: "Target grid exchange"
id: target_grid_exchange
optimistic: True
restore_value: True
mode: box
min_value: -99999
max_value: 99999
initial_value: 0
unit_of_measurement: "W"
step: 1
# ----------------------------------------------------------------------------------------------------
# Define scripts for power collection or energy regulation
# ----------------------------------------------------------------------------------------------------
script:
# Manage energy regulation
# Calculate the delta of percentage to apply to the router level status to go closer to the
# objective. Closer we are to the objective smaller are the steps. Reactivity parameter is
# doing a ponderation on this parameter to avoid resonance effects.
- id: energy_regulation
mode: single
then:
# Define the reouter level based on power measured and grid exchange target
# The value of regulator is a precentage and is then limited to the range 0 100
- lambda: |-
if (isnan(id(real_power).state) or id(safety_limit)){
// If we can have information about grid exchange or if safety_limit is active, do not divert any energy
id(router_level).publish_state(0);
return;
}
double delta = -1*(id(real_power).state-id(target_grid_exchange).state)*id(reactivity).state/1000;
double new_router_level = id(router_level).state + delta;
new_router_level = std::max(0.0, std::min(100.0, new_router_level));
id(router_level).publish_state(new_router_level);