forked from romquenin/home-assistant-config-fr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch_tplink.yaml
executable file
·90 lines (80 loc) · 4.37 KB
/
switch_tplink.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
############################################################
## ##
## SWITCH TPLINK ##
## ##
############################################################
#Ajout du composant et des prises connectées
tplink:
discovery: false
switch:
- host: 192.168.2.36
- host: 192.168.2.37
- host: 192.168.2.38
- host: 192.168.2.39
#Templates pour integrer les valeurs des prises
sensor:
- platform: template
sensors:
tplink_1_current_power_w:
value_template: '{{ states.switch.tp_link_plug_1.attributes["current_power_w"] | float }}'
unit_of_measurement: 'W'
tplink_1_total_energy_kwh:
value_template: '{{ states.switch.tp_link_plug_1.attributes["total_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
tplink_1_today_energy_kwh:
value_template: '{{ states.switch.tp_link_plug_1.attributes["today_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
tplink_1_volts:
value_template: "{{ state_attr('switch.tp_link_plug_1','voltage') | float }}"
unit_of_measurement: 'V'
tplink_2_current_power_w:
value_template: '{{ states.switch.tp_link_plug_2.attributes["current_power_w"] | float }}'
unit_of_measurement: 'W'
tplink_2_total_energy_kwh:
value_template: '{{ states.switch.tp_link_plug_2.attributes["total_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
tplink_2_today_energy_kwh:
value_template: '{{ states.switch.tp_link_plug_2.attributes["today_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
tplink_2_volts:
value_template: "{{ state_attr('switch.tp_link_plug_2','voltage') | float }}"
unit_of_measurement: 'V'
tplink_3_current_power_w:
value_template: '{{ states.switch.tp_link_plug_3.attributes["current_power_w"] | float }}'
unit_of_measurement: 'W'
tplink_3_total_energy_kwh:
value_template: '{{ states.switch.tp_link_plug_3.attributes["total_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
tplink_3_today_energy_kwh:
value_template: '{{ states.switch.tp_link_plug_3.attributes["today_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
tplink_3_volts:
value_template: "{{ state_attr('switch.tp_link_plug_3','voltage') | float }}"
unit_of_measurement: 'V'
tplink_4_current_power_w:
value_template: '{{ states.switch.tp_link_plug_4.attributes["current_power_w"] | float }}'
unit_of_measurement: 'W'
tplink_4_total_energy_kwh:
value_template: '{{ states.switch.tp_link_plug_4.attributes["total_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
tplink_4_today_energy_kwh:
value_template: '{{ states.switch.tp_link_plug_4.attributes["today_energy_kwh"] | float }}'
unit_of_measurement: 'kWh'
tplink_4_volts:
value_template: "{{ state_attr('switch.tp_link_plug_4','voltage') | float }}"
unit_of_measurement: 'V'
#Templates pour cumuler les valeurs des prises
- platform: template
sensors:
current_power_usage:
value_template: '{%- if not is_state("sensor.tplink_1_current_power_w","unknown") -%} {{ ((states.sensor.tplink_1_current_power_w.state | float) + (states.sensor.tplink_2_current_power_w.state | float) + (states.sensor.tplink_3_current_power_w.state | float)) | round(2) }} {%- endif -%}'
friendly_name: 'Conso/Actuelle'
unit_of_measurement: 'W'
total_power_usage:
value_template: '{%- if not is_state("sensor.tplink_1_total_energy_kwh","unknown") -%} {{ ((states.sensor.tplink_1_total_energy_kwh.state | float) + (states.sensor.tplink_2_total_energy_kwh.state | float) + (states.sensor.tplink_3_total_energy_kwh.state | float)) | round(2) }} {%- endif -%}'
friendly_name: 'Conso/Totale'
unit_of_measurement: 'kWh'
today_power_usage:
value_template: '{%- if not is_state("sensor.tplink_1_today_energy_kwh","unknown") -%} {{ ((states.sensor.tplink_1_today_energy_kwh.state | float) + (states.sensor.tplink_2_today_energy_kwh.state | float) + (states.sensor.tplink_3_today_energy_kwh.state | float)) | round(2) }} {%- endif -%}'
friendly_name: 'Conso/Jour'
unit_of_measurement: 'kWh'