-
Notifications
You must be signed in to change notification settings - Fork 0
/
epever_mppt_controller.yaml
144 lines (120 loc) · 4.18 KB
/
epever_mppt_controller.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
substitutions:
name: tracer
prefix: "MPPT"
update_interval: 10s
disabled_by_default: "true"
DI: GPIO19 # TX Pin
RO: GPIO18 # RX Pin
REDE: GPIO23 # RE/DE Pin
timezone: "Europe/Berlin"
esphome:
name: ${name}
project:
name: "cubinet-code.epever_mppt_controller"
version: "1.0.0"
esp32:
board: esp-wrover-kit
framework:
type: arduino
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# use_address: 10.1.1.167
dashboard_import:
package_import_url: github://cubinet-code/esphome-packages/epever_mppt_controller.yaml@main
logger:
level: INFO
# https://github.com/cubinet-code/esphome-packages
packages:
# special: "github://cubinet-code/esphome-packages/epever_mppt_controller/special.yaml@main"
specs: "github://cubinet-code/esphome-packages/epever_mppt_controller/specs.yaml@main"
operations: "github://cubinet-code/esphome-packages/epever_mppt_controller/operations.yaml@main"
realtime: "github://cubinet-code/esphome-packages/epever_mppt_controller/realtime.yaml@main"
stats: "github://cubinet-code/esphome-packages/epever_mppt_controller/stats.yaml@main"
stats-charging: "github://cubinet-code/esphome-packages/epever_mppt_controller/stats-charging.yaml@main"
stats-discharging: "github://cubinet-code/esphome-packages/epever_mppt_controller/stats-discharging.yaml@main"
stats-battery: "github://cubinet-code/esphome-packages/epever_mppt_controller/stats-battery.yaml@main"
settings: "github://cubinet-code/esphome-packages/epever_mppt_controller/settings.yaml@main"
loadcontrol: "github://cubinet-code/esphome-packages/epever_mppt_controller/loadcontrol.yaml@main"
batteryparams: "github://cubinet-code/esphome-packages/epever_mppt_controller/batteryparams.yaml@main"
web_server:
port: 80
time:
# - platform: homeassistant
# id: hass_time
# update_interval: 24h
# on_time_sync:
# then:
# - script.execute: update_rtc
- platform: sntp
id: sntp_time
update_interval: 24h
timezone: $timezone
servers:
- de.pool.ntp.org
on_time_sync:
then:
- script.execute: update_rtc
api:
reboot_timeout: 0s
ota:
on_error:
- button.press: restart_button
uart:
tx_pin: ${DI} # DI
rx_pin: ${RO} # RO
baud_rate: 115200
stop_bits: 1
modbus:
id: modbus1
flow_control_pin: ${REDE} # RE/DE
send_wait_time: 200ms
# disable_crc: true
modbus_controller:
- id: epever
address: 0x1
# command_throttle: 10ms
update_interval: ${update_interval}
sensor:
- platform: wifi_signal
name: "${prefix} ESP WiFi Signal"
update_interval: ${update_interval}
entity_category: diagnostic
button:
- platform: restart
id: restart_button
name: "${prefix} ESP Restart"
entity_category: diagnostic
script:
- id: update_rtc
then:
- lambda: |-
auto now = id(sntp_time).now();
if (!now.is_valid()) {
ESP_LOGW("epever_mppt_controller", "RTC not valid yet. Skipping RTC Update.");
return;
}
int s = now.second;
int m = now.minute;
int h = now.hour;
int d = now.day_of_month;
int M = now.month;
int y = now.year % 100;
uint16_t r1 = ((m << 8) | s);
uint16_t r2 = ((d << 8) | h);
uint16_t r3 = ((y << 8) | M);
std::vector<uint16_t> rtc_data = {
r1, r2, r3
};
for(std::vector<uint16_t>::size_type i = 0; i != rtc_data.size(); i++) {
ESP_LOGI("epever_mppt_controller", "RTC Data to be sent: 0x%x: 0x%x", i + 0x9013, rtc_data[i]);
}
esphome::modbus_controller::ModbusController *controller = id(epever);
esphome::modbus_controller::ModbusCommandItem cmd =
esphome::modbus_controller::ModbusCommandItem::create_write_multiple_command(
controller, 0x9013, 3, rtc_data
);
delay(200);
controller->queue_command(cmd);
delay(200);
ESP_LOGI("epever_mppt_controller", "RTC updated to %04d-%02d-%02d %02d:%02d:%02d", y+2000, M, d, h, m, s);