-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhuawei_solar_pees.yaml
1962 lines (1962 loc) · 70.3 KB
/
huawei_solar_pees.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -----------------------------------------------------
# HUAWEI SOLAR PEES - Power, Energy and Economy Sensors
# -----------------------------------------------------
# version: v2.2.6
# branch: main
# domain: https://github.com/JensenNick/huawei_solar_pees
# codeowner: Nick Jensen
#
# This is a complete package file with the sensors included in the "Huawei Solar
# PEES package". For "installation" follow the steps below.
#
# Create a root folder named "packages".
# Import this file to the "packages-folder".
# Ad the following lines to your configuration.yaml file (remove the hashtag "#"
# and the 1 indentation).
#
# homeassistant:
# packages: !include_dir_named packages
#
# Make sure the naming of your power input sensors is correct.
# - 'sensor.inverter_input_power' (from the Huawei Solar integration)
# - 'sensor.inverter_input_power_2' (from the Huawei Solar integration)
# - 'sensor.power_meter_active_power' (from the Huawei Solar integration)
# - 'sensor.batteries_charge_discharge_power' (from the Huawei Solar integration)
#
# The "Huawei Solar PEES package" will use the electricity price sensors from the
# "Energi Data Service integration" by MTrab as default.
#
# If you wish to provide your own electricity price sensors and/or your own currency
# and/or if you wish to use the provided efficiency corrected power input sensor,
# I recomend you "install" the "Huawei Solar PEES Input" file and the Lovelace Input
# card. This will make it possible for you to save your specific solar PV settings
# from between updates of the package.
#
# The currency used is DKK by default. If you use another currency you need to change
# this in this file. I advice you not make any other changes.
#
# Restart Home Assistant and refresh your browser.
#
# -------
# SENSORS
# -------
sensor:
## ----------------------------------
## Huawei Solar PEES - Energy Sensors
- platform: integration
source: sensor.power_battery_charge
name: "Energy Battery Charge (ps)"
unique_id: energy_battery_charge_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_battery_charge_grid
name: "Energy Battery Charge Grid (ps)"
unique_id: energy_battery_charge_grid_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_battery_charge_yield
name: "Energy Battery Charge Yield (ps)"
unique_id: energy_battery_charge_yield_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_battery_discharge
name: "Energy Battery Discharge (ps)"
unique_id: energy_battery_discharge_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_battery_discharge_grid
name: "Energy Battery Discharge Grid (ps)"
unique_id: energy_battery_discharge_grid_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_battery_discharge_house
name: "Energy Battery Discharge House (ps)"
unique_id: energy_battery_discharge_house_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_import
name: "Energy Import (ps)"
unique_id: energy_import_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_export
name: "Energy Export (ps)"
unique_id: energy_export_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_house_load
name: "Energy House Load (ps)"
unique_id: energy_house_load_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_house_load_grid
name: "Energy House Load Grid (ps)"
unique_id: energy_house_load_grid_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_house_load_yield
name: "Energy House Load Yield (ps)"
unique_id: energy_house_load_yield_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_inverter_1_input
name: "Energy Yield #1 (ps)"
unique_id: energy_yield_1_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_inverter_2_input
name: "Energy Yield #2 (ps)"
unique_id: energy_yield_2_ps
round: 6
unit_prefix: k
unit_time: h
method: left
- platform: integration
source: sensor.power_export_yield
name: "Energy Export Yield (ps)"
unique_id: energy_export_yield_ps
round: 6
unit_prefix: k
unit_time: h
method: left
# ----------------
# TEMPLATE SENSORS
# ----------------
template:
- sensor:
## ------------------
## Electricity Prices
- name: "Electricity Price Import (ts)"
unique_id: electricity_price_import_ts
unit_of_measurement: DKK
state_class: measurement
state: >
{% if is_state('input_text.electricity_price_import','') or
is_state('input_text.electricity_price_import','unavailable') or
is_state('input_text.electricity_price_import','unknown') %}
{{ states('sensor.energi_data_service') | float(0) }}
{% else %}
{{ states ( states('input_text.electricity_price_import')) | float(0) }}
{% endif %}
- name: "Electricity Price Export (ts)"
unique_id: electricity_price_export_ts
unit_of_measurement: DKK
state_class: measurement
state: >
{% if is_state('input_text.electricity_price_export','') or
is_state('input_text.electricity_price_export','unavailable') or
is_state('input_text.electricity_price_export','unknown') %}
{{ states('sensor.energi_data_service_sale') | float(0) }}
{% else %}
{{ states ( states('input_text.electricity_price_export')) | float(0) }}
{% endif %}
## ---------------------------------
## Huawei Solar PEES - Power Sensors
- name: "Power Inverter #1 Input"
unique_id: power_inverter_1_input
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% if is_state('input_boolean.efficiency_corrected_power_input','on') and
states('sensor.inverter_1_model') | regex_search('-L1|-LC0|-1PH') %}
{% set inverter_rating = states('sensor.inverter_1_rated_power') | float %}
{% set overall_factor = states('input_number.inverter_1_overall_factor') | float / 100 %}
{% set operating_voltage = states('input_number.inverter_1_operating_voltage_l1') | float(0) %}
{% set input_power = states('sensor.inverter_input_power') | float(0) %}
{% set load_factor = ( input_power / inverter_rating * 100 ) | float(0) %}
{% set efficiency = ( 98.25 / (1 + 0.11 * e**(-0.18 * load_factor))) | float(0) %}
{% if operating_voltage < 360 %}
{% set voltage_factor = (
( -0.01 * operating_voltage + 3.6 ) *
( -1.04 / ( 1 - 0.68 * e**( -0.07 * load_factor)))
) | float(0) %}
{% elif operating_voltage > 360 %}
{% set voltage_factor = (
( 0.0083 * operating_voltage + 3 ) *
( -0.5 / ( 1 - 0.89 * e**( -0.04 * load_factor)))
) | float(0) %}
{% else %}
{% set voltage_factor = 0 %}
{% endif %}
{{ (( overall_factor * input_power * (efficiency + voltage_factor) / 100 ) | float(0) ) | round(0) }}
{% elif is_state('input_boolean.efficiency_corrected_power_input','on') and
states('sensor.inverter_1_model') | regex_search('-M1|-MAP0|-MB0|-3PH') %}
{% set inverter_rating = states('sensor.inverter_1_rated_power') | float %}
{% set overall_factor = states('input_number.inverter_1_overall_factor') | float / 100 %}
{% set operating_voltage = states('input_number.inverter_1_operating_voltage_m1') | float(0) %}
{% set input_power = states('sensor.inverter_input_power') | float(0) %}
{% set load_factor = ( input_power / inverter_rating * 100 ) | float(0) %}
{% set efficiency = (98.5 / (1 + 0.082 * e**(-0.145 * load_factor))) | float(0) %}
{% if operating_voltage < 600 %}
{% set voltage_factor = (
( -0.0077 * operating_voltage + 4.6154 ) *
( -0.705 / ( 1 - 0.56 * e**( -0.05 * load_factor)))
) | float(0) %}
{% elif operating_voltage > 600 %}
{% set voltage_factor = (
( 0.004 * operating_voltage - 2.4 ) *
( -0.587 / ( 1 - 0.845 * e**( -0.05 * load_factor)))
) | float(0) %}
{% else %}
{% set voltage_factor = 0 %}
{% endif %}
{{ (( overall_factor * input_power * (efficiency + voltage_factor) / 100) | float(0) ) | round(0) }}
{% else %}
{{ states('sensor.inverter_input_power') | float(0) }}
{% endif %}
- name: "Power Inverter #2 Input"
unique_id: power_inverter_2_input
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% if is_state('input_boolean.efficiency_corrected_power_input','on') and
states('sensor.inverter_2_model') | regex_search('-L1|-LC0|-1PH') %}
{% set inverter_rating = states('sensor.inverter_2_rated_power') | float %}
{% set overall_factor = states('input_number.inverter_2_overall_factor') | float / 100 %}
{% set operating_voltage = states('input_number.inverter_2_operating_voltage_l1') | float(0) %}
{% set input_power = states('sensor.inverter_input_power_2') | float(0) %}
{% set load_factor = ( input_power / inverter_rating * 100 ) | float(0) %}
{% set efficiency = ( 98.25 / (1 + 0.11 * e**(-0.18 * load_factor))) | float(0) %}
{% if operating_voltage < 360 %}
{% set voltage_factor = (
( -0.01 * operating_voltage + 3.6 ) *
( -1.04 / ( 1 - 0.68 * e**( -0.07 * load_factor)))
) | float(0) %}
{% elif operating_voltage > 360 %}
{% set voltage_factor = (
( 0.0083 * operating_voltage + 3 ) *
( -0.5 / ( 1 - 0.89 * e**( -0.04 * load_factor)))
) | float(0) %}
{% else %}
{% set voltage_factor = 0 %}
{% endif %}
{{ (( overall_factor * input_power * (efficiency + voltage_factor) / 100 ) | float(0) ) | round(0) }}
{% elif is_state('input_boolean.efficiency_corrected_power_input','on') and
states('sensor.inverter_2_model') | regex_search('-M1|-MAP0|-MB0|-3PH') %}
{% set inverter_rating = states('sensor.inverter_2_rated_power') | float %}
{% set overall_factor = states('input_number.inverter_2_overall_factor') | float / 100 %}
{% set operating_voltage = states('input_number.inverter_2_operating_voltage_m1') | float(0) %}
{% set input_power = states('sensor.inverter_input_power_2') | float(0) %}
{% set load_factor = ( input_power / inverter_rating * 100 ) | float(0) %}
{% set efficiency = (98.5 / (1 + 0.082 * e**(-0.145 * load_factor))) | float(0) %}
{% if operating_voltage < 600 %}
{% set voltage_factor = (
( -0.0077 * operating_voltage + 4.6154 ) *
( -0.705 / ( 1 - 0.56 * e**( -0.05 * load_factor)))
) | float(0) %}
{% elif operating_voltage > 600 %}
{% set voltage_factor = (
( 0.004 * operating_voltage - 2.4 ) *
( -0.587 / ( 1 - 0.845 * e**( -0.05 * load_factor)))
) | float(0) %}
{% else %}
{% set voltage_factor = 0 %}
{% endif %}
{{ (( overall_factor * input_power * (efficiency + voltage_factor) / 100) | float(0) ) | round(0) }}
{% else %}
{{ states('sensor.inverter_input_power_2') | float(0) }}
{% endif %}
- name: "Power Inverter Input Total"
unique_id: power_inverter_input_total
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ states('sensor.power_inverter_1_input') | float(0) +
states('sensor.power_inverter_2_input') | float(0) }}
- name: "Power Export"
unique_id: power_export
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.power_meter_active_power') | float(0)
, 0 ) | max }}
- name: "Power Import"
unique_id: power_import
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.power_meter_active_power') | float(0)
, 0 ) | min | abs }}
- name: "Power Battery Charge"
unique_id: power_battery_charge
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.batteries_charge_discharge_power') | float(0)
, 0 ) | max }}
- name: "Power Battery Discharge"
unique_id: power_battery_discharge
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.batteries_charge_discharge_power') | float(0)
, 0 ) | min | abs }}
- name: "Power House Load"
unique_id: power_house_load
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.power_inverter_1_input') | float(0) +
states('sensor.power_inverter_2_input') | float(0) -
states('sensor.power_meter_active_power') | float(0) -
states('sensor.batteries_charge_discharge_power') | float(0)
, 0 ) | max }}
- name: "Power House Load Yield"
unique_id: power_house_load_yield
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% if states('sensor.power_house_load') | float(0) >
( states('sensor.power_inverter_1_input') | float(0) +
states('sensor.power_inverter_2_input') | float(0) ) %}
{{ states('sensor.power_inverter_1_input') | float(0) +
states('sensor.power_inverter_2_input') | float(0) }}
{% else %}
{{ states('sensor.power_house_load') | float(0) }}
{% endif %}
- name: "Power Battery Charge Yield"
unique_id: power_battery_charge_yield
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.power_inverter_1_input') | float(0) +
states('sensor.power_inverter_2_input') | float(0) -
states('sensor.power_house_load_yield') | float(0) -
states('sensor.power_export') | float(0)
, 0 ) | max }}
- name: "Power Battery Charge Grid"
unique_id: power_battery_charge_grid
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.power_battery_charge') | float(0) -
states('sensor.power_battery_charge_yield') | float(0)
, 0 ) | max }}
- name: "Power Export Yield"
unique_id: power_export_yield
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.power_inverter_1_input') | float(0) +
states('sensor.power_inverter_2_input') | float(0) -
states('sensor.power_house_load_yield') | float(0) -
states('sensor.power_battery_charge_yield') | float(0)
, 0 ) | max }}
- name: "Power Battery Discharge Grid"
unique_id: power_battery_discharge_grid
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.power_export') | float(0) -
states('sensor.power_export_yield') | float(0)
, 0 ) | max }}
- name: "Power Battery Discharge House"
unique_id: power_battery_discharge_house
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.power_battery_discharge') | float(0) -
states('sensor.power_battery_discharge_grid') | float(0)
, 0 ) | max }}
- name: "Power House Load Grid"
unique_id: power_house_load_grid
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{{ (
states('sensor.power_house_load') | float(0) -
states('sensor.power_house_load_yield') | float(0) -
states('sensor.power_battery_discharge_house') | float(0)
, 0 ) | max }}
## ----------------------------------
## Huawei Solar PEES - Energy Sensors
- name: "Energy Yield #1 (ts)"
unique_id: energy_yield_1_ts
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
state: >
{{ states('sensor.energy_yield_1') | float }}
availability: >
{{ has_value('sensor.energy_yield_1') }}
- name: "Energy Yield #2 (ts)"
unique_id: energy_yield_2_ts
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
state: >
{% if has_value('sensor.energy_yield_2') %}
{{ states('sensor.energy_yield_2') | float }}
{% else %}
{{ 0 }}
{% endif %}
- name: "Energy Yield Total (ts)"
unique_id: energy_yield_total_ts
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
state: >
{{ states('sensor.energy_yield_1') | float +
states('sensor.energy_yield_2') | float }}
availability: >
{{ has_value('sensor.energy_yield_1') and
has_value('sensor.energy_yield_2') }}
## ------------------------------
## Huawei Solar PEES - Economy
- name: "Economy - Result wo PV (ts)"
unique_id: economy_result_wo_pv_ts
unit_of_measurement: DKK
state_class: total_increasing
state: >
{{ states('sensor.house_load_cost') | float(0) | round(5) }}
availability: >
{{ has_value('sensor.house_load_cost') }}
- name: "Economy - Expenses w PV (ts)"
unique_id: economy_expenses_w_pv_ts
unit_of_measurement: DKK
state_class: total_increasing
state: >
{{ states('sensor.import_cost') | float(0) | round(5) }}
availability: >
{{ has_value('sensor.import_cost') }}
- name: "Economy - Income w PV (ts)"
unique_id: economy_income_w_pv_ts
unit_of_measurement: DKK
state_class: total_increasing
state: >
{{ states('sensor.export_income') | float(0) | round(5) }}
availability: >
{{ has_value('sensor.export_income') }}
- name: "Economy - Result w PV (ts)"
unique_id: economy_result_w_pv_ts
unit_of_measurement: DKK
state_class: total
state: >
{{ (
states('sensor.import_cost') | float -
states('sensor.export_income') | float
) | round(5) }}
availability: >
{{ has_value('sensor.import_cost') or
has_value('sensor.export_income') }}
- name: "Economy - NRI PV (ts)"
unique_id: economy_nri_pv_ts
unit_of_measurement: DKK
state_class: total
state: >
{{ (
states('sensor.house_load_cost') | float -
states('sensor.import_cost') | float +
states('sensor.export_income') | float
) | round(5) }}
availability: >
{{ has_value('sensor.house_load_cost') or
has_value('sensor.import_cost') or
has_value('sensor.export_income') }}
- name: "Economy - NRI Battery (ts)"
unique_id: economy_nri_battery_ts
unit_of_measurement: DKK
state_class: total
state: >
{{ (
states('sensor.battery_discharge_grid_sale') | float +
states('sensor.battery_discharge_house_saving') | float -
states('sensor.battery_charge_yield_sale') | float -
states('sensor.battery_charge_grid_cost') | float
) | round(5) }}
availability: >
{{ has_value('sensor.battery_discharge_grid_sale') or
has_value('sensor.battery_discharge_house_saving') or
has_value('sensor.battery_charge_yield_sale') or
has_value('sensor.battery_charge_grid_cost') }}
# ------------------------
# TEMPLATE TRIGGER SENSORS
# ------------------------
## -----------------------------------
## Huawei Solar PEES - Economy Sensors
- trigger:
- trigger: state
entity_id: sensor.energy_battery_charge_grid_ps
sensor:
- name: "Battery Charge Grid - Cost (tt)"
unique_id: battery_charge_grid_cost_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_import_ts') | float(0) %}
{% set meter = states('sensor.energy_battery_charge_grid_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_battery_charge_grid_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
- trigger:
- trigger: state
entity_id: sensor.energy_battery_charge_yield_ps
sensor:
- name: "Battery Charge Yield - Sale (tt)"
unique_id: battery_charge_yield_sale_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_export_ts') | float(0) %}
{% set meter = states('sensor.energy_battery_charge_yield_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_battery_charge_yield_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
- trigger:
- trigger: state
entity_id: sensor.energy_battery_discharge_house_ps
sensor:
- name: "Battery Discharge House - Saving (tt)"
unique_id: battery_discharge_house_saving_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_import_ts') | float(0) %}
{% set meter = states('sensor.energy_battery_discharge_house_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_battery_discharge_house_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
- trigger:
- trigger: state
entity_id: sensor.energy_battery_discharge_grid_ps
sensor:
- name: "Battery Discharge Grid - Sale (tt)"
unique_id: battery_discharge_grid_sale_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_export_ts') | float(0) %}
{% set meter = states('sensor.energy_battery_discharge_grid_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_battery_discharge_grid_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
- trigger:
- trigger: state
entity_id: sensor.energy_export_ps
sensor:
- name: "Export - Income (tt)"
unique_id: export_income_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_export_ts') | float(0) %}
{% set meter = states('sensor.energy_export_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_export_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
- trigger:
- trigger: state
entity_id: sensor.energy_import_ps
sensor:
- name: "Import - Cost (tt)"
unique_id: import_cost_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_import_ts') | float(0) %}
{% set meter = states('sensor.energy_import_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_import_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
- trigger:
- trigger: state
entity_id: sensor.energy_house_load_ps
sensor:
- name: "House Load - Cost (tt)"
unique_id: house_load_cost_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_import_ts') | float(0) %}
{% set meter = states('sensor.energy_house_load_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_house_load_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
- trigger:
- trigger: state
entity_id: sensor.energy_house_load_grid_ps
sensor:
- name: "House Load Grid - Cost (tt)"
unique_id: house_load_grid_cost_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_import_ts') | float(0) %}
{% set meter = states('sensor.energy_house_load_grid_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_house_load_grid_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
- trigger:
- trigger: state
entity_id: sensor.energy_house_load_yield_ps
sensor:
- name: "House Load Yield - Saving (tt)"
unique_id: house_load_yield_saving_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_import_ts') | float(0) %}
{% set meter = states('sensor.energy_house_load_yield_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_house_load_yield_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
- trigger:
- trigger: state
entity_id: sensor.energy_export_yield_ps
sensor:
- name: "Export Yield - Sale (tt)"
unique_id: export_yield_sale_tt
unit_of_measurement: DKK
device_class: monetary
state: >
{% set price = states('sensor.electricity_price_export_ts') | float(0) %}
{% set meter = states('sensor.energy_export_yield_ps') | float(0) %}
{% if meter > 0 and this.attributes.last is defined %}
{% set delta = meter - this.attributes.last | float(0) %}
{% else %}
{% set delta = 0 %}
{% endif %}
{{ price * delta }}
attributes:
last: >
{% if this.attributes.last is defined %}
{% set lastlast = this.attributes.last | float(0) %}
{% else %}
{% set lastlast = 0 %}
{% endif %}
{% set meter = states('sensor.energy_export_yield_ps') | float(0) %}
{% if meter > 0 %}
{{ meter }}
{% else %}
{{ lastlast }}
{% endif %}
# --------------
# UTILITY METERS
# --------------
utility_meter:
## -----------------------------------------
## Huawei Solar PEES - Energy Utility Meters
energy_battery_charge:
source: sensor.energy_battery_charge_ps
name: "Energy Battery Charge"
unique_id: energy_battery_charge
periodically_resetting: false
energy_battery_charge_grid:
source: sensor.energy_battery_charge_grid_ps
name: "Energy Battery Charge Grid"
unique_id: energy_battery_charge_grid
periodically_resetting: false
energy_battery_charge_yield:
source: sensor.energy_battery_charge_yield_ps
name: "Energy Battery Charge Yield"
unique_id: energy_battery_charge_yield
periodically_resetting: false
energy_battery_discharge:
source: sensor.energy_battery_discharge_ps
name: "Energy Battery Discharge"
unique_id: energy_battery_discharge
periodically_resetting: false
energy_battery_discharge_grid:
source: sensor.energy_battery_discharge_grid_ps
name: "Energy Battery Discharge Grid"
unique_id: energy_battery_discharge_grid
periodically_resetting: false
energy_battery_discharge_house:
source: sensor.energy_battery_discharge_house_ps
name: "Energy Battery Discharge House"
unique_id: energy_battery_discharge_house
periodically_resetting: false
energy_import:
source: sensor.energy_import_ps
name: "Energy Import"
unique_id: energy_import
periodically_resetting: false
energy_export:
source: sensor.energy_export_ps
name: "Energy Export"
unique_id: energy_export
periodically_resetting: false
energy_export_yield:
source: sensor.energy_export_yield_ps
name: "Energy Export Yield"
unique_id: energy_export_yield
periodically_resetting: false
energy_house_load:
source: sensor.energy_house_load_ps
name: "Energy House Load"
unique_id: energy_house_load
periodically_resetting: false
energy_house_load_grid:
source: sensor.energy_house_load_grid_ps
name: "Energy House Load Grid"
unique_id: energy_house_load_grid
periodically_resetting: false
energy_house_load_yield:
source: sensor.energy_house_load_yield_ps
name: "Energy House Load Yield"
unique_id: energy_house_load_yield
periodically_resetting: false
energy_yield_1:
source: sensor.energy_yield_1_ps
name: "Energy Yield #1"
unique_id: energy_yield_1
periodically_resetting: false
energy_yield_2:
source: sensor.energy_yield_2_ps
name: "Energy Yield #2"
unique_id: energy_yield_2
periodically_resetting: false
energy_yield_total:
source: sensor.energy_yield_total_ts
name: "Energy Yield Total"
unique_id: energy_yield_total
periodically_resetting: false
## ------------------------------------------
## Huawei Solar PEES - Economy Utility Meters
battery_charge_grid_cost:
source: sensor.battery_charge_grid_cost_tt
name: "Battery Charge Grid - Cost"
unique_id: battery_charge_grid_cost
delta_values: true
battery_charge_yield_sale:
source: sensor.battery_charge_yield_sale_tt
name: "Battery Charge Yield - Sale"
unique_id: battery_charge_yield_sale
delta_values: true
battery_discharge_house_saving:
source: sensor.battery_discharge_house_saving_tt
name: "Battery Discharge House - Saving"
unique_id: battery_discharge_house_saving
delta_values: true
battery_discharge_grid_sale:
source: sensor.battery_discharge_grid_sale_tt
name: "Battery Discharge Grid - Sale"
unique_id: battery_discharge_grid_sale
delta_values: true
export_income:
source: sensor.export_income_tt
name: "Export - Income"
unique_id: export_income
delta_values: true
import_cost:
source: sensor.import_cost_tt
name: "Import - Cost"
unique_id: import_cost
delta_values: true
house_load_cost:
source: sensor.house_load_cost_tt
name: "House Load - Cost"
unique_id: house_load_cost
delta_values: true
house_load_grid_cost:
source: sensor.house_load_grid_cost_tt
name: "House Load Grid - Cost"
unique_id: house_load_grid_cost
delta_values: true
house_load_yield_saving:
source: sensor.house_load_yield_saving_tt
name: "House Load Yield - Saving"
unique_id: house_load_yield_saving
delta_values: true
export_yield_sale:
source: sensor.export_yield_sale_tt
name: "Export Yield - Sale"
unique_id: export_yield_sale
delta_values: true
## ---------------------------------------------
## Huawei Solar PEES - Economy Utility Meters
### Economy - Result without PV
economy_result_wo_pv:
source: sensor.economy_result_wo_pv_ts
name: "Economy - Result wo PV"
unique_id: economy_result_wo_pv
hourly_economy_result_wo_pv:
source: sensor.economy_result_wo_pv_ts
name: "Hourly Economy - Result wo PV"
unique_id: hourly_economy_result_wo_pv
cycle: hourly
daily_economy_result_wo_pv:
source: sensor.economy_result_wo_pv_ts
name: "Daily Economy - Result wo PV"
unique_id: daily_economy_result_wo_pv
cycle: daily
monthly_economy_result_wo_pv:
source: sensor.economy_result_wo_pv_ts
name: "Monthly Economy - Result wo PV"
unique_id: monthly_economy_result_wo_pv
cycle: monthly
quarterly_economy_result_wo_pv:
source: sensor.economy_result_wo_pv_ts
name: "Quarterly Economy - Result wo PV"
unique_id: quarterly_economy_result_wo_pv
cycle: quarterly
yearly_economy_result_wo_pv:
source: sensor.economy_result_wo_pv_ts
name: "Yearly Economy - Result wo PV"