Commit ef25764 Xavier Berger
committed
1 parent 1e8e007 commit ef25764 Copy full SHA for ef25764
File tree 4 files changed +15
-37
lines changed
4 files changed +15
-37
lines changed Original file line number Diff line number Diff line change @@ -10,4 +10,17 @@ globals:
10
10
- id : power_meter_activated
11
11
type : int
12
12
initial_value : ${power_meter_activated_at_start}
13
- restore_value : True
13
+ restore_value : True
14
+
15
+
16
+ # ----------------------------------------------------------------------------------------------------
17
+ # Sensor updated every second to give feedback in Home Assistant
18
+ # ----------------------------------------------------------------------------------------------------
19
+ sensor :
20
+ # Sensor showing the actual power consumption
21
+ - id : real_power
22
+ platform : template
23
+ name : " Real Power"
24
+ device_class : " power"
25
+ unit_of_measurement : " W"
26
+ update_interval : 1s
Original file line number Diff line number Diff line change 2
2
3
3
esphome :
4
4
min_version : 2024.11.1
5
- # ----------------------------------------------------------------------------------------------------
6
- # Sensor updated every second to give feedback in Home Assistant
7
- # ----------------------------------------------------------------------------------------------------
8
- sensor :
9
- # Sensor showing the actual power consumption
10
- - id : real_power
11
- platform : template
12
- name : " Real Power"
13
- device_class : " power"
14
- unit_of_measurement : " W"
15
- update_interval : 1s
16
5
17
6
# ----------------------------------------------------------------------------------------------------
18
7
# Use http request component
@@ -54,7 +43,7 @@ script:
54
43
id(real_power).publish_state(NAN);
55
44
} else {
56
45
bool parse_success = json::parse_json(body, [](JsonObject root) -> bool {
57
- if (!root.containsKey("Body") || !root["Body"]["Data"]["0"].containsKey("PowerReal_P_Sum") ) {
46
+ if (!root.containsKey("Body")) {
58
47
ESP_LOGW("custom", "Invalid JSON structure");
59
48
return false;
60
49
}
Original file line number Diff line number Diff line change 2
2
3
3
esphome :
4
4
min_version : 2024.11.1
5
- # ----------------------------------------------------------------------------------------------------
6
- # Sensor updated every second to give feedback in Home Assistant
7
- # ----------------------------------------------------------------------------------------------------
8
- sensor :
9
- # Sensor showing the actual power consumption
10
- - id : real_power
11
- platform : template
12
- name : " Real Power"
13
- device_class : " power"
14
- unit_of_measurement : " W"
15
- update_interval : 1s
16
5
17
6
# ----------------------------------------------------------------------------------------------------
18
7
# Use http request component
Original file line number Diff line number Diff line change 1
1
<< : !include power_meter_common.yaml
2
2
3
- # ----------------------------------------------------------------------------------------------------
4
- # Sensor updated every second to give feedback in Home Assistant
5
- # ----------------------------------------------------------------------------------------------------
6
-
7
- sensor :
8
- # Sensor showing the actual power consumption
9
- - id : real_power
10
- platform : template
11
- name : " Real Power"
12
- device_class : " power"
13
- unit_of_measurement : " W"
14
- update_interval : 1s
15
-
16
3
# ----------------------------------------------------------------------------------------------------
17
4
# Use http request component
18
5
# ----------------------------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments