home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.67k stars 30.42k forks source link

JustNimbus integration not working anymore #96948

Closed tjittejelte closed 9 months ago

tjittejelte commented 1 year ago

The problem

Since about two weeks, the JustNimbus integration is not working anymore. Probably related to a change on the side of the JustNimbus dashboard.

What version of Home Assistant Core has the issue?

2023.7.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

JustNimbus

Link to integration documentation on our website

https://www.home-assistant.io/integrations/justnimbus/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @kvanzuijlen, mind taking a look at this issue as it has been labeled with an integration (justnimbus) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `justnimbus` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign justnimbus` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


justnimbus documentation justnimbus source (message by IssueLinks)

kvanzuijlen commented 1 year ago

Hello,

Since I no longer have access to this version of the dashboard anymore I am not able to reproduce this. Are you able to get some logs from your Home Assistant instance for this integration?

Thanks in advance!

tjittejelte commented 1 year ago

Hi Koen,

Bedankt voor je reactie. Ik kan niets vinden in de logs. Wat ik nu probeer is de integration 'justnimbus' opnieuw toe te voegen. Na het invullen van mijn 'client ID' zie ik een scherm met alleen 'close' als optie. Zie bijlage. Als ik iets meer kan betekenen in deze hoor ik het graag

[Edit: removed signature]

On Thu, 20 Jul 2023, 19:20 Koen van Zuijlen, @.***> wrote:

Hello,

Since I no longer have access to this version of the dashboard anymore I am not able to reproduce this. Are you able to get some logs from your Home Assistant instance for this integration?

Thanks in advance!

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/96948#issuecomment-1644303748, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHK7WPIBUIHUICM7E4LMVTXRFSFJANCNFSM6AAAAAA2RKQV4Q . You are receiving this because you authored the thread.Message ID: @.***>

joostlek commented 1 year ago

(Please keep it English ^^)

joostlek commented 1 year ago

Oh and attachments don't work on emails, please upload it via GitHub desktop :)

MartinFinkenflugel commented 1 year ago

I've encountered the same issue. My assumption is that the integration stopped working because the dashboard authentication has changed. It now requires "Installatienaam" + "Postcode" instead of a password (which seemed to be just the "Installatienaam" + "Postcode" combined).

I've emailed the JustNimbus team about these dashboard changes on the 19th of July but am still waiting for a response.

@kvanzuijlen : This is from my HA log, I've changed the last 5 numbers of my client_id to XXX:

Logger: homeassistant.components.justnimbus.coordinator
Source: components/justnimbus/coordinator.py:34
Integration: JustNimbus ([documentation](https://www.home-assistant.io/integrations/justnimbus), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+justnimbus%22))
First occurred: 5:02:58 PM (70 occurrences)
Last logged: 6:31:59 PM

Unexpected error fetching justnimbus data: 'jnXXX' is an invalid client_id
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/justnimbus/__init__.py", line 15, in get_data
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://dashboard.justnimbus.com/api/installation/jnXXX/data

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/justnimbus/coordinator.py", line 34, in _async_update_data
    return await self.hass.async_add_executor_job(self._client.get_data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/justnimbus/__init__.py", line 18, in get_data
    raise InvalidClientID(client_id=self._client_id) from error
justnimbus.exceptions.InvalidClientID: 'jnXXX' is an invalid client_id
kvanzuijlen commented 1 year ago

@MartinFinkenflugel you might be correct. Curious to hear what JustNimbus has to say about it.

Would also help if you could find the API url which is now being called by the dashboard. Before it just contained a client ID (as you can find in the integration docs). If I know how it changed I might be able to fix it, although it won't be easy without being able to test it.

MartinFinkenflugel commented 1 year ago

@kvanzuijlen I took a quick look and it seems they've removed the API. When accessing the new dashboard I don't see any calls to endpoints, it just fetches a PHP page at https://dashboard.justnimbus.com/user/view.php?system=JNXXX&zip=0000AA which contains the values.

I'll send them another email to ask for clarification on this.

I've also started looking into retrieving the values locally but it seems that's only possible via MQTT.

kvanzuijlen commented 1 year ago

Thanks, @MartinFinkenflugel.

It sounds like this would be hard to implement for me without access to a test environment. Currently, I only have access to their new local dashboard, which also works via MQTT, so it might be possible that this works similarly to that, but I'm not sure about that. I'm currently working to add support for this local dashboard but I currently don't have enough time to do that. So if there are any (experienced) programmers that do have access to this cloud dashboard; help is appreciated!

MartinFinkenflugel commented 1 year ago

@kvanzuijlen I might be able to help out with access to the dashboard, what's the best way to message you directly? I see you have your LinkedIn in your profile, is it ok if I message you through there?

kvanzuijlen commented 1 year ago

@MartinFinkenflugel yeah, sure. I'm not sure when I have time to look for a fix though, maybe this weekend...

DomoticX commented 1 year ago

Could you give me some examples what kind API (HTTP GET?) calls you make to the dashboard to retrieve the data?

*EDIT I see the plugin data here: Homeassistant Github

What was/is the generated output? JSON? (don't have home-assistant)

DomoticX commented 1 year ago

Ok, for now you can add output=json behind the GET call, like: https://dashboard.justnimbus.com/user/view.php?system=JNxxxxx&zip=1234AB&output=json

it will generate a JSON output (with starting and ending brackets, let me know if you need these) like:

[{
    "api_version": "1",
    "system_last_update": "2023-07-31 12:08",
    "system_status": " System Just Right!",
    "system_flow": "2.0.5",
    "reservoir_capacity": "4500",
    "reservoir_content": "1526",
    "reservoir_temp": "-",
    "pump_type": "Hydrofoor",
    "pump_pressure": "2.2",
    "water_saved": "0",
    "water_used": "27367"
}]

for now this is all the data.

@kvanzuijlen you might need to update the API call for this plugin from https://dashboard.justnimbus.com/api/installation/jnXXX/data to https://dashboard.justnimbus.com/user/view.php?system=JNxxxxx&zip=1234AB&output=json

and adjust the key pairs to the corresponding output.

If you need anything else, let me know...

*Edit I even made a page for it now ;-) https://dashboard.justnimbus.com/dashboard-info-api/

DomoticX commented 1 year ago

Just to complete it all... i've also added CSV andd XML output to the list, have fun!

kvanzuijlen commented 1 year ago

Thanks for adding this @DomoticX! I'll work on updating the integration!

MartinFinkenflugel commented 1 year ago

Awesome, thanks so much for your work @DomoticX !

@kvanzuijlen Any chance you're already working on this? No worries if not, in that case I'll go dust off my rusty code skills to take a crack at it.

kvanzuijlen commented 1 year ago

I started working on it but started doing a bit too much (working on the local integration as well). I'll try my best to get a PR in for the online integration before the end of the month but can't promise anything. My goal is to also get the local integration working since that one gives a lot more data and is push-based, but a bit harder for me to comprehend and integrate.

Thanks everyone for being so patient!

willemvanderkraan commented 1 year ago

I would like to get the justnimbus data into Homeassistant, but I get an error: UndefinedError: 'value_json' is undefined It seems that the json is not valid, there are no quotes at the api version. Can this be the reason of the error?

[ { "api_version": 3, "system_last_update": "2023-10-03 13:27", "system_lat": "52.0903", "system_lon": "5.14361", "system_status": "System Just Right!", "system_flow": "2.0.5", "system_ip": "", "reservoir_capacity": "4500", "reservoir_content": "2008", "reservoir_temp": null, "pump_type": "Hydrofoor", "pump_pressure": "2.4", "water_saved": "18467", "water_used": "177", "water_added": null, "api_weather": null, "rain_36h": "0" } ]

willemvanderkraan commented 1 year ago

I am also working on a local connection to the MQTT data of Justnimbus, that partly works, but not all the data seems available in MQTT.

DomoticX commented 1 year ago

I would like to get the justnimbus data into Homeassistant, but I get an error: UndefinedError: 'value_json' is undefined It seems that the json is not valid, there are no quotes at the api version. Can this be the reason of the error?

[ { "api_version": 3, "system_last_update": "2023-10-03 13:27", "system_lat": "52.0903", "system_lon": "5.14361", "system_status": "System Just Right!", "system_flow": "2.0.5", "system_ip": "", "reservoir_capacity": "4500", "reservoir_content": "2008", "reservoir_temp": null, "pump_type": "Hydrofoor", "pump_pressure": "2.4", "water_saved": "18467", "water_used": "177", "water_added": null, "api_weather": null, "rain_36h": "0" } ]

DomoticX commented 1 year ago

I am also working on a local connection to the MQTT data of Justnimbus, that partly works, but not all the data seems available in MQTT.

Depends on the FLOW version, since last flow revisions no extra data is currently implemented, we will hold it into the light again in the comming weeks.

kvanzuijlen commented 1 year ago

@willemvanderkraan Very nice! Are you planning on including it in Home Assistant Core? I'll try to get to reauthentication flow working for it this weekend. Would be nice to have the online API for users that don't know how to statically assign IP addresses on their DHCP server and the local (preferred) solution for statically assigned IP addresses/discoverable by hostname.

willemvanderkraan commented 1 year ago

@DomoticX thanks for fixing the API version!

DomoticX commented 1 year ago

@willemvanderkraan Very nice! Are you planning on including it in Home Assistant Core? I'll try to get to reauthentication flow working for it this weekend. Would be nice to have the online API for users that don't know how to statically assign IP addresses on their DHCP server and the local (preferred) solution for statically assigned IP addresses/discoverable by hostname.

No, the FLOW is locally, you can always use/try justnimbus.local (no ip address needed)

willemvanderkraan commented 1 year ago

@kvanzuijlen Hi Koen, I dont have the skills to include this in Home Assistant Core. I am looking forward to your renewed integration. The local solution is indeed preferred. Ik got it working via MQTT, but it shows less data then the remote API. Via MQTT it shows: justnimbus sensor water pressure = 2.67 temp = 16.5 volume = 2028 height = 182 overflow = 0 actuator pump = relay.off valve in = valve.off out = valve.off system error = 0 status = System Just Right! stats water added hour = 4

kvanzuijlen commented 1 year ago

Hi Willem,

The new API doesn't show much more, see my latest PR: #99212. I'm curious to see what you've been able to come up with. Maybe I can get it integrated into Home Assistant at a later moment.

@willemvanderkraan Very nice! Are you planning on including it in Home Assistant Core? I'll try to get to reauthentication flow working for it this weekend. Would be nice to have the online API for users that don't know how to statically assign IP addresses on their DHCP server and the local (preferred) solution for statically assigned IP addresses/discoverable by hostname.

No, the FLOW is locally, you can always use/try justnimbus.local (no ip address needed)

I was referring to the new JSON API for the online API (could've made that a bit clearer). The hostname would of course be a very nice solution, with the JSON API as a nice alternative for when Justnimbus is not on the same network as the home assistant device and a more complicated setup connecting the 2 networks isn't feasible. Not sure if it is possible/how easy it is to show Home Assistant users a notification suggesting to use the local MQTT solution when that becomes available though.