esphome / esphome/feature-requests
Log level line tag fixes - INFO=slow & default, DEBUG=repetitive
- Dominant language
- No language data
- Stars
- 450
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the problem you have/What new integration you would like**
_tl;dr: Update log line tagging so that we get more non-high-speed-repetitive lines on INFO and make this the default_
By default ESPHome uses DEBUG log levels. If you want less logging and decrease this to the next available level of granularity (INFO) logging drops to being useless. The reason why I would like more finegrained control is that I've found that reducing UART output has beneficial effects to responsiveness. On 2021.09 with the following settings I have perfect continuous uptime.
```
logger:
level: INFO # Less logs to reduce load
baud_rate: 0 # Disable serial logging via UART, reduces load
```
Increasing of the baud_rate leads to detectable packetloss. In similar vein, I don't need every sensor displayed every second (DSMR w 5.0 hardware for example) leading to continuous 20 lines/sec log output which serves no purpose. All I want is simply to know the device has started, has wifi, has sensors and that the sensors output something sane (once). All the other info I'll get through looking at the sensor values in the consumer of the data (home assistant for example).
_Proposal:_
- INFO shows startup lines, config, wifi (ex anything that's >1x second), detected sensors and if possible first sensor value
- DEBUG shows individual measurements by sensors
- Immediate output of current sensor value at startup (for example Dallas waits for a bit until it shows the first one)
- There are log lines tagged with C (assumed CONFIG) which are only visible on DEBUG, remove this level and replace by INFO and DEBUG respectively
_Example:_
The following is the output of a real sensor with the current log levels.
```
INFO Successfully connected to 192.168.30.110
[08:50:51][I][app:102]: ESPHome version 2021.9.2 compiled on Sep 28 2021, 08:50:16
[08:50:51][C][status_led:019]: Status LED:
[08:50:51][C][status_led:020]: Pin: GPIO1 (Mode: OUTPUT)
[08:50:51][C][wifi:501]: WiFi:
[08:50:51][C][wifi:361]: SSID: [redacted]
[08:50:51][C][wifi:362]: IP Address: 192.168.30.110
[08:50:51][C][wifi:364]: BSSID: [redacted]
[08:50:51][C][wifi:365]: Hostname: 'esp32-k4'
[08:50:51][C][wifi:369]: Signal strength: -57 dB ▂▄▆█
[08:50:51][C][wifi:373]: Channel: 6
[08:50:51][C][wifi:374]: Subnet: 255.255.255.0
[08:50:51][C][wifi:375]: Gateway: 192.168.30.254
[08:50:51][C][wifi:376]: DNS1: 192.168.5.254
[08:50:51][C][wifi:377]: DNS2: 0.0.0.0
[08:50:51][C][uptime.sensor:030]: Uptime Sensor 'ESP32-K4 Uptime'
[08:50:51][C][uptime.sensor:030]: State Class: 'total_increasing'
[08:50:51][C][uptime.sensor:030]: Unit of Measurement: 's'
[08:50:51][C][uptime.sensor:030]: Accuracy Decimals: 0
[08:50:51][C][uptime.sensor:030]: Icon: 'mdi:timer-outline'
[08:50:51][C][logger:193]: Logger:
[08:50:51][C][logger:194]: Level: DEBUG
[08:50:51][C][logger:195]: Log Baud Rate: 0
[08:50:51][C][logger:196]: Hardware UART: UART0
[08:50:51][C][dallas.sensor:072]: DallasComponent:
[08:50:51][C][dallas.sensor:073]: Pin: GPIO32 (Mode: OUTPUT)
[08:50:51][C][dallas.sensor:074]: Update Interval: 60.0s
[08:50:51][D][dallas.sensor:079]: Found sensors:
[08:50:51][D][dallas.sensor:082]: 0x05031997797BF828
[08:50:51][C][dallas.sensor:087]: Device 'Test temp'
[08:50:51][C][dallas.sensor:087]: Device Class: 'temperature'
[08:50:51][C][dallas.sensor:087]: State Class: 'measurement'
[08:50:51][C][dallas.sensor:087]: Unit of Measurement: '°C'
[08:50:51][C][dallas.sensor:087]: Accuracy Decimals: 1
[08:50:51][C][dallas.sensor:095]: Address: 0x05031997797BF828
[08:50:51][C][dallas.sensor:096]: Resolution: 12
[08:50:51][C][ota:029]: Over-The-Air Updates:
[08:50:51][C][ota:030]: Address: 192.168.30.110:3232
[08:50:51][C][api:135]: API Server:
[08:50:51][C][api:136]: Address: 192.168.30.110:6053
[08:50:51][C][wifi_signal.sensor:009]: WiFi Signal 'ESP32-K4 WiFi Signal'
[08:50:51][C][wifi_signal.sensor:009]: Device Class: 'signal_strength'
[08:50:51][C][wifi_signal.sensor:009]: State Class: 'measurement'
[08:50:51][C][wifi_signal.sensor:009]: Unit of Measurement: 'dBm'
[08:50:51][C][wifi_signal.sensor:009]: Accuracy Decimals: 0
[08:50:54][D][api:095]: Accepted 192.168.30.121
[08:50:54][D][api.connection:727]: Home Assistant 2021.9.7 (192.168.30.121): Connected successfully
[08:51:40][D][sensor:121]: 'ESP32-K4 Uptime': Sending state 52.00200 s with 0 decimals of accuracy
[08:51:46][D][dallas.sensor:153]: 'Test temp': Got Temperature=20.8°C
[08:51:46][D][sensor:121]: 'Test temp': Sending state 20.75000 °C with 1 decimals of accuracy
```
Below is the same but now with the proposed updates. Lines ending with ** at the end of 08:50 were added
```
INFO Successfully connected to 192.168.30.110
[08:50:51][I][app:102]: ESPHome version 2021.9.2 compiled on Sep 28 2021, 08:50:16
[08:50:51][I][status_led:019]: Status LED:
[08:50:51][I][status_led:020]: Pin: GPIO1 (Mode: OUTPUT)
[08:50:51][I][wifi:501]: WiFi:
[08:50:51][I][wifi:361]: SSID: [redacted]
[08:50:51][I][wifi:362]: IP Address: 192.168.30.110
[08:50:51][I][wifi:364]: BSSID: [redacted]
[08:50:51][I][wifi:365]: Hostname: 'esp32-k4'
[08:50:51][I][wifi:369]: Signal strength: -57 dB ▂▄▆█
[08:50:51][I][wifi:373]: Channel: 6
[08:50:51][I][wifi:374]: Subnet: 255.255.255.0
[08:50:51][I][wifi:375]: Gateway: 192.168.30.254
[08:50:51][I][wifi:376]: DNS1: 192.168.5.254
[08:50:51][I][wifi:377]: DNS2: 0.0.0.0
[08:50:51][I][uptime.sensor:030]: Uptime Sensor 'ESP32-K4 Uptime'
[08:50:51][I][uptime.sensor:030]: State Class: 'total_increasing'
[08:50:51][I][uptime.sensor:030]: Unit of Measurement: 's'
[08:50:51][I][uptime.sensor:030]: Accuracy Decimals: 0
[08:50:51][D][uptime.sensor:030]: Icon: 'mdi:timer-outline'
[08:50:51][I][logger:193]: Logger:
[08:50:51][I][logger:194]: Level: DEBUG
[08:50:51][I][logger:195]: Log Baud Rate: 0
[08:50:51][I][logger:196]: Hardware UART: UART0
[08:50:51][I][dallas.sensor:072]: DallasComponent:
[08:50:51][I][dallas.sensor:073]: Pin: GPIO32 (Mode: OUTPUT)
[08:50:51][I][dallas.sensor:074]: Update Interval: 60.0s
[08:50:51][I][dallas.sensor:079]: Found sensors:
[08:50:51][I][dallas.sensor:082]: 0x05031997797BF828
[08:50:51][I][dallas.sensor:087]: Device 'Test temp'
[08:50:51][I][dallas.sensor:087]: Device Class: 'temperature'
[08:50:51][I][dallas.sensor:087]: State Class: 'measurement'
[08:50:51][I][dallas.sensor:087]: Unit of Measurement: '°C'
[08:50:51][I][dallas.sensor:087]: Accuracy Decimals: 1
[08:50:51][I][dallas.sensor:095]: Address: 0x05031997797BF828
[08:50:51][I][dallas.sensor:096]: Resolution: 12
[08:50:51][I][ota:029]: Over-The-Air Updates:
[08:50:51][I][ota:030]: Address: 192.168.30.110:3232
[08:50:51][I][api:135]: API Server:
[08:50:51][I][api:136]: Address: 192.168.30.110:6053
[08:50:51][I][wifi_signal.sensor:009]: WiFi Signal 'ESP32-K4 WiFi Signal'
[08:50:51][I][wifi_signal.sensor:009]: Device Class: 'signal_strength'
[08:50:51][I][wifi_signal.sensor:009]: State Class: 'measurement'
[08:50:51][I][wifi_signal.sensor:009]: Unit of Measurement: 'dBm'
[08:50:51][I][wifi_signal.sensor:009]: Accuracy Decimals: 0
[08:50:54][I][api:095]: Accepted 192.168.30.121
[08:50:54][I][api.connection:727]: Home Assistant 2021.9.7 (192.168.30.121): Connected successfully
[08:50:54][I][foo:0]: Current sensor values: **
[08:50:54][I][sensor:121]: 'ESP32-K4 Uptime': 52.00200 s with 0 decimals of accuracy **
[08:50:54][I][dallas.sensor:153]: 'Test temp': Got Temperature=20.8°C **
[08:50:54][I][sensor:121]: 'Test temp': 20.75000 °C with 1 decimals of accuracy **
[08:51:40][D][sensor:121]: 'ESP32-K4 Uptime': Sending state 52.00200 s with 0 decimals of accuracy
[08:51:46][D][dallas.sensor:153]: 'Test temp': Got Temperature=20.8°C
[08:51:46][D][sensor:121]: 'Test temp': Sending state 20.75000 °C with 1 decimals of accuracy
```
Note the jump in time between 08:50 and 08:51 where normally the first measurements are.
**Please describe your use case for this integration and alternatives you've tried:**
No alternatives exist
**Additional context**
None
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the logger configuration and the component log calls represented in the issue's ESPHome output, including sensor startup and recurring measurements. Compare INFO and DEBUG behavior against the proposed examples; done means INFO provides startup/configuration and an initial sensor value, while repetitive measurements remain at DEBUG and the C tag is removed or reassigned.
Written by the indexing model from the issue text.
Assessment
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100