-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpower_meter_fronius.yaml
68 lines (62 loc) · 2.58 KB
/
power_meter_fronius.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
# ----------------------------------------------------------------------------------------------------
# Sensor updated every second to give feedback in Home Assistant
# ----------------------------------------------------------------------------------------------------
sensor:
# Sensor showing the actual power consumption
- id: real_power
platform: template
name: "Real Power"
device_class: "power"
unit_of_measurement: "W"
update_interval: 1s
# ----------------------------------------------------------------------------------------------------
# Use http request component
# ----------------------------------------------------------------------------------------------------
http_request:
id: http_request_data
useragent: esphome/device
timeout: 10s
verify_ssl: False
# ----------------------------------------------------------------------------------------------------
# Define scripts for power collection
# ----------------------------------------------------------------------------------------------------
script:
# Fronius script gather power reports from inverter and update globals (real_power)
# Information are provided as json. Power exchanged with the grid is names PowerReal_P_Sum
# When this value is positive, energy is taken from the grid.
# When this value is negative, energy is pushed to the grid.
- id: power_meter_source
mode: single
then:
- if:
condition:
lambda: 'return network::is_connected();'
then:
- http_request.get:
url: http://${power_meter_ip_address}/solar_api/v1/GetMeterRealtimeData.cgi
headers:
Content-Type: application/json
capture_response: true
max_response_buffer_size: 4096
on_response:
then:
- logger.log:
format: 'Response status: %d, Duration: %u ms'
args:
- response->status_code
- response->duration_ms
- lambda: |-
json::parse_json(body, [](JsonObject root) -> bool {
id(real_power).publish_state(root["Body"]["Data"]["0"]["PowerReal_P_Sum"].as< float >());
return true;
});
time:
- platform: sntp
on_time:
- seconds: /1
then:
- if:
condition:
- lambda: return id(power_meter_activated) != 0;
then:
- script.execute: power_meter_source