tolwi / hassio-ecoflow-cloud

EcoFlow Cloud Integration for Home Assistant
381 stars 64 forks source link

"Unknown" error when testing public API in v1.0.0-pre1/2 #276

Closed 321MathiasS123 closed 1 month ago

321MathiasS123 commented 2 months ago

Hey,

I know the newer releases after v0.13.4 are considered beta, but I wanted to try the public API for the integration of the smart plugs. My goal is to automate the charging of two Delta 2 Max stations. I managed to automate the AC charge speed with the private API but I need to be able to turn on and off charging completely with a plug, so I tried die v1.0.0-pre2.

When I try to add an entry via the UI and enter my access key and secret key in the respective fields all I get is a message saying "unknown". The corresponding log entry looks like this:

Traceback (most recent call last): File "/config/custom_components/ecoflow_cloud/config_flow.py", line 136, in async_step_api devices = await auth.fetch_all_available_devices() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ecoflow_cloud/api/public_api.py", line 43, in fetch_all_available_devices result.append(self.__create_device_info(device["sn"], device["deviceName"], device["productName"])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ecoflow_cloud/api/public_api.py", line 89, in __create_device_info data_topic=f"/open/{self.mqtt_info.username}/{device_sn}/quota", ^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'username'

Any ideas how to get around this problem?

keenanj123 commented 2 months ago

I have been getting the same for the last 2 weeks on HA 2024.7.4 first the integration stopped working when I try to add ecoflow back in i get unknow. If I use application api it will initialize but i get no data.

tolwi commented 2 months ago

try with v1.0.0-pre3

321MathiasS123 commented 2 months ago

Thanks for working on this so fast. Now I get a few steps further before I hit another snag.

The credentials are now accepted and I get a list of all my devices. When I select a smart plug (tried the Powerstream with the same result) I get another Window where I have to select a device type. it gives me the options of Delta 2, River 2, River 2 Max and Diagnostic. When I select Diagnostic I get the message "Unknown error occured."

This generates the following log entry:

Logger: aiohttp.server Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:421 First occurred: 8:37:04 PM (1 occurrences) Last logged: 8:37:04 PM Error handling request

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin return await func(self, request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post return await super().post(request, flow_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper return await method(view, request, data, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post result = await self._flow_mgr.async_configure(flow_id, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure result = await self._async_configure(flow_id, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 415, in _async_configure result = await self._async_handle_step( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step result: _FlowResultT = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ecoflow_cloud/config_flow.py", line 179, in async_step_confirm_cloud_device device = device_by_product[user_input[const.CONF_DEVICE_TYPE]]


KeyError: 'DIAGNOSTIC'

When I select one of my two Delta 2 Max with the Option Delta 2, is works, but the entry has fewer entities than with the private API (64 vs. 77)
keenanj123 commented 2 months ago

mine is now working using v1.0.0-pre3 thanks!

tolwi commented 2 months ago

@321MathiasS123 v1.0.0-pre4 - got rid of inconsistency between a real list of device profiles and list of device types in config. The 'Smart Plug' option should be available, but I'm uncertain if it's the default option for smart plug devices, as I don't know what the API returns for 'productName' (assuming it's "Smart Plug").

321MathiasS123 commented 2 months ago

@tolwi -pre4 is a huge step forwards, I can add the plugs and get 6 entities: a switch for turning it on/off, a slider for the brightness and sensors for current, power, temperature and volts

However the sensors are never updated after adding the plug and the values for the switch and slider don't sync with the app. When I try to toggle the switch for plug from HA it creates this:

[547826673712] Unexpected exception

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2731, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1689, in async_turn_off await self.hass.async_add_executor_job(ft.partial(self.turn_off, *kwargs)) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ecoflow_cloud/switch.py", line 34, in turn_off self.send_set_message(0, self.command_dict(0)) File "/config/custom_components/ecoflow_cloud/entities/init.py", line 132, in send_set_message self._client.mqtt_client.send_set_message({self._mqtt_key: target_value}, command) File "/config/custom_components/ecoflow_cloud/api/ecoflow_mqtt.py", line 117, in send_set_message self.__device.data.update_to_target_state(mqtt_state) File "/config/custom_components/ecoflow_cloud/devices/data_holder.py", line 78, in update_to_target_state jp.parse(key).update(self.params, value) ^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/jsonpath_ng/ext/parser.py", line 174, in parse return ExtentedJsonPathParser(debug=debug).parse(path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/jsonpath_ng/parser.py", line 38, in parse return self.parse_token_stream(lexer.tokenize(string)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/jsonpath_ng/parser.py", line 62, in parse_token_stream return new_parser.parse(lexer = IteratorToTokenStream(token_iterator)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/ply/yacc.py", line 333, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/ply/yacc.py", line 1201, in parseopt_notrack tok = call_errorfunc(self.errorfunc, errtoken, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/ply/yacc.py", line 192, in call_errorfunc r = errorfunc(token) ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/jsonpath_ng/parser.py", line 78, in p_error raise JsonPathParserError('Parse error at %s:%s near token %s (%s)' jsonpath_ng.exceptions.JsonPathParserError: Parse error at 1:1 near token _1 (ID)

I can live with the sensors not updating, I don't have to control and monitor everything :-) Wat I'd like to be able to access is switching the plugs on and off via automation and being able to add a Powerstream inverter and setting a value for what Ecoflow calls household power demand -> base load in the options in the app or Custom load power settings/permanentWatts in the developer reference. All the rest I'll treat as nice to have.