evcc does not provide an metric endpoint for prometheus (see evcc discussion #7306).
With pollect, its easy to publish the evcc data for prometheus.
Setup account, pollect and systemd service config on Debian 12:
# add system user
adduser --system --home /opt/pollect pollect
# install Python venv (instead of using pip directly)
apt install python3-venv
# change to pollect user
su - pollect -s /bin/bash
# setup venv
python3 -m venv /opt/pollect/.venv
# install pollect
/opt/pollect/.venv/bin/pip install pollect
# install required library to connect to evcc
/opt/pollect/.venv/bin/pip install websocket-client
# create pollect config (see file below)
vim config.yml
# back to root
exit
# create systemd config (see file below)
vim /etc/systemd/system/pollect.service
# start service (test using curl http://localhost:8000/)
systemctl start pollect
# enable service
systemctl enable pollect
pollect config in /opt/pollect/config.yml
---
tickTime: 30
threads: 4
writer:
type: Prometheus
port: 8000
executors:
- collection: home_automation
tickTime: 120
sources:
- type: Evcc
host: localhost:7070
Systemd service config in /etc/systemd/system/pollect.service
[Unit]
Description=pollect
After=syslog.target network.target
[Service]
Type=simple
User=pollect
WorkingDirectory=/opt/pollect
ExecStart=/opt/pollect/.venv/bin/pollect -c /opt/pollect/config.yml
Restart=on-abort
[Install]
WantedBy=multi-user.target