Skip to content

Commit ef25764

Browse files
author
Xavier Berger
committed
refactor(power_meter): move real_power to common
1 parent 1e8e007 commit ef25764

4 files changed

+15
-37
lines changed

solar_router/power_meter_common.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,17 @@ globals:
1010
- id: power_meter_activated
1111
type: int
1212
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

solar_router/power_meter_fronius.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22

33
esphome:
44
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
165

176
# ----------------------------------------------------------------------------------------------------
187
# Use http request component
@@ -54,7 +43,7 @@ script:
5443
id(real_power).publish_state(NAN);
5544
} else {
5645
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")) {
5847
ESP_LOGW("custom", "Invalid JSON structure");
5948
return false;
6049
}

solar_router/power_meter_proxy_client.yaml

-11
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22

33
esphome:
44
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
165

176
# ----------------------------------------------------------------------------------------------------
187
# Use http request component

solar_router/power_meter_shelly_em.yaml

-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
<<: !include power_meter_common.yaml
22

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-
163
# ----------------------------------------------------------------------------------------------------
174
# Use http request component
185
# ----------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)