-
Notifications
You must be signed in to change notification settings - Fork 1
/
inode-reader-debug.yaml
125 lines (105 loc) · 3.51 KB
/
inode-reader-debug.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
substitutions:
plugname: home
inode_mac: "DD:CC:55:00:99:11"
board_type: esp-wrover-kit
platform: ESP32
domain: !secret ENERGY_DOMAIN
wifi_ssid: !secret WIFI_SSID
wifi_pass: !secret WIFI_PASS
fallback_hotspot_pass: !secret AP_FALLBACK_PASS
esphome:
name: ${plugname}
platform: ${platform}
board: ${board_type}
wifi:
ssid: ${wifi_ssid}
password: ${wifi_pass}
domain: ${domain}
ap:
ssid: ${plugname} Energy Fallback Hotspot
password: ${fallback_hotspot_pass}
captive_portal:
logger:
level: DEBUG
api:
time:
- platform: sntp
id: local_time
ota:
web_server:
port: 80
esp32_ble_tracker:
scan_parameters:
duration: 1s
active: false
on_ble_manufacturer_data_advertise:
- mac_address: ${inode_mac}
manufacturer_id: 82A4
then:
- lambda: |-
ESP_LOGD("ble_adv", " 0 - %02X", (x[0] ) );
ESP_LOGD("ble_adv", " 1 - %02X", (x[1] ) );
ESP_LOGD("ble_adv", " 2 - %02X", (x[2] ) );
ESP_LOGD("ble_adv", " 3 - %02X", (x[3] ) );
ESP_LOGD("ble_adv", " 4 - %02X", (x[4] ) );
ESP_LOGD("ble_adv", " 5 - %02X", (x[5] ) );
ESP_LOGD("ble_adv", " 6 - %02X", (x[6] ) );
ESP_LOGD("ble_adv", " 7 - %02X", (x[7] ) );
ESP_LOGD("ble_adv", " 8 - %02X", (x[8] ) );
ESP_LOGD("ble_adv", " 9 - %02X", (x[9] ) );
ESP_LOGD("ble_adv", " 10 - %02X", (x[10] ) );
ESP_LOGD("ble_adv", " impulses hex - %02X:%02X", x[7], x[6] );
ESP_LOGD("ble_adv", " energy hex - %02X:%02X:%02X:%02X", x[5], x[4], x[3], x[2] );
ESP_LOGD("ble_adv", " power hex - %02X:%02X", x[1], x[0] );
uint16_t impulses_raw = (x[6]) + (x[7] << 8);
uint16_t power_raw = (x[0]) + (x[1] << 8);
uint32_t energy_raw = (x[2]) + (x[3] << 8) + (x[4] << 16) + (x[5] << 24);
ESP_LOGD("ble_adv", " impulses_raw - %i", impulses_raw );
ESP_LOGD("ble_adv", " power_raw - %i", power_raw );
ESP_LOGD("ble_adv", " energy_raw - %i", energy_raw );
float power = float(power_raw)/float(impulses_raw) * 60.0 * 1000;
float energy = float(energy_raw)/float(impulses_raw);
ESP_LOGD("ble_adv", " power - %.2f", power );
ESP_LOGD("ble_adv", " energy - %.2f", energy );
id(home_power).publish_state(power);
id(home_energy).publish_state(energy);
id(home_impulses).publish_state(impu lses_raw);
text_sensor:
- platform: version
name: "ESPHome Version ${plugname}"
sensor:
- plat form: ble_rssi
mac_address: ${inode_mac}
name: "inode ${inode_mac}"
- platform: uptime
id: socket_uptime
name: "Uptime ${plugname}"
icon: mdi:clock-outline
update_interval: 60s
- platform: wifi_signal
id: socket_wifi_signal
name: "WiFi Signal ${plugname}"
update_interval: 30s
- platform: template
name: "Power ${plugname}"
id: home_power
unit_of_measurement: "W"
accuracy_decimals: 3
icon: "mdi:flash"
- platform: template
name: "Total Energy ${plugname}"
id: home_energy
unit_of_measurement: 'kWh'
accuracy_decimals: 3
icon: "mdi:flash"
- platform: template
name: "Impulses ${plugname}"
id: home_impulses
unit_of_measurement: 'imp/kWh'
accuracy_decimals: 0
- platform: total_daily_energy
name: "Total Daily Energy ${plugname}"
power_id: home_power
unit_of_measurement: kW
filters:
- multiply: 0.001