-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesp32-rtl_433-decoder.yaml
106 lines (95 loc) · 3.61 KB
/
esp32-rtl_433-decoder.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
packages:
board_config: !include esp32_cc1101.yaml
#example of how to enable/disable specific protocols at boot
#runtime_protocols: !include rtl_433_protocols.yaml
esphome:
name: esp32-rtl433-decoder
friendly_name: ESP32 RTL 433 Decoder example of ESPHome/Home Assistant setup
# can reduce memory/cpu usage if desired by setting build_flags to limit devices...
#platformio_options:
# build_flags:
# - '-DMY_RTL433_DEVICES="DECL(govee_h5054) DECL(lacrosse_tx141x) "'
libraries:
- rtl_433_Decoder_ESP=https://github.com/juanboro/rtl_433_Decoder_ESP.git
external_components:
- source:
type: git
url: https://github.com/juanboro/esphome-rtl_433-decoder
# no mqtt since this is for API/web access
mqtt: !remove
# How to use:
# 1. Create a rtl_433 component to receive the json messages and process
# 2. Send raw data to the rtl_433 component via lambdas (usually remote_receiver on_raw)
# this example processes pulses from the remote receiver component and then updates buttons
# and sensors from the decoded data
rtl_433:
id: my_rtl433_id
on_json_message:
then:
- lambda: |-
if ((x["model"]=="Govee-Water")&&(x["id"].as<int>()==4759)) {
id(govee_4759_wet).publish_state(x["detect_wet"].as<int>());
if (x["event"]=="Button Press") {
id(govee_4759_button).publish_state(true);
} else if (x["battery_ok"]) {
id(govee_4759_bat).publish_state(x["battery_ok"].as<float>());
}
} else if ((x["model"]=="LaCrosse-TX141THBv2")&&(x["id"].as<int>()==188)) {
id(lacross_temp_sensor).publish_state(x["temperature_C"].as<float>());
id(lacross_hum_sensor).publish_state(x["humidity"].as<float>());
}
- delay: .5s
- lambda: |-
id(govee_4759_button).publish_state(false);
remote_receiver:
- id: !extend rf_receiver
on_raw:
then:
- lambda: |-
id(my_rtl433_id).recv_raw(x);
sensor:
- platform: template
name: "Lacross Temperature Sensor"
id: lacross_temp_sensor
unit_of_measurement: celcius
- platform: template
name: "Lacross Humidity Sensor"
id: lacross_hum_sensor
unit_of_measurement: percent
- platform: template
name: "Govee Leak Detector battery level"
id: govee_4759_bat
unit_of_measurement: percent
# - platform: template
# name: "Unparsed rtl_433 signals"
# id: rtl_433_unparsed
# lambda: return id(my_rtl433_id).rd.unparsedSignals;
binary_sensor:
- platform: template
name: "Govee Leak Detector Button Press"
id: govee_4759_button
- platform: template
name: "Govee Leak Detector WET"
id: govee_4759_wet
## EXAMPLE of how to
script:
- id: boot_rtl_433
then:
- lambda: |-
// build a new custom protocol list for rtl_433
rtl_433_Decoder* rd=id(my_rtl433_id).get_rtl_433_Decoder();
r_cfg_t* cfg=&rd->g_cfg;
list_t* r_devs=&cfg->demod->r_devs;
ESP_LOGI("boot_rtl_433", "There are %d devices currently",r_devs->len);
list_free_elems(r_devs,&free);
char* arg = NULL;
for (int i = 0; i < cfg->num_r_devices; i++) {
if (cfg->devices[i].disabled <= 2) { // ignore anything hidden
r_device* rdev=&cfg->devices[i];
if ((strstr(rdev->name,"Govee")||(strstr(rdev->name,"LaCrosse")))) {
register_protocol(cfg, &cfg->devices[i], arg);
ESP_LOGI("boot_rtl_433", "Enabled protocol %s",rdev->name);
}
}
}
ESP_LOGI("boot_rtl_433", "... and now there are %d devices.",r_devs->len);