bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances
MIT License
927 stars 246 forks source link

Errors when Running Measure Tool in Docker #438

Closed IIAIronWolf closed 2 years ago

IIAIronWolf commented 2 years ago

I have been unsuccessful in running the Measure tool in both python and Docker. Currently, this is what I am getting when trying to run in Docker:

C:\powercalc\utils\measure>docker run --rm --name=measure --env-file=.env -v %CD%/export:/app/export -v %CD%/.persistent:/app/.persistent -it bramgerritsen/powercalc-measure:latest
Powercalc measure: v0.13.2

2021-12-20 00:31:14,755 [INFO] Selected powermeter: manual
2021-12-20 00:31:14,755 [INFO] Selected Light controller: hue
2021-12-20 00:31:14,755 [INFO] Attempting to connect to the bridge...
2021-12-20 00:31:14,759 [INFO] Error opening config file, will attempt bridge registration
Please click the link button on the bridge, than hit enter..

2021-12-20 00:31:15,883 [INFO] Attempting to connect to the bridge...
2021-12-20 00:31:15,886 [INFO] Error opening config file, will attempt bridge registration
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/phue.py", line 735, in connect
    with open(self.config_file_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/app/light_controller/../.persistent/.python_hue'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/light_controller/hue.py", line 64, in initialize_hue_bridge
    bridge = Bridge(ip=bridge_ip, config_file_path=config_file_path)
  File "/usr/local/lib/python3.8/site-packages/phue.py", line 628, in __init__
    self.connect()
  File "/usr/local/lib/python3.8/site-packages/phue.py", line 751, in connect
    self.register_app()
  File "/usr/local/lib/python3.8/site-packages/phue.py", line 718, in register_app
    raise PhueRegistrationException(error_type,
phue.PhueRegistrationException: (101, 'The link button has not been pressed in the last 30 seconds.')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/phue.py", line 735, in connect
    with open(self.config_file_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/app/light_controller/../.persistent/.python_hue'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "measure.py", line 515, in <module>
    main()
  File "measure.py", line 505, in main
    light_controller = light_controller_factory.create()
  File "measure.py", line 452, in create
    return factory()
  File "measure.py", line 443, in hue
    return HueLightController(HUE_BRIDGE_IP)
  File "/app/light_controller/hue.py", line 17, in __init__
    self.bridge = self.initialize_hue_bridge(bridge_ip)
  File "/app/light_controller/hue.py", line 68, in initialize_hue_bridge
    bridge = Bridge(ip=bridge_ip, config_file_path=config_file_path)
  File "/usr/local/lib/python3.8/site-packages/phue.py", line 628, in __init__
    self.connect()
  File "/usr/local/lib/python3.8/site-packages/phue.py", line 751, in connect
    self.register_app()
  File "/usr/local/lib/python3.8/site-packages/phue.py", line 718, in register_app
    raise PhueRegistrationException(error_type,
phue.PhueRegistrationException: (101, 'The link button has not been pressed in the last 30 seconds.')

The script seems to start correctly but complains about non-existent phue.py and being unable to open the config file. Any suggestions?

bramstroker commented 2 years ago

It expects a file /app/light_controller/../.persistent/.python_hue which contains the token from the bridge, so you don't have to click the link button each time again. This file should be written by the phue library on connection to the hue bridge.

Did you click the link button? Because the exception also says: "The link button has not been pressed in the last 30 seconds"?

bramstroker commented 2 years ago

Do you still have this issue? Did you see my comments?

bramstroker commented 2 years ago

Closed due to inactivity, please let me know if you have any update, than we can have another look / reopen the issue.

IIAIronWolf commented 2 years ago

My apologies, I have been away with COVID. I guess I wasn't pressing the link button hard enough or something. I am able to get it working on Docker now.

bramstroker commented 2 years ago

I'm sorry for you, did you recover fully? Hope we can leave the COVID pandamic behind us soon. Glad you got the measure script working. Do you plan into contributing lights into the repo?

IIAIronWolf commented 2 years ago

I'm sorry for you, did you recover fully? Hope we can leave the COVID pandamic behind us soon.

Glad you got the measure script working. Do you plan into contributing lights into the repo?

Thank ya! Just a sore throat now. And you and I both!

I just ordered some power measuring smart plugs and will contribute my lights whenever I get them. I have Philips hue LCA002, LCA003's, LWB014's, LCT014, and some Wyze bulbs and LIFX bulbs

bramstroker commented 2 years ago

That's awesome mate!