Open CWempe opened 4 years ago
Hi @CWempe
Same issue here, fixed by adding to requirements.txt
, thanks for the tip.
Now having this:
Curious where you added your mqtt broker settings, direct in apcupsd-mqtt.py
?
Seems like there should be an ENV file maybe,
Here's my setup so far: https://gist.github.com/877dev/58b8b2dc57912eabda79a8acea293df7
I added the settings via environment variables to the container.
See. https://github.com/bgulla/apcupsd-mqtt/blob/master/src/apcupsd-mqtt.py#L22-L29
@CWempe thanks, I'm still learning how to use docker.
Something like this saved as apcupsd-mqtt.env
?
TZ=Europe/London
#MQTT_USER =
#MQTT_PASSWORD =
#MQTT_PORT = 1883
#MQTT_HOST = localhost
#INTERVAL = 15
#UPS_ALIAS = socket.gethostname()
#APCUPSD_HOST = 127.0.0.1
#LOG_LEVEL = logging.INFO
I am using docker run
and do not know about an .env file.
It seems to be a valid option.
"Environment variables in Compose | Docker Documentation" https://docs.docker.com/compose/environment-variables/
But i think you need to remove the #
.
Thank you, I'll keep trying 👍🏻
@CWempe PR's welcome!
@bgulla I don't mind submitting a PR for this one..
Can I ask regarding an error I am having in Portainer logs:
Traceback (most recent call last):
File "/src/apcupsd-mqtt.py", line 98, in <module>
main()
File "/src/apcupsd-mqtt.py", line 64, in main
ups = apc.parse(apc.get(host=APCUPSD_HOST))
File "/usr/local/lib/python3.9/site-packages/apcaccess/status.py", line 37, in get
sock.connect((host, port))
ConnectionRefusedError: [Errno 111] Connection refused
Here are my docker compose settings if you could cast a quick eye over them please: https://gist.github.com/877dev/58b8b2dc57912eabda79a8acea293df7
PS - my new BX1400UI is damaged on arrival, so I am testing this on an old BX900, I believe the software is the same though...
@877dev
It looks like you did not change any value of the settings.
socket.gethostname()
works if you define it yourself outside the source code.apcupsd-mqtt.env
?@CWempe I just tried without apcupsd-mqtt.env
and rebuilt, still same error.
I'm connecting to the APC via USB connection, maybe something there I need to do?
You are aware you need to run a separate apcupsd?
This docker container only is a bridge between the aspupsd and an mqtt broker.
Erm.. nope! That is likely a contributing factor 😄
I suppose there are other ways to bridge apcupsd to mqtt as well then..
Thanks for this image.
But there seems to be an issue.
I could fix this by adding
pyfiglet
torequirements.txt
.Do you want me to create a PR?