HABridge
Create a Home Assistant sensor from any hardware and send measurements with ESPNow or LoRa
Building from our ESPNow
To recap, there's not an easy way to send messages with ESPNow or LoRa within ESPHome/Home Assistant. There are a handful of reasons why you might want to.
- speed there's no need to negotiate a connection to any servers, messages can be sent in milliseconds from waking up
- battery-friendly WiFi is not ideal for battery-powered devices, it can take several seconds to start a connection
- range ESPNow is a long-range option, and LoRa can go several kilometers under the right circumstances
The components allow you to create sensors (regular measurements, binary, text) using ESPHome,
but sometimes you want to use something other than an ESP32 and Home Assistant. That's where
this library comes in. You could use something like this RAK3172
Use
HABridge is on GitHub
The API is simple, there are only two methods: ::line
and ::send
. There are two example projects that come with the library, one to use ESPNow and the other
for LoRa.
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
This example just uses rand()
to simulate sensor measurements. Declare an HABridge* class, get your sensor measurement, and turn it into a line
to be sent through either transport protocol.