-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange-address.yaml
89 lines (72 loc) · 2.04 KB
/
change-address.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
esphome:
name: power-meter
on_boot:
## configure controller settings at setup
## make sure priority is lower than setup_priority of modbus_controller
priority: -100
then:
- lambda: |-
auto new_address = 0x05;
if(new_address < 0x01 || new_address > 0xF7) // sanity check
{
ESP_LOGE("ModbusLambda", "Address needs to be between 0x01 and 0xF7");
return;
}
esphome::modbus_controller::ModbusController *controller = id(pzem);
auto set_addr_cmd = esphome::modbus_controller::ModbusCommandItem::create_write_single_command(
controller, 0x0002, new_address);
delay(200) ;
controller->queue_command(set_addr_cmd);
ESP_LOGI("ModbusLambda", "PZEM Addr set");
esp8266:
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret encryption_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Power-Meter Fallback Hotspot"
password: !secret fallback_hotspot_password
captive_portal:
uart:
rx_pin: D2
tx_pin: D1
baud_rate: 9600
sensor:
- platform: pzemac
current:
name: "PZEM-004T V3 Current"
voltage:
name: "PZEM-004T V3 Voltage"
energy:
name: "PZEM-004T V3 Energy"
power:
name: "PZEM-004T V3 Power"
frequency:
name: "PZEM-004T V3 Frequency"
power_factor:
name: "PZEM-004T V3 Power Factor"
update_interval: 5s
modbus:
send_wait_time: 200ms
id: mod_bus_pzem
modbus_controller:
- id: pzem
# The current device address.
address: 0xF8
# The special address 0xF8 is a broadcast address accepted by any pzem device,
# so if you use this address, make sure there is only one pzem device connected
# to the uart bus.
# address: 0xF8
modbus_id: mod_bus_pzem
command_throttle: 0ms
setup_priority: -10
update_interval: 5s