-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathamber_usage_part2.yaml
164 lines (144 loc) · 4.9 KB
/
amber_usage_part2.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# After the sensors in amber_usage.yaml are confirmed to be working correctly,
# append the following content to amber_usage.yaml.
### Automations ###
automation:
# Writes final import cost and export profit at the end of each 30 minute period.
# Instructions:
# Update sensor.your_amber_general_price and sensor.your_amber_feed_in_price to the
# corresponding sensor names from your Amber Electric integration.
- id: 'amber_30_minute_import_cost_export_price'
alias: 'Amber: 30 Minute Import Cost & Export Price'
trigger:
- platform: time_pattern
minutes: '29'
seconds: '58'
- platform: time_pattern
minutes: '59'
seconds: '58'
condition: []
action:
- service: input_number.set_value
data:
value: "{{ states('sensor.your_amber_general_price')|float(0) }}"
target:
entity_id: input_number.amber_closing_import_price
- service: input_number.set_value
data:
value: "{{ states('sensor.your_amber_feed_in_price')|float(0) }}"
target:
entity_id: input_number.amber_closing_export_price
- service: input_number.set_value
data:
value: >
{% set energy = states('sensor.inverter_import_energy_30_minutes')|float(0) %}
{% set price = states('sensor.your_amber_general_price')|float(0) %}
{{ energy * price | float }}
target:
entity_id: input_number.amber_import_cost_30_minutes
- service: input_number.set_value
data:
value: >
{% set energy = states('sensor.inverter_export_energy_30_minutes')|float(0) %}
{% set price = states('sensor.your_amber_feed_in_price')|float(0) %}
{{ energy * price | float }}
target:
entity_id: input_number.amber_export_profit_30_minutes
mode: single
### Input Numbers ###
input_number:
# Import price at the end of the 30 minute period
amber_closing_import_price:
name: 'Amber: Closing Import Price'
unit_of_measurement: $
icon: mdi:cash
initial: 0
min: -10000
max: 10000
step: 0.01
mode: box
# Export price at the end of the 30 minute period
amber_closing_export_price:
name: 'Amber: Closing Export Price'
unit_of_measurement: $
icon: mdi:cash
initial: 0
min: -10000
max: 10000
step: 0.01
mode: box
# Import cost at the end of the 30 minute period
amber_import_cost_30_minutes:
name: 'Amber: Import Cost (30 Minutes)'
unit_of_measurement: $
icon: mdi:cash
initial: 0
min: -10000
max: 10000
step: 0.001
mode: box
# Export profit at the end of the 30 minute period
amber_export_profit_30_minutes:
name: 'Amber: Export Profit (30 Minutes)'
unit_of_measurement: $
icon: mdi:cash
initial: 0
min: -10000
max: 10000
step: 0.001
mode: box
### Riemann Sum Sensors ###
sensor:
# Cumulative energy import
- platform: integration
unique_id: inverter_import_energy_total
name: 'Inverter: Import Energy Total'
source: sensor.inverter_import_power
method: left
# Cumulative energy export
- platform: integration
unique_id: inverter_export_energy_total
name: 'Inverter: Export Energy Total'
source: sensor.inverter_export_power
method: left
### Utility Meters ###
utility_meter:
# Cumulative energy import for each half hour
inverter_import_energy_30_minutes:
unique_id: inverter_import_energy_30_minutes
name: 'Inverter: Import Energy (30 Minutes)'
source: sensor.inverter_import_energy_total
cron: "*/30 * * * *"
# Cumulative energy export for each half hour
inverter_export_energy_30_minutes:
unique_id: inverter_export_energy_30_minutes
name: 'Inverter: Export Energy (30 Minutes)'
source: sensor.inverter_export_energy_total
cron: "*/30 * * * *"
# Cumulative energy import for each day
inverter_import_energy_daily:
unique_id: inverter_import_energy_daily
name: 'Inverter: Import Energy (Daily)'
source: sensor.inverter_import_energy_total
cycle: daily
# Cumulative energy export for each day
inverter_export_energy_daily:
unique_id: inverter_export_energy_daily
name: 'Inverter: Export Energy (Daily)'
source: sensor.inverter_export_energy_total
cycle: daily
# Cumulative import cost for each day
amber_import_cost_daily:
unique_id: amber_import_cost_daily
name: 'Amber: Import Cost (Daily)'
source: input_number.amber_import_cost_30_minutes
delta_values: true
net_consumption: true
cycle: daily
# Cumulative export profit for each day
amber_export_profit_daily:
unique_id: amber_export_profit_daily
name: 'Amber: Export Profit (Daily)'
source: input_number.amber_export_profit_30_minutes
delta_values: true
net_consumption: true
cycle: daily