forked from sthope/battery2mqtt
		
	commit
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
FROM python:3-alpine
 | 
			
		||||
MAINTAINER Tediore <tediore.maliwan@gmail.com>
 | 
			
		||||
MAINTAINER sthopeless <hopelessautomations@gmail.com>
 | 
			
		||||
 | 
			
		||||
ADD battery2mqtt.py /
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -9,14 +9,14 @@ I thought of this project when I switched to using my old laptop as my Home Assi
 | 
			
		||||
# Instructions
 | 
			
		||||
 | 
			
		||||
**Option 1: Manual build**
 | 
			
		||||
1. Clone repo: `git clone https://github.com/Tediore/battery2mqtt`
 | 
			
		||||
1. Clone repo: `git clone https://github.com/sthopeless/battery2mqtt`
 | 
			
		||||
2. Enter directory: `cd battery2mqtt`
 | 
			
		||||
3. Build image: `docker build . -t battery2mqtt`
 | 
			
		||||
4. Customize `docker-compose.yaml` to fit your needs
 | 
			
		||||
5. `docker-compose up -d`
 | 
			
		||||
 | 
			
		||||
**Option 2: Docker Hub**
 | 
			
		||||
1. Follow steps 4 and 5 above using `tediore/battery2mqtt:latest` as the image.
 | 
			
		||||
1. Follow steps 4 and 5 above using `sthopeless/battery2mqtt:latest` as the image.
 | 
			
		||||
 | 
			
		||||
Example docker-compose.yaml with all possible environmental variables listed:
 | 
			
		||||
```yaml
 | 
			
		||||
@@ -61,7 +61,7 @@ docker run --name battery2mqtt \
 | 
			
		||||
-e AC_ADAPTER=1 \
 | 
			
		||||
-e LOG_LEVEL=info \
 | 
			
		||||
-v /sys/class/power_supply:/sys/class/power_supply:ro \
 | 
			
		||||
tediore/battery2mqtt:latest
 | 
			
		||||
sthopeless/battery2mqtt:latest
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
# Configuration
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										16
									
								
								battery2mqtt.env
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								battery2mqtt.env
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
#TAG=latest
 | 
			
		||||
 | 
			
		||||
MQTT_HOST=mqtt-broker-ip
 | 
			
		||||
MQTT_USERNAME=username
 | 
			
		||||
MQTT_PASSWORD=password
 | 
			
		||||
 | 
			
		||||
#MQTT_PORT=1883
 | 
			
		||||
#MQTT_TOPIC=battery2mqtt
 | 
			
		||||
 | 
			
		||||
### Choose one
 | 
			
		||||
#LOG_LEVEL=info
 | 
			
		||||
#LOG_LEVEL=debug
 | 
			
		||||
#LOG_LEVEL=warning
 | 
			
		||||
#LOG_LEVEL=error
 | 
			
		||||
 | 
			
		||||
#SENSORS=status,capacity,energy_now,energy_full,energy_full_design,power_now,voltage_now
 | 
			
		||||
@@ -1,20 +1,23 @@
 | 
			
		||||
---
 | 
			
		||||
version: "3.8"
 | 
			
		||||
services:
 | 
			
		||||
  battery2mqtt:
 | 
			
		||||
    container_name: battery2mqtt
 | 
			
		||||
    image: tediore/battery2mqtt:latest
 | 
			
		||||
    image: sthopeless/battery2mqtt:${TAG-latest}
 | 
			
		||||
    environment:
 | 
			
		||||
    - MQTT_HOST=10.0.0.2
 | 
			
		||||
    - MQTT_PORT=1883
 | 
			
		||||
    - MQTT_USER=user
 | 
			
		||||
    - MQTT_PASSWORD=password
 | 
			
		||||
    - MQTT_TOPIC=server
 | 
			
		||||
    - MQTT_QOS=1
 | 
			
		||||
    - INTERVAL=60
 | 
			
		||||
    - MONITORED_CONDITIONS=status,capacity,energy_now,energy_full,energy_full_design,power_now,voltage_now
 | 
			
		||||
    - BATTERY_HEALTH=1
 | 
			
		||||
    - TIME_REMAINING=1
 | 
			
		||||
    - SHOW_UNITS=1
 | 
			
		||||
    - AC_ADAPTER=1
 | 
			
		||||
    - LOG_LEVEL=info
 | 
			
		||||
      - MQTT_HOST=${MQTT_HOST}
 | 
			
		||||
      - MQTT_PORT=${MQTT_PORT-1883}
 | 
			
		||||
      - MQTT_USER=${MQTT_USERNAME}
 | 
			
		||||
      - MQTT_PASSWORD=${MQTT_PASSWORD}
 | 
			
		||||
      - MQTT_TOPIC=${MQTT_TOPIC-battery2mqtt}
 | 
			
		||||
      - MQTT_QOS=1
 | 
			
		||||
      - INTERVAL=60
 | 
			
		||||
      - MONITORED_CONDITIONS=${SENSORS-status,capacity,energy_now,energy_full,energy_full_design,power_now,voltage_now}
 | 
			
		||||
      - BATTERY_HEALTH=1
 | 
			
		||||
      - TIME_REMAINING=1
 | 
			
		||||
      - SHOW_UNITS=1
 | 
			
		||||
      - AC_ADAPTER=1
 | 
			
		||||
      - LOG_LEVEL=${LOG_LEVEL-info}
 | 
			
		||||
    volumes:
 | 
			
		||||
    - /sys/class/power_supply:/sys/class/power_supply:ro
 | 
			
		||||
      - /sys/class/power_supply:/sys/class/power_supply:ro
 | 
			
		||||
    restart: unless-stopped
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user