Open kboeckx opened 1 year ago
I don't have an ESP32 on me to test this right now, nor do I have an Ethernet module for it. But if you feel up to it, you can try to add a condition to check Ethernet connectivity in this file: https://github.com/TheStaticTurtle/esphome_syslog/blob/main/syslog_component.cpp#L57
I'm not certain how it would work on the esp32 idf platform, though, maybe it's as simple as including the Ethernet.h
header and getting the link status.
As an ugly patch just to test that syslog/udp even works (because I'm using WiFiUDP
) you could try to remove the check completely
Samuel
Thanks for a quick repply !
After looking at the source code on https://github.com/arcao/Syslog, I think this your code is not going to work because it uses the WIFI components.
I don't have time today to look into this and read the code and understand it :-) So please give me some time, I will look into this next week.
Greetings !
After looking at the source code on https://github.com/arcao/Syslog, I think this your code is not going to work because it uses the WIFI components.
Actually, no it doesn't, while you can give it an instance of WiFiUDP
you can also do it for EthernetUDP
see their SimpleLogging
example. The only thing that I'm not sure about is how to detect that it's using Ethernet.
Samuel
Hi Samuel,
I did some testing and found out that it works with your code. I removed the "if(WiFi.status() != WL_CONNECTED)" part of your code and it works.
I was reading the source code and searching the internet but I can't find out how to check if ethernet is connected. For me it works, I receive syslog messages. If you ever find out how to check for etherenet connectivity, please let me know.
Thanks for support !
I can confirm on my ESP32 WT32-ETH01 this hack works. I commented out the WiFi connection check and now I get rsyslog messages on my server.
Nice to have if this were implemented in a way so that both Ethernet and WiFi work without having to modify the code and pull it locally :)
But nevertheless, great work, love it!!
Hi,
Nice to know π!
Currently, I don't have a working esp32 board with Ethernet as I don't really have any project that needs it, so I can't actually test it.
As you saw, it's easy-ish to switch to Ethernet, almost all the code is already compatible thanks to WifiUDP
and EthernetUDP
using the same UDP
class.
I basically need to do two things:
WifiUdp
instance for every log line caused some issue for me in the past. So it needs to change only when the esp switched connection methods. The tricky thing is using both Wi-Fi and Ethernet since, especially since the esp32 ip stack is apparently not always stable π
Would you mind describing how the module behaves if there is no cable plugged in or if the driver didn't initialize for some reason? My experience with WifiUDP is that it will probably fail silently.
One thing, I'm not clear about the docs is that it states that The Ethernet component and the Wi-Fi component may not be used simultaneously, even if both are physically available.
Does that mean it won't let you compile with both modules, or just not running simultaneously?
But it's of course doable. The thing is, as I said, I don't have the capabilities to do it right now. One thing that could work in the meantime is a secondary branch (or even PR) and users could use the experimental branch/pr-id on the external_components
import.
Thanks for the update!
On a side note, esphome evolved a lot since I last looked at how it works internally, I'm amazed that this module still works "fine" after going through so many updates π! If I get my hands on an Ethernet board, I'll probably redo of most of the module.
Syslog isn't complicated and ditching the *UDP
class entirely and instead using a socket is possible as suggested by esphome docs https://esphome.io/cookbook/lambda_magic.html#send-udp-commands. This would not only reduce overhead (Especially if I also ditch the Syslog
library), but would also solve compatibility with esp-idf since it would use anything from the Arduino framework π€.
I need to tinker with the esp32 and sendto
because if there is no connection it will most likely just do nothing intentionally, and I would prefer to write a warning in the log if there is an issue sending something.
You know what, I'll order a board of AliExpress so that I will at least have it, and I'll work on it when I'll have a bit more time (my month is about to get crazy πͺ). Any recommendations?
Yeah no worries, it's not urgent for me since it works :)
I just tested it, but only OTA since otherwise, I have to solder again and no time for that :).
While I was connected with "esp logs" it worked. Then I pulled the cable, it said "Connection reset by pear", replugged the cable, it didn't work again. Then I CTRL-C, then re-issued the command esphome logs, but still it didn't connect OTA. I had to unplug the power from the ESP32 before it restarted.
I guess more info will be visible if I connect via serial, but as I said, I'm having a hard time finding time for the project I'm using your custom module in.
With regards to recommendations? I don't know, I just bought an ESP32 WT32-eth01 for around 15$/15eur. I guess most of them are the same but not sure :)
[09:26:25][C][mqtt.light:079]: Command Topic: '12channel-dimmer/light/flow_heater_l1/command'
[09:26:25][C][mqtt.light:078]: MQTT Light 'Flow heater L2':
[09:26:25][C][mqtt.light:079]: State Topic: '12channel-dimmer/light/flow_heater_l2/state'
[09:26:25][C][mqtt.light:079]: Command Topic: '12channel-dimmer/light/flow_heater_l2/command'
[09:26:25][C][mqtt.light:078]: MQTT Light 'Flow heater L3':
[09:26:25][C][mqtt.light:079]: State Topic: '12channel-dimmer/light/flow_heater_l3/state'
[09:26:25][C][mqtt.light:079]: Command Topic: '12channel-dimmer/light/flow_heater_l3/command'
WARNING 12channel-dimmer.local: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for 12channel-dimmer.local
WARNING Disconnected from API
WARNING 12channel-dimmer.local: Connection error occurred: [Errno 104] Connection reset by peer
WARNING Can't connect to ESPHome API for 12channel-dimmer.local: Read failed (ReadFailedAPIError)
INFO Trying to connect to 12channel-dimmer.local in the background
WARNING 12channel-dimmer.local: Connection error occurred: [Errno 104] Connection reset by peer
WARNING 12channel-dimmer.local: Connection error occurred: [Errno 104] Connection reset by peer
WARNING 12channel-dimmer.local: Connection error occurred: [Errno 104] Connection reset by peer
^C(esphome) userwa@macbookuser:~/Documents/smarthome/esphome/tmp$ esphome logs dimpack-controller.yml
INFO ESPHome 2023.8.3
INFO Reading configuration dimpack-controller.yml...
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
Found multiple options for logging, please choose one:
[1] Over The Air (12channel-dimmer.local)
[2] MQTT (10.10.10.19)
(number): 1
INFO Starting log output from 12channel-dimmer.local using esphome API
WARNING 12channel-dimmer.local: Connection error occurred: [Errno 104] Connection reset by peer
WARNING Can't connect to ESPHome API for 12channel-dimmer.local: Read failed (ReadFailedAPIError)
INFO Trying to connect to 12channel-dimmer.local in the background
WARNING 12channel-dimmer.local: Connection error occurred: [Errno 104] Connection reset by peer
WARNING 12channel-dimmer.local: Connection error occurred: [Errno 104] Connection reset by peer
WARNING 12channel-dimmer.local: Connection error occurred: [Errno 104] Connection reset by peer
This should now work (for Ethernet, esp-idf, IPv6) with https://github.com/TheStaticTurtle/esphome_syslog/pull/17
Hi, I have an ESP32 bord that is connected via Ethernet instead of WIFI. So NO WIFI is configured, only Ehternet.
First part of my esphome config is:
I was troubleshooting this because I did not get any syslog message on my syslog server. I used "tcpdump" to see if any syslog packet was received by the syslog server -> the answer was NO :-( (I'm an IT specialist so I know what I"m doing)
Then I added the action "syslog.log" to send explicit a syslog message. Then I received this:
[syslog:058]: Tried to send "custom_action"@"My log message" with level 7 but Wifi isn't connected yet
So my question is: as I'm not using WIFI to connect the ESP32, would it be possible to add support for Ethernet ? Thanks for reponse and support !