I have … a kinda strange idea:
I have numerous ESP modules, many of them are built by myself, so occasional errors or not-correct functioning is not exactly a stranger to me, it can be due to bad programming (i’m not a pro here…), but mostly because either bad hardware design, missing component (pull-up etc…), or anything similar.
Now, i’d like to debug them as much as i can, so, what i wonder is - is it a chance to save logger from esphome modules into log files by default? I know that i can trigger writing single module’s log into file my myself via ssh (with command: “esphome logs kitchen-dimmer.yaml > kitchen_dimmer.log”), but i’d like for all my modules to write such a log by default - each module into a their own file.
It will be quite some MB of data, i know, but i have HA in VM on NAS, so i can assign HDD size as much as i wish, and i’d try to make an automation which would delete those files, say, each week or so.
Does anyone knows if this would be possible and how?
The only way I can think of doing it is using on_message: and using say a http post or some other method to write the data. You obviously would need some process/server to receive the data but it wouldn’t need to be part of HA.
Aha… you mean to create a text sensor in ESPHome which would send messages to HA? Well, i can try to play with it if something usefull comes out… thanks for idea!
No. on_message: is part of the logger component and is triggered for every log message. The example shows it sending a mqtt message but you could just as well send a http message to a web server.
Thanks a lot! It’s quite some things to study now… i’m not exactly “friend” with mqtt, so i’ll have to do some digging here. An idea to send http message to a (file on the) web server seems great, but i must figure out how to do it, so i’m back into google now…
do you have any quick suggestions/examples?
A quick recap after first testing: http is a no-go, since: first: it doesn’t support esp-idf, second: fw file for esp is too big, so it won’t flash over OTA - i’d need to have an esp module with bigger memory (i’m testing on ESP32).
I also succesfully created text sensor, but i wouldn’t to in this direction either, since i’d pump up HA’s database file into heaven, i guess…
I could probably whip something up in Node-Red fairly quickly.
It has the ability to accept a HTTP POST or an MQTT topic as an input, process it and the write it to a file. Or several files based on the contents of the input.
Have a fiddle (wine o’clock for me) and see if you can nut something out, otherwise may have time to assist tomorrow evening.
Note that a solution with Node-Red requires your HA server to be up and running - whereas an external server would work regardless.
EDIT: It’s getting past evening here now for reference
Many thanks for your help!
As i said: http won’t go, as it seems, since fw file won’t fit into even my 4MB esp32, not to mention that i have quite a few esp8266 modules with only 1MB…
I’l dig into mqtt and your mqtt logger suggestion.
(BTW…it’s before noon here )
I have CO sensor (MQ7) and a couple of relays on the same board (it’s still a testing board at this point, though), perhaps co component is also big…
If you’ll have some time then i’d appreciate if you write node-red example for me, it’s no hurry, though…
I don’t use node-red, but i’l install it (and learn a bit) if necesarry, no problem. But, as said, take your time - i have plans for these loggings for quite a while anyway…
Wow… this looks excellent! I DO have syslog server - i have synology NAS. And it’s already logging my test esp! So simple, yet so “complicated” when a man doesn’t know how to…
First test are just what i wanted - i’ll dig into this a bit more for details.
Many thanks! @zogara: many thanks to you, too for your help and support! Wait a bit with node-red for a while to see if this really works as planned.
EDIT: ok, it seems that this addon works with arduino only, too. I have some esp-idf modules (merely beacuse of bt-proxy, which supposely works better with esp-idf), but i guess i can temporarily switch them to arduino if i’ll have problems with either one of them.
Hopefully there’s an idf version out there, as syslog is a defacto standard. My main reason for mentioning was to point you to syslog as an option over file.
Well, as i found on original library’s github page it requires arduino. But as you said: perhaps esp-idf version will (eventually) be available (or discovered).
For now my main reason for needing this is solved: i have occasional non-explainable light turn-on in my sleeping room and i have to find out why this is happening. HA’s log doesn’t tell much, only that one binary sensor was turned on (which i already know…). Perhaps this log will help, although i have a suspicion that pull-up resistor in my wall button is either missing or it’s too big value. Since there’s a few metres from module to button there’s a possibility for a wire to catch all kind of “dirt” spikes and trigger input… If i’ll have a log confirmation which will say that button was indeed pressed i’ll know for sure that this is the cause.