ESPHome logger => to a file

Hi, i am using esphome, how can we view the log files? you can see the logfile in the add-on, but where is output log file created? is there any? its easier for debugging

thnx a lot

As i said in the other thread where you asked,

ephome switch.yaml logs

So if you want to save the log file

esphome switch.yaml logs > switch.log

Thnx , will try it out

where do i need to enter that command? if i ssh to HA, it doesnt work :slight_smile:
command not found => esphome

I assume you are using the addon? If so enter the docker container

docker exec -it name or id of docker container /bin/bash

yeah, i need to turn off protection mode for that add-on, but seems that one doesnt have a protection mode like other add-ons that i can turn off …

docker exec -it a0d7b954_esphome /bin/bash

You need to turn off protection on the ssh addon not the esphome addon.

1 Like

Also if after entering the addon with docker exec you can change to the esphome directory so that your yaml files are all there and the logs get saved to that directory, which is not destroyed when the addon is restarted.

cd config/esphome
1 Like

@nickrout

trying it out, still one question, when i try to run the command below with the .log file, the esphome doesnt start, it needs an option to start , i need to press a number first, as you can see in the log file
If i start without the log file, i can enter offcourse the number, but then i have no log file :slight_smile:
how can i force it to choose option 2 when starting the esphome?

esphome esp.yaml logs > esphome.log

Found multiple options, please choose one:
  [1] /dev/ttyUSB0 (FT230X Basic UART)
  [2] Over The Air (192.168.0.22)
(number):

i dont see an option for it, when i just run “esphome”

ok, found it :

esphome esp.yaml logs > esphome.log --serial-port OTA

1 Like

Is there a way to do this when running HassOS with the esphome addon?
I have an issue with some ds18b20 sensors randomly giving checksum failures but by the time i get to view the esphome logs the sensors are back so I can never tell which ones bugged out. If I could save the esphome log history to a file or ouotput to a syslog server or similar then I could go back through the history as needed.

Exactly the same. Enter the docker container, then run that command.

hi @nickrout, sorry to revive old topic - would this apply to proxmox installed supervised home assistant? I tried docker exec -it (cont ID) /bin/bash - this doesn’t work at all - says no container with this id.

thanks!

Then I suspect you have the wrong id.

100% right. I have run another command and got different (valid) ID.

thanks!

1 Like

What is the easiest way to stop writing logs to a file? Maybe restarting the addon?

Same as stopping any other program at the commandline, ctrl-c

Yeah, but if you close the docker session, the process remains opened.

I guess you should kill the process looking for it with ps -e, but you have to install ‘ps’ first because is not installed by default.

So, this is why my question. Is there any simpler way to stop recording logs?

I see, yes. Maybe killall ephome

Thanks that works! Although in the future the command needs to be adjusted I guess because I got a deprecated warning:

esphome esp32-07-desk-control.yaml logs > esp32-07-desk-control.log --serial-port OTA

#WARNING Calling ESPHome with the configuration before the command is deprecated and will be removed in the future. 
#WARNING Please instead use:
#WARNING    esphome logs esp32-07-desk-control.yaml --device OTA

I am still wondering how to stop logging? Does killall esphome work? Is it safe to use … I do not want to destroy anything else …

1 Like