homeassistant-truenas: [Bug] Integration fails with Electric Eel - chart error

Describe the issue

Using the beta version of TrueNAS-SCALE, the API for ‘chart/release’ fails with: TrueNAS 192.168.10.11 unable to fetch data "chart/release" (404) This persists through reboots of both systems - it appears to be related to an API change in Electric Eel, likely relating to the changes to how containers are handled.

Generating a new API key also has the same error, which suggests it’s not credential validation causing it, but likely an endpoint has changed. Looking further into the repo and the API itself, it is to do with the app releases section specifically. Bypassing that gets the normal data loading properly, just minus the container/app information. (changing line 1123 in coordinator.py to remove the ‘not’ part allows for regular data to resume flow).

How to reproduce the issue

Steps to reproduce the behavior:

  1. Upgrade to ‘Electric Eel’ (beta)
  2. Restart HAss
  3. See error (unavailable entities)

Alternately: Attempt to re-add to HAss, and get the specific error.

Expected behavior

TrueNAS information shows up in HA.

Screenshots

Software versions

  • Home Assistant version:
  • TrueNAS integration version:
  • TrueNAS version:

Diagnostics data

Traceback/Error logs

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 10
  • Comments: 26 (5 by maintainers)

Most upvoted comments

if you already update to 24.10, you can make it works by editing few lines like i did. in custom_components/truenas/coordinator.py, if you already edit line 1123 before, revert it back to

        if not self._is_scale:

and edit line 1128 and so on to:

            source=self.api.query("app"),
            key="id",
            vals=[
                {"name": "id", "default": 0},
                {"name": "name", "default": "unknown"},
                {"name": "human_version", "default": "unknown"},
                {"name": "upgrade_available", "default": "unknown"},
                {"name": "image_updates_available", "default": "unknown"},
                {"name": "portal", "source": "portals/Web UI", "default": "unknown"},
                {"name": "state", "default": "unknown"},
            ],
            ensure_vals=[
                {"name": "running", "type": "bool", "default": False},
            ],
        )

        for uid, vals in self.ds["app"].items():
            self.ds["app"][uid]["running"] = vals["state"] == "RUNNING"

and for fixing the attibutes: in custom_components/truenas/binary_sensor_types.py line 78-79

    "upgrade_available",
    "image_updates_available",

don’t forget to restart homeassistant

image

i think there is 2 ways this can go about, either:

  1. The integration keep supporting both the new and old versions of truenas (pre and post electric eel)

  2. The integration is migrated/updated to only support post electric eel, and we bump the major version and leave the old version to go. They seem to be moving away from the REST API, and fully migrating their TrueNAS API Client

Personally i feel its best to go with the latter option, as its going to hinder development/improvements, but then again, it comes down to how @tomaae wants to approach it

how do i make this fix and add it back to home assistant with the fix?

You need to alter the ‘coordinator.py’ file in the custom components folder. If you installed using HACS, the file is located in custom_components/truenas/coordinator.py.

Line 1123 normally reads: if not self._is_scale:

If you remove the “not” part, it should read: if self._is_scale:

Then restart HA to load the modified version. It’s not a fix, but it gets most stats back online until a proper fix is available (which I expect will require more changes from TrueNAS to finish the apps API on the new version).

released in 1.3

Can you suggest this for a pull request?

PR submitted with some improvement to retain compatibility with previous TrueNAS version #180

if you already update to 24.10, you can make it works by editing few lines like i did. in custom_components/truenas/coordinator.py, if you already edit line 1123 before, revert it back to

        if not self._is_scale:

and edit line 1128 and so on to:

            source=self.api.query("app"),
            key="id",
            vals=[
                {"name": "id", "default": 0},
                {"name": "name", "default": "unknown"},
                {"name": "human_version", "default": "unknown"},
                {"name": "upgrade_available", "default": "unknown"},
                {"name": "image_updates_available", "default": "unknown"},
                {"name": "portal", "source": "portals/Web UI", "default": "unknown"},
                {"name": "state", "default": "unknown"},
            ],
            ensure_vals=[
                {"name": "running", "type": "bool", "default": False},
            ],
        )

        for uid, vals in self.ds["app"].items():
            self.ds["app"][uid]["running"] = vals["state"] == "RUNNING"

and for fixing the attibutes: in custom_components/truenas/binary_sensor_types.py line 78-79

    "upgrade_available",
    "image_updates_available",

don’t forget to restart homeassistant

image

Can you suggest this for a pull request?

Electric Eel now final, if you can @tomaae please make it compatible 👍 .

issue still exists in RC2

That works - mostly. Still randomly suggests that there’s a release update available, which is bizarre. To make that change reliable while retaining support for people who haven’t yet updated, we might need a way to check the version and see if it’s pre- or post- changes, so that the API calls differ based on truenas version being connected to.

I think i have found solution for this problems. I was trying to make a pull request but it was a mess so i delete it (i’m still newbie 😅). You can check all changes i made to make it works in my forked repo itsniawan/homeassistant-truenas

No surprise there, since they are moving from k3s to docker. API documentation is not available right now, so probably after release we can get it updated to work with EE. You will probably make it work by hashing out apps related updates in main coordinator thread.