thestaticturtle / esphome_syslog Goto Github PK
View Code? Open in Web Editor NEWA simple syslog component for esphome
License: ISC License
A simple syslog component for esphome
License: ISC License
heya,
i successfully used your syslog component before on a dingtian board (ethernet only) by using the known hack of just commenting out the if(WiFi.status() != WL_CONNECTED) line.
"some" months later, i tried using it again, in the meantime esphome was updated to 2023.11.2 (not sure what version was in use previously.. ), and now it looks like the component is not loaded at all. i dont even see the "syslog started" line, let alone the wifi not connected part (not using the ethernet "hack").
i also tried manually reverting this change but it had no effect.
could you please check if any "structural" changes are needed for current esphome version? am i missing something? someone else has it working with 2023.11.2 currently?
thanks
Hi, thanks for this component. I've burnt it onto a few esp8266 based modules and it seems to work well. Given udp is stateless and things would have to be really broken for the packet to not send it seems fairly low risk.
I just realised I now need to migrate to a different subnet and will need to reprogram my modules for them to report syslog. Am wondering if it's possible to grab the log server from a dhcp option? See http://www.networksorcery.com/enp/protocol/bootp/option007.htm
my current snip of yaml thats works just fine using your code:
esp8266:
board: nodemcuv2
# Enable logging
logger:
syslog:
ip_address: "192.168.10.101"
port: 1518
min_level: DEBUG
# Enable Home Assistant API
api:
I would like it so that I do not get the "basic" operations logged to my graylog server but the deeper level debug information such as when the unit gets updated, update failures, reboots, any kind of low level errors, etc. So I attempted the below but based on the examples in the documentation, they just don't make sense and the YAML will not compile. Can you please provide a clear code example of how this is accomplished to obtain ESPHOME_LOG_LEVEL_VERY_VERBOSE
/ LOG_DEBUG
level capture to graylog? Interestingly Logspout can send data to Graylog using GELF if at all possible to capture more information and a greater calirty as well instead of using syslog.
syslog:
ip_address: "192.168.10.101"
port: 1518
min_level: DEBUG
then:
- syslog.log:
level: 7
tag: "custom_action"
payload: "My log message"
I also tried the below:
syslog.log:
ip_address: "192.168.10.101"
port: 1518
level: 7
tag: "custom_action"
payload: "My log message"
Hello!
Is it possible to override client_id in syslog messages?
I see the client_id
in source files, but when I try to set custom client_id, esphome dashbord show me error that [client_id] is an invalid option for [syslog]. Please check the indentation.
Hi,, and thanks for this initiative :)
Unfortunately i'm encountering compilation error as below,, I'm using Hassos and esphome add-on 2021.12.0
any suggestion to fix this??
HA core: core: 2021.12.1
HA Supervisor: supervisor-2021.12.1
HA OS: Home Assistant OS 7.0
syslog folder is under /root/config/esphome/custom_components/ as following
[core-ssh esphome]$ cd custom_components/syslog/
[core-ssh syslog]$
[core-ssh syslog]$ ls -ltra
total 40
-rwxr--r-- 1 root root 1799 Mar 6 2021 syslog_component.h
-rwxr--r-- 1 root root 2048 Mar 6 2021 syslog_component.cpp
-rwxr--r-- 1 root root 2212 Mar 6 2021 __init__.py
-rwxr--r-- 1 root root 2353 Mar 6 2021 README.md
-rwxr--r-- 1 root root 755 Mar 6 2021 LICENSE
-rwxr--r-- 1 root root 270 Mar 6 2021 .gitignore
drwxr-xr-x 8 root root 4096 Dec 12 00:42 .git
drwxr-xr-x 3 root root 4096 Dec 12 13:43 ..
drwxr-xr-x 4 root root 4096 Dec 13 20:01 .
drwxr-xr-x 2 root root 4096 Dec 13 20:02 __pycache__
[core-ssh syslog]$ pwd
/root/config/esphome/custom_components/syslog
compiling my smini_danasmallroom.yaml file having the following configuration:
syslog:
ip_address: "192.168.xx.xxx"
port: 514
=====>>
INFO Reading configuration /config/esphome/smini_danasmallroom.yaml...
WARNING 'smini_danasmallroom': Using the '_' (underscore) character in the hostname is discouraged as it can cause problems with some DHCP and local name services. For more information, see https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name
INFO Detected timezone 'Asia/Riyadh'
INFO Generating C++ source...
INFO Compiling app...
Processing smini_danasmallroom (board: esp8285; framework: arduino; platform: platformio/espressif8266 @ 2.6.3)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|-- <ESPAsyncWebServer-esphome> 2.1.0
| |-- <ESPAsyncTCP-esphome> 1.2.3
| |-- <Hash> 1.0
| |-- <ESP8266WiFi> 1.0
|-- <DNSServer> 1.1.1
|-- <ESP8266WiFi> 1.0
|-- <ArduinoJson-esphomelib> 5.13.3
|-- <Syslog> 2.0.0
|-- <ESP8266mDNS> 1.2
Compiling /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/main.cpp.o
Linking /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/firmware.elf
/data/cache/platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/syslog/syslog_component.cpp.o: in function `esphome::syslog::SyslogComponent::loop()':
syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponent4loopEv+0x0): multiple definition of `esphome::syslog::SyslogComponent::loop()'; /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/esphome/components/syslog/syslog_component.cpp.o:syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponent4loopEv+0x0): first defined here
/data/cache/platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/syslog/syslog_component.cpp.o: in function `esphome::syslog::SyslogComponent::get_setup_priority() const':
syslog_component.cpp:(.text._ZNK7esphome6syslog15SyslogComponent18get_setup_priorityEv+0x4): multiple definition of `esphome::syslog::SyslogComponent::get_setup_priority() const'; /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/esphome/components/syslog/syslog_component.cpp.o:syslog_component.cpp:(.text._ZNK7esphome6syslog15SyslogComponent18get_setup_priorityEv+0x4): first defined here
/data/cache/platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/syslog/syslog_component.cpp.o: in function `esphome::syslog::SyslogComponent::SyslogComponent()':
syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponentC2Ev+0x14): multiple definition of `esphome::syslog::SyslogComponent::SyslogComponent()'; /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/esphome/components/syslog/syslog_component.cpp.o:syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponentC2Ev+0x14): first defined here
/data/cache/platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/syslog/syslog_component.cpp.o: in function `esphome::syslog::SyslogComponent::SyslogComponent()':
syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponentC2Ev+0x14): multiple definition of `esphome::syslog::SyslogComponent::SyslogComponent()'; /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/esphome/components/syslog/syslog_component.cpp.o:syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponentC2Ev+0x14): first defined here
/data/cache/platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/syslog/syslog_component.cpp.o: in function `esphome::syslog::SyslogComponent::log(unsigned char, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponent3logEhRKSsS3_+0xc): multiple definition of `esphome::syslog::SyslogComponent::log(unsigned char, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'; /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/esphome/components/syslog/syslog_component.cpp.o:syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponent3logEhRKSsS3_+0xc): first defined here
/data/cache/platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/syslog/syslog_component.cpp.o: in function `esphome::syslog::SyslogComponent::setup()':
syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponent5setupEv+0x40): multiple definition of `esphome::syslog::SyslogComponent::setup()'; /data/smini_danasmallroom/.pioenvs/smini_danasmallroom/src/esphome/components/syslog/syslog_component.cpp.o:syslog_component.cpp:(.text._ZN7esphome6syslog15SyslogComponent5setupEv+0x40): first defined here
collect2: error: ld returned 1 exit status
*** [/data/smini_danasmallroom/.pioenvs/smini_danasmallroom/firmware.elf] Error 1
========================= [FAILED] Took 21.49 seconds =========================
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:
esphome:
name: kc-868-a64
platform: ESP32
board: esp32dev
logger:
level: VERBOSE
syslog:
ip_address: "192.168.255.X"
port: 514
min_level: VERY_VERBOSE
api:
encryption:
key: <mykey>
ota:
password: <mypassword>
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO17_OUT
phy_addr: 0
manual_ip:
static_ip: 192.168.255.X
gateway: 192.168.255.1
subnet: 255.255.255.0
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 !
Hello!
I probably confused by all the github windows in my browser, and wrote in the wrong window.
Because I don't need all my logger messages to forward to syslog, it was easier to me to delete that part of your code in my implementation, than make a pull request and make it configurable.
I need the syslog forwarding in a lambda function, therefore the example.
On the other hand, I don't know how to use your code in yaml coding. Well.. rereading your description answered that question.
I must have been very tired not to notice that.
Best regards,
Atus
Hi there!
Firstly thanks for this great component, I've been using it to log time-based events and it's been very useful.
This evening I stumbled on a scenario where I believe esphome_syslog prevents an esp device from booting successfully.
In this scenario the esphome api, web_server and remote logger all stop functioning. Fortunately OTA is still available.
I have a script which is called by "on_boot" and under normal circumstances it never calls syslog.log until well after the esp boots, time syncs, api connects, etc.
Tonight the script tried to call syslog.log immediately after a reboot and that's where things went awry.
I use the following syslog configuration:
syslog:
enable_logger: false
ip_address: "192.168.x.x"
port: 514
The following on_boot reproduces the problem:
esphome:
on_boot:
priority: 700.0
then:
- wait_until:
wifi.connected:
- syslog.log:
level: 5
tag: "ESPHome"
payload: "This will break things"
This on_boot also causes issues:
esphome:
on_boot:
priority: -100.0
then:
- syslog.log:
level: 5
tag: "ESPHome"
payload: "This will break things"
However this on_boot works fine:
esphome:
on_boot:
priority: 700.0
then:
- wait_until:
time.has_time:
#also working is api.connected:
- syslog.log:
level: 5
tag: "ESPHome"
payload: "This will work fine"
I can see you have return setup_priority::LATE; defined, so I'm not sure where else to go looking for the cause of this issue.
For the moment I have a workaround in place (testing for api.connected anywhere that I call syslog.log).
Thanks!
Fails right out the gate. Not sure what's wrong here.
I am building ESPHome Bluetooth Proxies for Sonoff Mini R4 (ESP32) switches. The ESPHome link seems quite adamant that we use framework: {type: esp-idf}
. When I switch from {type: arduino}
to {type: esp-idf}
, I start getting this error:
In file included from src/esphome/components/syslog/syslog_component.cpp:1:
src/esphome/components/syslog/syslog_component.h:9:10: fatal error: Syslog.h: No such file or directory
Example config:
esphome:
name: syslog-esp-idf
esp32:
board: esp32dev
framework:
type: esp-idf
logger:
syslog:
ip_address: !secret syslog_ip_address
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
Hi!
I already remote log messages from my espeasy components. So basically the setup is working.
What I did was adding the settings to my esphome components yaml file:
debug:
logger:
level: debug # none, error, warn, info, debug, verbose, very_verbose
syslog:
ip_address: "192.168.x.y"
port: 514
I see, that it got compiled in the pio compile logs and after uploading mqtt logs give
[17:46:57][I][syslog:032]: Started
Still I do not see any logs in syslog. Anything I am missing out?
Also I do not understand in the description what your intentions with "then:" are. But this could also be because I am new to esphome.
Br, Alex.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.