Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerOcean nicht mehr auslesbar #16

Closed
4 tasks done
MaxGrmm opened this issue Jan 7, 2025 · 25 comments · Fixed by #17
Closed
4 tasks done

PowerOcean nicht mehr auslesbar #16

MaxGrmm opened this issue Jan 7, 2025 · 25 comments · Fixed by #17

Comments

@MaxGrmm
Copy link

MaxGrmm commented Jan 7, 2025

System Health details

System Information

version core-2024.12.5
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.13.0
os_name Linux
os_version 6.6.62-haos-raspi
arch aarch64
timezone Europe/Berlin
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
HACS Data ok
GitHub API Calls Remaining 5000
Installed Version 2.0.2
Stage running
Available Repositories 1559
Downloaded Repositories 31
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 14.1
update_channel stable
supervisor_version supervisor-2024.12.3
agent_version 1.6.0
docker_version 27.2.0
disk_total 116.5 GB
disk_used 19.9 GB
healthy true
supported true
host_connectivity true
supervisor_connectivity true
ntp_synchronized true
virtualization
board rpi4-64
supervisor_api ok
version_api ok
installed_addons Terminal & SSH (9.16.0), File editor (5.8.0), Samba Backup (5.2.0), Mosquitto broker (6.4.1), deCONZ (7.0.0), Uptime Kuma (0.12.4), Google Assistant SDK (2.5.0), Piper (1.5.2), ESPHome Device Builder (2024.12.2), Matter Server (7.0.0), HassOS SSH port 22222 Configurator (0.9.3), Advanced SSH & Web Terminal (19.0.0), Studio Code Server (5.18.0)
Dashboards
dashboards 8
resources 14
views 33
mode storage
Recorder
oldest_recorder_run 22. Dezember 2024 um 00:10
current_recorder_run 7. Januar 2025 um 10:41
estimated_db_size 1564.34 MiB
database_engine sqlite
database_version 3.45.3

Checklist

  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of any previous issues..

Describe the issue

Hallo @niltrip seit dem EcoFlow seine App geupdatet hat, bekomme ich keine Daten mehr vom PowerOcean.
Habe das Gerät bereits aus der Integration gelöscht und neu hinzugefügt, es kommen gar keine Entitäten mehr an.
Kannst du das Problem nachvollziehen / reproduzieren ?

Reproduction steps

  1. App aktualisiert, neue Einrichtung in der App erfolgt
  2. Gerät musste in der App einem Raum und Standort zugeordnet werden
  3. Keine Verbindung mehr via HomeAssinstant möglich
    ...

Debug logs

2025-01-07 10:42:04.401 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up powerocean platform for sensor
Traceback (most recent call last):
  File "/config/custom_components/powerocean/ecoflow.py", line 96, in get_json_response
    response = json_loads(request.text)
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 42, in json_loads
    return orjson.loads(obj)  # type:ignore[no-any-return]
           ~~~~~~~~~~~~^^^^^
orjson.JSONDecodeError: unexpected character: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 366, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/powerocean/sensor.py", line 54, in async_setup_entry
    data = await hass.async_add_executor_job(ecoflow.fetch_data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/powerocean/ecoflow.py", line 120, in fetch_data
    response = self.get_json_response(request)
  File "/config/custom_components/powerocean/ecoflow.py", line 103, in get_json_response
    raise Exception(f"Failed to parse response: {request.text} Error: {error}")
Exception: Failed to parse response: Invalid request Error: unexpected character: line 1 column 1 (char 0)

Diagnostics dump

No response

image

@yanbec
Copy link

yanbec commented Jan 7, 2025

Moin! War schon auf dem Weg das ebenfalls zu melden.
Der Login klappt noch:
2025-01-07 10:40:25.688 INFO (SyncWorker_6) [custom_components.powerocean] Login to EcoFlow API {'https://api.ecoflow.com/auth/login'} 2025-01-07 10:40:25.896 INFO (SyncWorker_6) [custom_components.powerocean] Successfully logged in: {'***'}

Bin gerne beim debuggen oder beheben behilflich, selbst leider (evtl. zu) wenig Erfahrungen mit HA-Integrationen, schaue aber nach Feierabend mal drauf. Bin sehr an einem schnellen Fix interessiert :)

@MaxGrmm
Copy link
Author

MaxGrmm commented Jan 7, 2025

Moin! War schon auf dem Weg das ebenfalls zu melden. Der Login klappt noch: 2025-01-07 10:40:25.688 INFO (SyncWorker_6) [custom_components.powerocean] Login to EcoFlow API {'https://api.ecoflow.com/auth/login'} 2025-01-07 10:40:25.896 INFO (SyncWorker_6) [custom_components.powerocean] Successfully logged in: {'***'}

Bin gerne beim debuggen oder beheben behilflich, selbst leider (evtl. zu) wenig Erfahrungen mit HA-Integrationen, schaue aber nach Feierabend mal drauf. Bin sehr an einem schnellen Fix interessiert :)

Stimmt der Login funktioniert bei mir auch noch, ich habe die Vermutung das sich in der API irgendwas geändert hat weil die App jetzt auch umstrukturiert worden ist mit diesen Räumen etc.

@Ackmachine
Copy link

Gleiches Problem bei mir. Keinerlei Entitäten nach Neuinstallation der Integration.

@yanbec
Copy link

yanbec commented Jan 7, 2025

Ein
curl "https://api-e.ecoflow.com/provider-service/user/device/detail?sn=$SN" -H "authorization: Bearer $TOKEN"
brringt mir nach wie vor ein valides Json. In der Integration kommt aber, soweit ich das nachvollziehen kann auf den gleichen Request ein "Invalid request" (Content der Response) zurück, wenn gleich mit einem Response Code 200.

@AndyBowden
Copy link

The integration has not provided me with any valid data since almost exactly 00:00UTC this morning. One suspects that EcoFlow introduced a change.
My iPhone app is showing valid live data for my system.

@yanbec
Copy link

yanbec commented Jan 7, 2025

It's the user agent in the request. I changed the request to send a user-agent header from my current browser and it instantly works again.
I will put in a PR later today I hope, not sure what user-agent to use tho, maybe there's a best practive in HA I don't know about.

Strangely I had a few values in between tonight and now. Maybe they're actively working on it.
image

@MaxGrmm
Copy link
Author

MaxGrmm commented Jan 7, 2025

@yanbec strange things happened 😮
Danke fürs Troubleshooting! Hoffe das der Codeowner das schnell umsetzen kann damit wir unsere Daten wieder abgreifen können. Ich hoffe ja auch wirklich das Ecoflow uns irgendwann mal MQTT direkt auf den PowerOcean gibt

@aortner
Copy link

aortner commented Jan 7, 2025

habe auch das gleiche problem. heute eingerichtet - keine daten - keine Entitäten.


Ecoflow PowerOcean
Version: 2024.08.27
Domain: powerocean
If you have any issues with this custom component please open an issue here:
https://github.com/niltrip/powerocean/issues

2025-01-07 10:58:23.955 INFO (SyncWorker_4) [custom_components.powerocean] Login to EcoFlow API {'https://api.ecoflow.com/auth/login'}
2025-01-07 10:58:24.146 INFO (SyncWorker_4) [custom_components.powerocean] Successfully logged in: {'EcoFlow User'}
2025-01-07 10:58:24.308 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up powerocean platform for sensor
Traceback (most recent call last):
File "/config/custom_components/powerocean/ecoflow.py", line 96, in get_json_response
response = json_loads(request.text)
File "/usr/src/homeassistant/homeassistant/util/json.py", line 42, in json_loads
return orjson.loads(obj) # type:ignore[no-any-return]
~~~~~~~~~~~~^^^^^
orjson.JSONDecodeError: unexpected character: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 366, in _async_setup_platform
await asyncio.shield(awaitable)
File "/config/custom_components/powerocean/sensor.py", line 54, in async_setup_entry
data = await hass.async_add_executor_job(ecoflow.fetch_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/powerocean/ecoflow.py", line 120, in fetch_data
response = self.get_json_response(request)
File "/config/custom_components/powerocean/ecoflow.py", line 103, in get_json_response
raise Exception(f"Failed to parse response: {request.text} Error: {error}")

@Cover1987
Copy link

Auch hier selbes Problem. Mir ist gestern Abend noch aufgefallen, dass es auf einmal mehr Entitäten gibt als davor und zwar zu den batter packs.

Screenshot_2025-01-07-15-14-41-508_io homeassistant companion android

@FabianMartin
Copy link

FabianMartin commented Jan 7, 2025

Als schneller Workaround lässt sich das Problem wie folgt beheben. / As a quick workaround, the problem can be solved as follows.

  1. Installation des Add-on "File editor" (alternativ Zugriff per SSH) / Install the “File editor” add-on (alternatively access via SSH)
  2. File editor starten und die Benutzeroberfläche öffnen / Start the file editor and open the user interface
  3. Über das Ordner Symbol links oben die Datei "/homeassistant/custom_components/powerocean/ecoflow.py" öffnen / Open the file “/homeassistant/custom_components/powerocean/ecoflow.py” via the folder icon at the top left

Folgende Zeilen anpassen:

Zeile 56 / Line 56:
Sollte ungefähr so aussehen / Should look something like this:

        headers = {"lang": "en_US", "content-type": "application/json"}

ändern in / change to

        headers = {"lang": "en_US", "content-type": "application/json", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0"}

Zeile 118 / Line 118:
Sollte ungefähr so aussehen / Should look something like this:

        headers = {"authorization": f"Bearer {self.token}"}

ändern in / change to

        headers = {"authorization": f"Bearer {self.token}", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0"}

Anschließend HA neustarten und schon sollte es frische Daten geben. / Then restart HA and you should have fresh data.

@yanbec Thanks for troubleshooting

@MaxGrmm
Copy link
Author

MaxGrmm commented Jan 7, 2025

@FabianMartin habe ich bei mir so getestet, bekomme aber leider jetzt 401 Error.
Exception: Got HTTP status code 401: {"code":"401","message":"noAuthorizationheader","eagleEyeTraceId":"ea1a2a582917362615769215550d0007","tid":""}

@FabianMartin
Copy link

Copy & Paste Fehler von mir. Ich habe den Code für Zeile 118 oben korrigiert.

@Ackmachine
Copy link

Sehr cool! Vielen Dank @FabianMartin ich bekomme auch wieder Werte mit dem Fix!

@MaxGrmm
Copy link
Author

MaxGrmm commented Jan 7, 2025

Copy & Paste Fehler von mir. Ich habe den Code für Zeile 118 oben korrigiert.

Danke, damit läuft es! 👍

@Bodoundbenni
Copy link

Als schneller Workaround lässt sich das Problem wie folgt beheben.

DANKE DIR!
Funktioniert einwandfrei, du bist ein Magier :-)

@niltrip
Copy link
Owner

niltrip commented Jan 7, 2025

I can fix it. It seems that it is now necessary to specify a user agent in the header. I should be able to do it this evening. Thanks @yanbec

@aortner
Copy link

aortner commented Jan 7, 2025

danke für deinen einsatz. geht dritz änderung noch nicht - warte dann mal bis zum fix.

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 366, in _async_setup_platform
await asyncio.shield(awaitable)
File "/config/custom_components/powerocean/sensor.py", line 54, in async_setup_entry
data = await hass.async_add_executor_job(ecoflow.fetch_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/powerocean/ecoflow.py", line 124, in fetch_data
return self._get_sensors(response)
~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/config/custom_components/powerocean/ecoflow.py", line 204, in _get_sensors
sensors = self.__get_sensors_ems_heartbeat(response, sensors)
File "/config/custom_components/powerocean/ecoflow.py", line 414, in __get_sensors_ems_heartbeat
for key, value in d[phase].items():
~^^^^^^^
KeyError: 'pcsAPhase'
2025-01-07 16:47:17.503 WARNING (ImportExecutor_0) [homeassistant.const] POWER_VOLT_AMPERE_REACTIVE was used from huawei_solar, this is a deprecated constant which will be removed in HA Core 2025.9. Use UnitOfReactivePower.VOLT_AMPERE_REACTIVE instead, please report it to the author of the 'huawei_solar' custom integration
2025-01-07 16:48:11.613 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up powerocean platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 366, in _async_setup_platform
await asyncio.shield(awaitable)
File "/config/custom_components/powerocean/sensor.py", line 54, in async_setup_entry
data = await hass.async_add_executor_job(ecoflow.fetch_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/powerocean/ecoflow.py", line 124, in fetch_data
return self._get_sensors(response)
~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/config/custom_components/powerocean/ecoflow.py", line 204, in _get_sensors
sensors = self.__get_sensors_ems_heartbeat(response, sensors)
File "/config/custom_components/powerocean/ecoflow.py", line 414, in __get_sensors_ems_heartbeat
for key, value in d[phase].items():
~^^^^^^^
KeyError: 'pcsAPhase'

@yanbec
Copy link

yanbec commented Jan 7, 2025

I can fix it. It seems that it is now necessary to specify a user agent in the header. I should be able to do it this evening. Thanks @yanbec

Sure thing :) Thank you! That goes for the integration in general too, I still hope EF will allow us a local connection to our devices at some point, until then we'll have to work with what we've got.

@jdammers
Copy link
Collaborator

jdammers commented Jan 7, 2025

@ALL thanks for the quick fix. However, the user-agent definition will depend on the OS. For me, on macos it works with: "user-agent": "Mozilla / 5.0 (Macintosh; Intel Mac OS, wie Gecko) Chrome/90.0.4430.212 Safari/537,36"
Any idea how to fix it without using a hard-coded user-agent definition?

@yanbec
Copy link

yanbec commented Jan 7, 2025

@jdammers It's just the user agent used for the request from the integration to EF, so your OS doesn't matter. All that matters is EF accepting the set user agent, which would probably best be something like "HomeAssistant powerocean integration" .. - if that works. As @niltrip is on it I guess we're good for now and the update comes in soon :) if there's any help needed, feel free to ping me of course

@niltrip niltrip linked a pull request Jan 7, 2025 that will close this issue
@jdammers
Copy link
Collaborator

jdammers commented Jan 7, 2025

@yanbec @niltrip Many thanks to both of you!

@aortner
Copy link

aortner commented Jan 12, 2025

Ich habe zuerst den Code geändert - leider nix.

dann alles deaktiviert und neu installiert .

der Power ocean wird gefunden aber es werden weiterhin keine Daten angezeigt .

trotzdem danke !

@FabianMartin
Copy link

Ich habe zuerst den Code geändert - leider nix.

dann alles deaktiviert und neu installiert .

der Power ocean wird gefunden aber es werden weiterhin keine Daten angezeigt .

trotzdem danke !

Die Fehlermeldung zeigt ein anderes Problem. In der Rückgabe scheinen die Daten für die drei Phasen zu fehlen. Dadurch kommt es zu dem Fehler. Kann es sein, dass es sich bei deinem Modell um das Einphasige handelt?

@aortner
Copy link

aortner commented Jan 12, 2025

https://homebattery.ecoflow.com/de/products/PowerOcean-DC-Fit

Ich glaube wir sind auf dem richtigen Weg.

Habe einen power ocean - aber die Type dc fit . Da hängt der Speicher zw strings und wechselrichter .

Ich glaube da müsste man die api anpassen .Liebe Grüße Andreas

@niltrip
Copy link
Owner

niltrip commented Jan 12, 2025

Hi,

you can generate a response an share it with us.

Generating a response is easy: activate debug and then reload the integration. The log file should then contain the complete answer. It should start with

[custom_components.powerocean] {'code': '0', 'message': 'Success',...

Copy the string ( within the curly brackets {} ) into an editor and format it a little and save it as json. I like to use notepad++ and a plugin “JsonTools”.

Remember to remove the serial numbers and other data related to you, then you can provide the file.

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants