Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_FROM
ARG BUILD_FROM=homeassistant/amd64-base:latest
FROM $BUILD_FROM

WORKDIR /app
Expand Down
41 changes: 41 additions & 0 deletions doc/Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Building and running `batmon-ha` via Docker

## Step #1: Build the Docker image

If you are building for a regular x86 ('amd64') architecture run:

git clone https://github.com/fl4p/batmon-ha.git
cd batmon-ha
docker buildx build --build-arg BUILD_FROM=homeassistant/amd64-base:latest -t batmon-ha "."


If you're building `homeassistant/amd64-base:latest` with `homeassistant/aarch64-base:latest` if you're building for an Raspberry Pi.


## Step #2: Create the base configuration

Create a `options.json` configuration file, i.e. in the `batmon-ha` folder.
Use the provided example `doc/options.json.template` and adjust as needed.
Refer to the configuration section in `README.md` for more information.

cp doc/options.json.template options.json
nano options.json


### Step #3a: Run container manually

docker run -d --privileged --restart unless-stopped --name batmon-ha -v /var/run/dbus/:/var/run/dbus/:z -v $PWD/options.json:/data/options.json:ro batmon-ha

### Step #3b: Run via docker-compose

You can also declare `batmon-ha` via an entry in your `docker-compose` file, i.e.:

batmon-ha:
container_name: batmon-ha
image: batmon-ha
restart: unless-stopped
privileged: true
volumes:
- /path/tooptions.json:/app/options.json:ro
- /var/run/dbus/:/var/run/dbus/:z

45 changes: 2 additions & 43 deletions doc/Standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,8 @@ cd batmon-ha
pip3 install -r requirements.txt
```

Create `options.json` within the `batmon-ha` directory. Use this as an example and adjust as needed:
```
{
"devices": [
{
"address": "",
"type": "daly",
"alias": "daly1"
},
{
"address": "",
"type": "jk",
"alias": "jk1"
},
{
"address": "",
"type": "jbd",
"alias": "jbd1"
},
{
"address": "",
"type": "victron",
"alias": "victron1",
"pin": "000000"
}
],
"mqtt_broker": "homeassistant.local",
"mqtt_user": "pv",
"mqtt_password": "Offgrid",
"concurrent_sampling": false,
"keep_alive": true,
"sample_period": 1.0,
"publish_period": 1.0,
"invert_current": false,
"expire_values_after": 20,
"verbose_log": false,
"watchdog": false
}
```
Create `options.json` within the `batmon-ha` directory.
Use the provided example `doc/options.json.template` and adjust as needed.

Then start:
```
Expand Down Expand Up @@ -74,7 +37,3 @@ Place this file to `/etc/systemd/system/batmon.service` and enable to start on b
systemctl enable batmon.service
systemctl start batmon.service
```


# Docker
Small modifications are needed to run this inside Docker, see https://github.com/fl4p/batmon-ha/issues/25#issuecomment-1400900525
36 changes: 36 additions & 0 deletions doc/options.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"devices": [
{
"address": "<device bluetooth MAC address>",
"type": "<jk|jbd|daly|victron|dummy>",
"alias": "<name displayed in HomeAssistant>"
"pin": "<for device requiring a PIN like victron>"
},
{
"address": "C8:47:8C:E4:55:E5",
"type": "jk",
"alias": "jk_bms1"
},
{
"address": "C8:47:8C:E4:55:E5",
"type": "jk",
"alias": "jk_bms2"
},
{
"address": "jk_bms1,jk_bms2",
"type": "group_parallel",
"alias": "jk_battery_group1"
}
],
"mqtt_broker": "homeassistant.local",
"mqtt_user": "pv",
"mqtt_password": "Offgrid",
"concurrent_sampling": false,
"keep_alive": false,
"sample_period": 60.0,
"publish_period": 60.0,
"invert_current": false,
"expire_values_after": 120,
"verbose_log": false,
"watchdog": true
}
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv bashio
#!/usr/bin/with-contenv /bin/bash

python3 install_bleak.py
python3 main.py
Expand Down