Hi, I’m fairly new to the Home Assistant space and currently trying to integrate my custom builds into it.
I have an ESP32-C3 board which serves as a PIR sensor for the yard lighting. The board is solar powered and is in sleep mode most of the time. A description of the project can be found here.
In principle, it is a generic ESP32-C3 and I only have to manage a few GPIOs.
Please correct me if I am wrong. To integrate the whole thing into HA, do I write a YAML file that reflects the logic of the linked C code?
I have already done some reading. However, I am particularly concerned about the flashing of the status LED (ESP is woken up-> LED on-> 50ms sleep-> ESP is woken up-> LED off → 950ms sleep etc.) and the persistent level of the GPIOs during sleep.
Of course, the PIR sensor no longer has to communicate with the actuator via ESPNow, but an energy-saving logic should be created, which sends the detected movement to HA in a dark environment.
It may be possible to design the logic a little differently, but the general functions as they are now would be nice to keep.
Does anyone have any experience with such things and can give me some advice?
If you are interested in installing ESPHome (and any of the components, then you write a YAML that will generate the C++, create a bin and flash the ESP Node.
In other words the other way around
If you do not want to use ESPHome, there are a number of ways of communicating with HA. However, since you have posted on a ESPHome Forum, all ways lead to the following site. It is a sweety shop! Good luck
There is generally more than one way to do something. A battery operated esp32 device is a challenging thing to get right. Doing it with esphome even more so.
If your goal is to get a working system quickly, I would recommend a pre built sensor that runs on batteries. I use the SonOff basic PIR sensor that is Zigbee. I have one that is sensitive to signal quality and goes out to lunch when it is bad, but works fine in a different location.
If your goal is to learn how to create good esphome devices, realize there will be a learning curve. How steep/difficult that will be depends on what you already know and how quickly you can learn new things that are not well documented. What you want to do (battery operated) is not simple and I have seen many people struggling with it, so clearly not an easy task that can be done by studying something for even 30 mins. There are MANY threads on this forum and the Internet in general where people have shared what they have done and the struggles that they had. I have yet to see one where someone said it was easy.
However, I have seen many posts where people figured a basic device very quickly. So esphome does make some things very easy.
I have given it some thought and you are probably right.
Reinventing the entire sensor via ESPHome is pointless.
I think I will give both the PIR sensor and the associated actuators an MQTT interface and integrate them into HA.
I already have and tested the hardware, it works great and it would be pointless to buy new hardware.
The linked board has everything necessary for solar operation on board and only needs to be configured on the software side.
As I already mentioned in another post, I will approach the whole thing differently than configuring it via ESPHome, I think that is quite easy to implement.
I have several Esphome devices running. I also have few Esp devices that I can’t or I don’t want to use Esphome. That doesn’t prevent them to communicate with Esphome devices. I use simple HTTP requests, but there are many ways of wirelessly exchanging data between devices.
I have to disagree with @neel-m. Building ESPHome devices is not a big deal. I have several DIY sensors around my home and a couple of off-the-shelf. (How long do you think the original firmware existed before being flashed with an ESPHome binary?)
As you discovered, the easiest method is to simply add MQTT to your C++ code. But what do you learn in the process?
ESPHome is written in Python. The YAML configuration file is not code, it is configuration with a bit of logic thrown in because they can. The ESPHome Builder is a compiler. If you have ever converted a Python script into a C++ source code, then you are a better programmer than I ever was.
I recently converted a 14-segment LED display from Arduino C++ to ESPHome. (Challenge accepted).
If you are going to fall further into this rabbit hole, then seriously think about creating your own YAML configuration files for some of your sensors.
Since you said you disagreed with me, what exactly are you disagreeing with?
I said
A battery operated esp32 device is a challenging thing to get right. Doing it with esphome even more so.
Your statement said nothing about battery operated, which was the main point of what is hard.
Creating a simple esphome really is simple, so simple MANY people have accomplished it. I haven’t seen a single example of someone saying it is simple to create a battery operated esphome device. I have seen MANY people write about how challenging it is and none of them have managed the battery life of my SonOff PIR sensors.
It is is all about using the right tool for the job. Sometimes you need a mini ball peen hammer and sometimes you need the big sledgehammer. Both are hammers, yet they are not really interchangeable.
Thanks for all the suggestions.
However, I will now try MQTT first.
This offers me several advantages:
-easy implementation
-fast response of the actuator thanks to ESPNow
-fallback if HA does not work correctly, so I don’t have to be in the dark in this case either
So the whole system works as before, but I can still integrate everything into HA, which is actually the perfect solution.
There will be more projects to follow, so I can also get to work with YAML there.