kizniche / Mycodo

An environmental monitoring and regulation system
http://kylegabriel.com/projects/
GNU General Public License v3.0
3k stars 500 forks source link

Installing RPi Power Monitor breaks Mycodo #1399

Open zannis opened 3 weeks ago

zannis commented 3 weeks ago

Describe the problem/bug

Installing RPi Power Monitor breaks mycodo cause theres dependency conflicts between the library and mycodo, when mycodo installs these deps for influxdb and urllib to satisfy rpi-power-monitor, all calls to get measurements from influxdb fail on urllib with : unexpected keyword argument 'key_key_password'

In my case what fixed it was deleting rpi power monitor input and reinstalling mycodo so that the correct dependencies were reinstalled. During installation, the dependency conflict on influxdbclient and urllib between mycodo and rpi monitor was pointed out by the installer.

Versions:

Reproducibility

  1. Set up an input with any kind of measurement (in my case SCD40 sensor)
  2. Check fetching measurements works
  3. Install RPi power monitor
  4. Restart Mycodo
  5. Measurements break

Expected behavior

Nothing breaks

Error log

2024-10-31 18:56:05,032 - ERROR - mycodo.controllers.controller_pid_b5b9956e - Exception while reading measurement from the influxdb database
Traceback (most recent call last):
  File "/opt/Mycodo/mycodo/controllers/controller_pid.py", line 439, in get_last_measurement_pid
    last_measurement = read_influxdb_single(
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/mycodo/utils/influx.py", line 372, in read_influxdb_single
    data = query_string(
           ^^^^^^^^^^^^^
  File "/opt/Mycodo/mycodo/utils/influx.py", line 301, in query_string
    ret_value = query_flux(
                ^^^^^^^^^^^
  File "/opt/Mycodo/mycodo/utils/influx.py", line 286, in query_flux
    tables = client.query_api().query(query)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/client/query_api.py", line 203, in query
    response = self._query_api.post_query(org=org, query=self._create_query(query, self.default_dialect, params),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/service/query_service.py", line 285, in post_query
    (data) = self.post_query_with_http_info(**kwargs)  # noqa: E501
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/service/query_service.py", line 311, in post_query_with_http_info
    return self.api_client.call_api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/_sync/api_client.py", line 343, in call_api
    return self.__call_api(resource_path, method,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/_sync/api_client.py", line 121, in __call_api
    self._signin(resource_path=resource_path)
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/_sync/api_client.py", line 657, in _signin
    http_info = SigninService(self).post_signin_with_http_info()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/service/signin_service.py", line 74, in post_signin_with_http_info
    return self.api_client.call_api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/_sync/api_client.py", line 343, in call_api
    return self.__call_api(resource_path, method,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/_sync/api_client.py", line 173, in __call_api
    response_data = self.request(
                    ^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/_sync/api_client.py", line 388, in request
    return self.rest_client.POST(url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/_sync/rest.py", line 311, in POST
    return self.request("POST", url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/influxdb_client/_sync/rest.py", line 186, in request
    r = self.pool_manager.request(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/urllib3/request.py", line 70, in request
    return self.request_encode_body(method, url, fields=fields,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/urllib3/request.py", line 150, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/urllib3/poolmanager.py", line 313, in urlopen
    conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/urllib3/poolmanager.py", line 229, in connection_from_host
    return self.connection_from_context(request_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/urllib3/poolmanager.py", line 240, in connection_from_context
    pool_key = pool_key_constructor(request_context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/Mycodo/env/lib/python3.11/site-packages/urllib3/poolmanager.py", line 105, in _default_key_normalizer
    return key_class(**context)
           ^^^^^^^^^^^^^^^^^^^^
TypeError: PoolKey.__new__() got an unexpected keyword argument 'key_key_password'