Closed grahamrjuk closed 6 months ago
I confirm, Same issue.
After set night_hour_start Api return "Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."
Log :
2024-03-16 17:04:11,138 :: ERROR :: Exception on /settings/electricity_config [GET]
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/web/view/api.py", line 182, in settings_section
return json_response(config_section.json())
File "pydantic/main.py", line 504, in pydantic.main.BaseModel.json
File "/usr/lib/python3.9/json/__init__.py", line 234, in dumps
return cls(
File "/usr/lib/python3.9/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.9/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "pydantic/json.py", line 90, in pydantic.json.pydantic_encoder
TypeError: Object of type 'Hour' is not JSON serializable
2024-03-16 17:04:11,138 :: ERROR :: Exception on /settings/electricity_config [GET]
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/web/view/api.py", line 182, in settings_section
return json_response(config_section.json())
File "pydantic/main.py", line 504, in pydantic.main.BaseModel.json
File "/usr/lib/python3.9/json/__init__.py", line 234, in dumps
return cls(
File "/usr/lib/python3.9/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.9/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "pydantic/json.py", line 90, in pydantic.json.pydantic_encoder
TypeError: Object of type 'Hour' is not JSON serializable
2024-03-16 17:04:11,144 :: INFO :: 172.30.32.1 - - [16/Mar/2024 17:04:11] "[35m[1mGET /settings/electricity_config HTTP/1.1[0m" 500 -
I have confirmed that the app doesn't crash anymore for me when night hour start
is set.
Thank you :-)
Describe the bug Trying to set
night_hour_start
in theelectricity_config
using the api. e.g.http://localhost:5000/settings/electricity_config?night_hour_start=23h30
the configuration becomes unusable and I have had to re-install the PSA controller a couple of times. I am using the controller within Home Assistant OS on a Raspberry Pi.To Reproduce Steps to reproduce the behavior:
Config file Give the anonymize content of the config file
{"General": {"currency": "\u00a3", "length_unit": "km", "minimum_trip_length": 10.0, "export_format": "csv"}, "Electricity_config": {"day_price": 0.31, "night_price": 0.075, "night_hour_start": "23h30", "night_hour_end": null, "dc_charge_price": null, "high_speed_dc_charge_price": null, "high_speed_dc_charge_threshold": null, "charger_efficiency": 0.8942}}
Environment (please complete the following information):
Additional context I have looked in other issues and in the FAQ and can't see anything like this - apologies if an answer is already available. So far I haven't managed to use ssh to get to the admin port on the Pi (22222) to get access to the docker container directly.