Dielee / volvo2mqtt

Home Assistant addon for connecting AAOS Volvos
MIT License
125 stars 25 forks source link

Cannot get it working in Unraid Docker #162

Closed timknowlden closed 4 months ago

timknowlden commented 5 months ago

Error log on unraid shows this:



During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/volvoAAOS2mqtt/./main.py", line 2, in <module>
    from volvo import authorize
  File "/volvoAAOS2mqtt/volvo.py", line 3, in <module>
    import mqtt
  File "/volvoAAOS2mqtt/mqtt.py", line 6, in <module>
    import util
  File "/volvoAAOS2mqtt/util.py", line 9, in <module>
    from const import units
  File "/volvoAAOS2mqtt/const.py", line 93, in <module>
    {"name": "Electric Range", "domain": "sensor", "id": "electric_range", "unit": LENGTH_KILOMETERS if not units.get(settings["babelLocale"]) else units[settings["babelLocale"]]["electric_range"]["unit"], "icon": "map-marker-distance", "url": RECHARGE_STATE_URL, "state_class": "measurement"},
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/functional.py", line 18, in inner
    self._setup()
  File "/usr/local/lib/python3.9/site-packages/dynaconf/base.py", line 174, in _setup
    self._wrapped = Settings(
  File "/usr/local/lib/python3.9/site-packages/dynaconf/base.py", line 253, in __init__
    self.execute_loaders()
  File "/usr/local/lib/python3.9/site-packages/dynaconf/base.py", line 1035, in execute_loaders
    core_loader.load(self, env, silent=silent, key=key)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/loaders/env_loader.py", line 33, in load
    load_from_env(obj, global_prefix, key, silent, IDENTIFIER + "_global")
  File "/usr/local/lib/python3.9/site-packages/dynaconf/loaders/env_loader.py", line 73, in load_from_env
    data = {
  File "/usr/local/lib/python3.9/site-packages/dynaconf/loaders/env_loader.py", line 74, in <dictcomp>
    key[trim_len:]: parse_conf_data(
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 379, in parse_conf_data
    return _parse_conf_data(data, tomlfy=tomlfy, box_settings=box_settings)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 343, in _parse_conf_data
    value = get_converter(converter_key, value, box_settings)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 275, in get_converter
    converted_value = converter(value)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 250, in <lambda>
    else json.loads(value),
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 70 (char 69)
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 273, in get_converter
    converted_value = converter(value, box_settings=box_settings)
TypeError: <lambda>() got an unexpected keyword argument 'box_settings'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/volvoAAOS2mqtt/./main.py", line 2, in <module>
    from volvo import authorize
  File "/volvoAAOS2mqtt/volvo.py", line 3, in <module>
    import mqtt
  File "/volvoAAOS2mqtt/mqtt.py", line 6, in <module>
    import util
  File "/volvoAAOS2mqtt/util.py", line 9, in <module>
    from const import units
  File "/volvoAAOS2mqtt/const.py", line 93, in <module>
    {"name": "Electric Range", "domain": "sensor", "id": "electric_range", "unit": LENGTH_KILOMETERS if not units.get(settings["babelLocale"]) else units[settings["babelLocale"]]["electric_range"]["unit"], "icon": "map-marker-distance", "url": RECHARGE_STATE_URL, "state_class": "measurement"},
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/functional.py", line 18, in inner
    self._setup()
  File "/usr/local/lib/python3.9/site-packages/dynaconf/base.py", line 174, in _setup
    self._wrapped = Settings(
  File "/usr/local/lib/python3.9/site-packages/dynaconf/base.py", line 253, in __init__
    self.execute_loaders()
  File "/usr/local/lib/python3.9/site-packages/dynaconf/base.py", line 1035, in execute_loaders
    core_loader.load(self, env, silent=silent, key=key)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/loaders/env_loader.py", line 33, in load
    load_from_env(obj, global_prefix, key, silent, IDENTIFIER + "_global")
  File "/usr/local/lib/python3.9/site-packages/dynaconf/loaders/env_loader.py", line 73, in load_from_env
    data = {
  File "/usr/local/lib/python3.9/site-packages/dynaconf/loaders/env_loader.py", line 74, in <dictcomp>
    key[trim_len:]: parse_conf_data(
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 379, in parse_conf_data
    return _parse_conf_data(data, tomlfy=tomlfy, box_settings=box_settings)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 343, in _parse_conf_data
    value = get_converter(converter_key, value, box_settings)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 275, in get_converter
    converted_value = converter(value)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 250, in <lambda>
    else json.loads(value),
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 70 (char 69)

** Press ANY KEY to close this window ** ```
timknowlden commented 5 months ago

Thats putting all this info here into extra parameters and replacing with my correct details: -e CONF_updateInterval=300 -e CONF_babelLocale='de' -e CONF_mqtt='@json {"broker": "", "username": "", "password": "", "port": 1883}' -e CONF_volvoData='@json {"username": "", "password": "", "vin": "", "vccapikey": ["key1", "key2"], "odometerMultiplier": 1, "averageSpeedDivider": 1, "averageFuelConsumptionMultiplier": 1}' -e TZ='Europe/Berlin'

timknowlden commented 5 months ago
image

also will not start if using variables like this, it says invalid host

Dielee commented 5 months ago

I'm not having any experience with unraid, so I can't help you, sorry.

EDIT: But in your config is @json in front of all jsons missing.

timknowlden commented 5 months ago

I have tried with ' before and after the variables, tried with '@json{variable}' too. Usually you'd add the variable as per the image.

timknowlden commented 5 months ago
Screenshot 2024-01-18 192631

It formats the docker template like so when adding that variables. which to me reads okay..

timknowlden commented 5 months ago

yet it will not start the docker container and gives these errors in the log

text  error  warn  system  array  login  

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 273, in get_converter
    converted_value = converter(value, box_settings=box_settings)
TypeError: <lambda>() got an unexpected keyword argument 'box_settings'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/volvoAAOS2mqtt/./main.py", line 2, in <module>
    from volvo import authorize
  File "/volvoAAOS2mqtt/volvo.py", line 3, in <module>
    import mqtt
  File "/volvoAAOS2mqtt/mqtt.py", line 6, in <module>
    import util
  File "/volvoAAOS2mqtt/util.py", line 9, in <module>
    from const import units
  File "/volvoAAOS2mqtt/const.py", line 93, in <module>
    {"name": "Electric Range", "domain": "sensor", "id": "electric_range", "unit": LENGTH_KILOMETERS if not units.get(settings["babelLocale"]) else units[settings["babelLocale"]]["electric_range"]["unit"], "icon": "map-marker-distance", "url": RECHARGE_STATE_URL, "state_class": "measurement"},
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/functional.py", line 18, in inner
    self._setup()
  File "/usr/local/lib/python3.9/site-packages/dynaconf/base.py", line 174, in _setup
    self._wrapped = Settings(
  File "/usr/local/lib/python3.9/site-packages/dynaconf/base.py", line 253, in __init__
    self.execute_loaders()
  File "/usr/local/lib/python3.9/site-packages/dynaconf/base.py", line 1035, in execute_loaders
    core_loader.load(self, env, silent=silent, key=key)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/loaders/env_loader.py", line 33, in load
    load_from_env(obj, global_prefix, key, silent, IDENTIFIER + "_global")
  File "/usr/local/lib/python3.9/site-packages/dynaconf/loaders/env_loader.py", line 73, in load_from_env
    data = {
  File "/usr/local/lib/python3.9/site-packages/dynaconf/loaders/env_loader.py", line 74, in <dictcomp>
    key[trim_len:]: parse_conf_data(
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 379, in parse_conf_data
    return _parse_conf_data(data, tomlfy=tomlfy, box_settings=box_settings)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 343, in _parse_conf_data
    value = get_converter(converter_key, value, box_settings)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 275, in get_converter
    converted_value = converter(value)
  File "/usr/local/lib/python3.9/site-packages/dynaconf/utils/parse_conf.py", line 250, in <lambda>
    else json.loads(value),
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 70 (char 69)

** Press ANY KEY to close this window ** 
timknowlden commented 5 months ago

I worked out my error in the docker template and now it is running..

however logs show this:


Jan 19 11:15:18 volvo2mqtt [1] - WARNING: VCCAPIKEY ae30345212684c21b0eb32b32b0df1c7 isn't working! Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
Jan 19 11:15:18 volvo2mqtt [1] - WARNING: VCCAPIKEY 00e219378a574d4f8348fad601bea753 isn't working! Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
Jan 19 11:15:18 volvo2mqtt [1] - WARNING: No working VCCAPIKEY found, waiting 10 minutes. Then trying again!

VCCAPI Key is correct though as set up here: https://developer.volvocars.com/account/

Do i need to publish the application or is it okay in testing?
Ilpo55 commented 5 months ago

Do i need to publish the application No Sometimes it takes some time before the API-key starts to work.

timknowlden commented 5 months ago

Do i need to publish the application No Sometimes it takes some time before the API-key starts to work.

Okay, I will wait an hour and see if working.

Will entities be created from the mqtt messages inside of home assistant or do i need to create these myself?

Ilpo55 commented 5 months ago

do i need to create these myself? No, if everything is working, entities will be created by Home Assistant.

timknowlden commented 5 months ago

1705658619: New client connected from 172.19.0.1:44204 as volvoAAOS2mqtt@.org (p2, c1, k60, u'mqtt'). 1705658619: Client volvoAAOS2mqtt@.org closed its connection.

Mosuqitto log, no entities inside of home assistant as it stands

Dielee commented 5 months ago

This seems to be a local issue. Are you using the ha addon ?

timknowlden commented 5 months ago

This seems to be a local issue. Are you using the ha addon ?

I'm on unraid, ha core container, mosquito container and volvo2mqtt container. It'd pulling entities in now, but all 'unknown'

timknowlden commented 5 months ago

Screenshot_20240120_081044_Home Assistant The controls do not work and haven't updated in 14 hours..

Dielee commented 5 months ago

Please enable debug an show me some logs.

timknowlden commented 5 months ago

Please enable debug an show me some logs.


text  error  warn  system  array  login  

Traceback (most recent call last):
  File "/volvoAAOS2mqtt/./main.py", line 16, in <module>
    update_loop()
  File "/volvoAAOS2mqtt/mqtt.py", line 215, in update_loop
    create_ha_devices()
  File "/volvoAAOS2mqtt/mqtt.py", line 326, in create_ha_devices
    device = volvo.get_vehicle_details(vin)
  File "/volvoAAOS2mqtt/volvo.py", line 235, in get_vehicle_details
    raise Exception("Getting vehicle details failed. Status Code: " + str(response.status_code) +
Exception: Getting vehicle details failed. Status Code: 401. Error: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
      "timestamp" : "2024-01-19T11:47:08.449Z"
    },
    "washerFluidLevelWarning" : {
      "value" : "NO_WARNING",
      "timestamp" : "2024-01-19T11:47:08.449Z"
    },
    "timeToService" : {
      "value" : 2,
      "unit" : "months",
      "timestamp" : "2024-01-19T11:47:08.449Z"
    }
  }
}
Jan 19 21:44:15 volvo2mqtt [1] - INFO: Success! Distance to Service is supported by your vehicle.
Jan 19 21:44:15 volvo2mqtt [1] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/diagnostics
Jan 19 21:44:15 volvo2mqtt [1] - DEBUG: Response status code: 401
Jan 19 21:44:15 volvo2mqtt [1] - DEBUG: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Jan 19 21:44:15 volvo2mqtt [1] - ERROR: API Call failed. Status Code: 401. Error: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Jan 19 21:44:15 volvo2mqtt [1] - INFO: Failed, Time to Service is unfortunately not supported by your vehicle.
Jan 19 21:44:15 volvo2mqtt [1] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/diagnostics
Jan 19 21:44:15 volvo2mqtt [1] - DEBUG: Response status code: 401
Jan 19 21:44:15 volvo2mqtt [1] - DEBUG: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Jan 19 21:44:15 volvo2mqtt [1] - ERROR: API Call failed. Status Code: 401. Error: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Jan 19 21:44:15 volvo2mqtt [1] - INFO: Failed, Service warning status is unfortunately not supported by your vehicle.
Jan 19 21:44:15 volvo2mqtt [1] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/diagnostics
Jan 19 21:44:15 volvo2mqtt [1] - DEBUG: Response status code: 200
Jan 19 21:44:15 volvo2mqtt [1] - DEBUG: {
  "data" : {
    "serviceWarning" : {
      "value" : "NO_WARNING",
      "timestamp" : "2024-01-19T11:47:08.449Z"
    },
    "engineHoursToService" : {
      "value" : 381,
      "unit" : "h",
      "timestamp" : "2024-01-19T11:47:08.449Z"
    },
    "distanceToService" : {
      "value" : 18076,
      "unit" : "km",
      "timestamp" : "2024-01-19T11:47:08.449Z"
    },
    "washerFluidLevelWarning" : {
      "value" : "NO_WARNING",
      "timestamp" : "2024-01-19T11:47:08.449Z"
    },
    "timeToService" : {
      "value" : 2,
      "unit" : "months",
      "timestamp" : "2024-01-19T11:47:08.449Z"
    }
  }
}
Jan 19 21:44:15 volvo2mqtt [1] - INFO: Success! Washer Fluid Level warning is supported by your vehicle.
Jan 19 21:44:15 volvo2mqtt [1] - INFO: Success! API Backend status is supported by your vehicle.
timknowlden commented 5 months ago
image

Copying API keys directly from here. Formatted like this in docker:


@json {"username": "my@email.com", "password": "**Password**", "vin": "YV1UZL***", "vccapikey": ["**APIKEY1**", "**APIKEY2**"], "odometerMultiplier": 1, "averageSpeedDivider": 1, "averageFuelConsumptionMultiplier": 1}
timknowlden commented 5 months ago

Log after restarting container. ( I will regen API key after posting this )


Jan 19 21:44:15 volvo2mqtt [1] - INFO: Success! Washer Fluid Level warning is supported by your vehicle.
Jan 19 21:44:15 volvo2mqtt [1] - INFO: Success! API Backend status is supported by your vehicle.
Jan 20 08:19:37 volvo2mqtt [1] - INFO: Starting volvo2mqtt version v1.8.23
Jan 20 08:19:37 volvo2mqtt [1] - WARNING: VCCAPIKEY dc2a20b2915847e1ac8f0c3dc10bfc62 isn't working! Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
Jan 20 08:19:37 volvo2mqtt [1] - WARNING: VCCAPIKEY 10eba83e646d4fe689b6fd50fbb99df1 isn't working! Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
Jan 20 08:19:37 volvo2mqtt [1] - DEBUG: [{'key': 'dc2a20b2915847e1ac8f0c3dc10bfc62', 'extended': True, 'extended_until': None, 'in_use': False}, {'key': '10eba83e646d4fe689b6fd50fbb99df1', 'extended': True, 'extended_until': None, 'in_use': False}]
Jan 20 08:19:37 volvo2mqtt [1] - WARNING: No working VCCAPIKEY found, waiting 10 minutes. Then trying again!
Dielee commented 5 months ago

Your vcc API key isn't working. This is not a volvo2mqtt issue.

PS: You only need the primary key, not the secondary.

timknowlden commented 5 months ago

Your vcc API key isn't working. This is not a volvo2mqtt issue.

PS: You only need the primary key, not the secondary.

Okay ill keep trying, the API key as you can see though is copy and pasted and correct with what is issued by volvo

Dielee commented 5 months ago

Just wait, it will work!

timknowlden commented 5 months ago

Just wait, it will work!

Fingers crossed, id have thought it wouldnt take days though

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 4 months ago

This issue was closed because it has been stalled for 5 days with no activity.