I’m rather new to Linux, so here’s my question :
each time I want to start esphome Dashboard I need to type in “esphome config/ dashboard”
What do I need to do so that the esphome dashboard starts automatically on my linux system?
I’m rather new to Linux, so here’s my question :
each time I want to start esphome Dashboard I need to type in “esphome config/ dashboard”
What do I need to do so that the esphome dashboard starts automatically on my linux system?
I would use systemd
What Linux?
Debian
so lets see if I’m right :
first create a file in /etc/system/system : “esphomeDashboard.service”
add following to the file :
[Unit]
Description= ESPHome Dashboard
After=network-online.target
[Service]
Type=simple
User=%i
ExecStart=/usr/local/bin/esphome config/ dashboard
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
then a : sudo systemctl --system daemon-reload
after that enable the service : sudo systemctl enable espHomeDashboard
And then after a reboot it should work, right?
3 questions :
thanks for any help…
edit : ok, the above seems to work after a reboot I can access the dashboard, but now it seems that although the configured Sonoff switch (with espHome) is still working inside my Home Assistant, it doesn’t appear on my ESPHome Dashboard.
ESPHome Dashboard even says that the are no nodes configured yet, like the first time you setup ESPHome
What could be wrong here?
You might need to set the working directory for the service:
WorkingDirectory=/home/wherever_your_config_is
Should be in the line after [service]
Or add the full path to the config directory in the line above.
Hello guys!
I was not able to use ESPHome as a systemd because of the following error:
FileNotFoundError: [Errno 2] No such file or directory: ‘esphome’: ‘esphome’
Until I added Environment=PATH
under [Service]
section:
[Service]
Environment=PATH=/srv/homeassistant/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Notice the /srv/homeassistant/bin
in PATH - that’s my virtualenv
directory for ESPHome anf Home Assistant…
My working configuration on Debian:
/etc/systemd/system/esphomeDashboard.service
[Unit]
Description= ESPHome Dashboard
After=network-online.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/esphome /root/config/ dashboard
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
After file is created , run
systemctl daemon-reload && systemctl start esphomeDashboard.service
hello,
I cannot find why my esphome cannot autostart / start when i make ’ systemctl start esphomeDashboard.service’ i get error like this:
Failed to start esphomeDashboard.service: Unit esphomeDashboard.service has a bad unit file setting.
Here my /etc/systemd/system/esphomeDashboard.service file:
[Unit]
Description= ESPHome Dashboard
After=network-online.target
[Service]
Type=simple
User=%i
ExecStart=/usr/local/bin/esphome config/ dashboard
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Anybody can help me please?
what is
config/
supposed to do?
directory for esphome nodes configuration.
No it is not. see esphome --help
root@nuccy:/config# esphome --help
usage: esphome [-h] [-v] [-q]
[configuration [configuration ...]]
{config,compile,upload,logs,run,clean-mqtt,wizard,mqtt-fingerprint,version,clean,dashboard,vscode,update-all}
...
ESPHome v1.14.3
positional arguments:
configuration Your YAML configuration file.
{config,compile,upload,logs,run,clean-mqtt,wizard,mqtt-fingerprint,version,clean,dashboard,vscode,update-all}
Commands
config Validate the configuration and spit it out.
compile Read the configuration and compile a program.
upload Validate the configuration and upload the latest
binary.
logs Validate the configuration and show all MQTT logs.
run Validate the configuration, create a binary, upload
it, and start MQTT logs.
clean-mqtt Helper to clear an MQTT topic from retain messages.
wizard A helpful setup wizard that will guide you through
setting up esphome.
mqtt-fingerprint Get the SSL fingerprint from a MQTT broker.
version Print the esphome version and exit.
clean Delete all temporary build files.
dashboard Create a simple web server for a dashboard.
vscode ==SUPPRESS==
update-all ==SUPPRESS==
optional arguments:
-h, --help show this help message and exit
-v, --verbose Enable verbose esphome logs.
-q, --quiet Disable all esphome logs.
Now I am confused though. My docker install is running
root@nuccy:/config# ps ax
PID TTY STAT TIME COMMAND
1 pts/0 Ssl+ 72:51 /usr/bin/python3 /usr/local/bin/esphome /config dashboard
37 pts/0 S+ 0:00 /usr/bin/python3 /usr/local/bin/esphome --dashboard -q /config vscode --ace
Yet config/ or /config is undocumented.
Setup systemd unit file with virtualenv and pip.
You will need python-virtualenv and python-pip packets installed.
sudo useradd --home-dir=/opt/esphome --create-home esphome
sudo su - esphome
virtualenv --python=python3 ENV
source ENV/bin/activate
pip install esphome
[Unit]
Description=esphome
After=network.target
[Service]
Type=simple
User=esphome
WorkingDirectory=/opt/esphome
ExecStart=/opt/esphome/ENV/bin/python /opt/esphome/ENV/bin/esphome config/ dashboard
RestartSec=30
Restart=on-failure
Environment="PATH=/opt/esphome/ENV/bin"
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start esphome.service
systemctl status esphome.service
systemctl enable esphome.service
Thanks for sharing this.
I thought I would share the addition I had to make in order to make it work.
Not sure if it is because of my linux distrib or the new version of platformio, but I had to add a bit more in the PATH
variable:
Environment="PATH=/opt/esphome/ENV/bin:/usr/local/sbin:/usr/local/bin:/usr/bin"
Otherwise it would not compile properly on the beta version at least (esphome v1.15.0b4)
For anyone on a rPi my working service is:
[Unit]
Description= ESPHome Dashboard
After=network.target
[Service]
WorkingDirectory=/home/pi/config
User=pi
ExecStart=/home/pi/.local/bin/esphome config dashboard
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Then:
sudo systemctl daemon-reload && sudo systemctl start esphomeDashboard.service
this works for me and compiling is working.
and no erros in the log of the service:
sudo systemctl status esphomeDashboard.service
[Unit]
Description= ESPHome Dashboard
After=network.target
[Service]
WorkingDirectory=/home/pi
User=pi
ExecStart=/home/pi/.local/bin/esphome config dashboard
Restart=on-failure
RestartSec=5s
Environment="PATH=/home/pi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games"
[Install]
WantedBy=multi-user.target
Really useful, thanks. I have made a couple of adjustments - this is on a Raspberry OS 64 bit system. Main thing is that you should not put the service
file in /etc/systemd/system/
as if you use systemctl delete
it will remove the service file completely.
NOTE Edited original post
Commands from clean install of PiOS
sudo apt-get update
sudo apt-get -y upgrade
sudo apt install python3-pip python3-venv
sudo useradd --home-dir=/opt/esphome --create-home esphome
sudo su - esphome
python3 -m venv venv
source venv/bin/activate
pip install esphome
Create a small script to start the dashboard
nano start.sh
with
#!/bin/bash
source venv/bin/activate
esphome dashboard /opt/esphome/config/
set as executable
chmod +x start.sh
Then exit the esphome
user and create the service
file.
sudo nano /lib/systemd/system/esphomedashboard.service
with is file contents
[Unit]
Description=ESPHome Dashboard Service
After=network.target
[Service]
Type=simple
User=esphome
WorkingDirectory=/opt/esphome
ExecStart=/opt/esphome/start.sh
RestartSec=30
Restart=on-failure
[Install]
WantedBy=multi-user.target
Then to activate
sudo systemctl daemon-reload
sudo systemctl start esphomedashboard.service
systemctl status esphomedashboard.service
If you want it to start at boot;
sudo systemctl enable esphomedashboard.service
If you are looking for the config files, they will be found in /opt/esphome/config/
The above works on 64bit PiOS, if you want to do it on 32bit PiOS you need to install libssl-dev
and rust;
sudo apt-get update
sudo apt-get -y upgrade
sudo apt install -y python3-pip python3-venv libssl-dev
sudo useradd --home-dir=/opt/esphome --create-home esphome
sudo su - esphome
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
rustc --version
python3 -m venv venv
source venv/bin/activate
pip install esphome
Does anyone know how to update esphome
when setup like this (I’m not used to VENVs)?
I’d like to use a script or just a cron
job to update it.
anyone using systemd in Kali linux running in WSL?
I had to rework just a bit to make it work on ubuntu 22.04 in a mini-pc.
[Unit]
Description= ESPHome Dashboard
After=network.target
[Service]
Type=simple
User=esphome
#ExecStart=/usr/local/bin/esphome /administrator/config/ dashboard
ExecStart=/opt/esphome/.local/bin/esphome dashboard /opt/esphome/config/
Restart=on-failure
RestartSec=30
Environment="PATH=/opt/esphome/.local/bin"
[Install]
WantedBy=multi-user.target