bgulla / apcupsd-mqtt

Post APCUPSD ups data to MQTT Brokers. Home-Assistant
5 stars 10 forks source link

ModuleNotFoundError: No module named 'pyfiglet' #2

Open CWempe opened 4 years ago

CWempe commented 4 years ago

Thanks for this image.

But there seems to be an issue.

$ docker logs -f apcupsd-mqtt
Traceback (most recent call last):
  File "/src/apcupsd-mqtt.py", line 9, in <module>
    import pyfiglet
ModuleNotFoundError: No module named 'pyfiglet'

I could fix this by adding pyfiglet to requirements.txt.

Do you want me to create a PR?

877dev commented 3 years ago

Hi @CWempe

Same issue here, fixed by adding to requirements.txt, thanks for the tip. Now having this:

image

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

CWempe commented 3 years ago

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

877dev commented 3 years ago

@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
CWempe commented 3 years ago

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 #.

877dev commented 3 years ago

Thank you, I'll keep trying 👍🏻

bgulla commented 3 years ago

@CWempe PR's welcome!

877dev commented 3 years ago

@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...

CWempe commented 3 years ago

@877dev

It looks like you did not change any value of the settings.

  1. I am not sure socket.gethostname() works if you define it yourself outside the source code.
  2. If you use the default settings I do not think you even need to set these.
    Have you tried without apcupsd-mqtt.env?
877dev commented 3 years ago

@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?

CWempe commented 3 years ago

You are aware you need to run a separate apcupsd?

This docker container only is a bridge between the aspupsd and an mqtt broker.

877dev commented 3 years ago

Erm.. nope! That is likely a contributing factor 😄

I suppose there are other ways to bridge apcupsd to mqtt as well then..