juicejuice / homeassistant_redback

Home Assistant integration for inverter and battery systems from Redback Technologies
7 stars 2 forks source link

No Configuration after installation #16

Closed Ross-FS closed 9 months ago

Ross-FS commented 11 months ago

I have installed the Redback Integration into my HomeAssistant system. It works fine. However, I am not able to view or change the Client ID and Credentials now that it is running. There is no option to change the configuration from within the settings after it has been installed. This is a bit of a short-coming, as I am now unable to review these details for troubleshooting, or migration. It appears, that if the Redback company changes my security details, then I would have to delete and recreate this integration. Would you be able to add a Configuration command to the integration?

juicejuice commented 11 months ago

Thanks, great idea! I will look into it when I get chance. Unfortunately, I'm away from home until October.

GrantKeymer commented 9 months ago

Hi @juicejuice,

Today I received a notification email from Redback that my API access will expire in 2 months time. Apparently this now happens every 2 years. Is there any chance of having a Configuration Flow available and working within the next 2 months? I really don't want to have to reinstall the integration, when it's been working so well for so long.

Secondly, Redback have provided a Web Link to my new credentials, which will expire in 30 days.

If I access the link to my new credentials, is that likely to disable my existing credentials?

juicejuice commented 9 months ago

Interesting! I haven't had a similar email yet, so I don't know if it replaces old with new credentials. I'll look into what's involved to change credentials, I've been flat out with work but hopefully get some spare time soon. In the meantime, you can manually update the details if required:

  1. Login to HA and launch File editor add-on
  2. Click folder button in top-left to open the /config/.storage/core.config_entries file
  3. Search in that config file for "redback"
  4. Update the following "client_id" and "auth" fields to suit new credentials
  5. Click red save button at top of File editor
  6. Reload the Redback integration (or restart HA)

Here is what the config entry code should look like: "domain": "redback", "title": "Redback", "data": { "displayname": "Redback", "apimethod": "public", "client_id": "0123456a-1111-1111-1111-1a2b3c4d5e6f", "auth": "ABCDE~XCC4qulr-JzXBVVWQRVcnXrBO8N_EcZbrv", "site_index": "First" },

Note: if you have multiple inverters registered you will need to update every instance of "redback" in that config file.

I haven't tested this out yet so if someone does test it out please update all of us with your findings.

GrantKeymer commented 9 months ago

Brilliant, thanks very much Juice. The manual method sounds very simple, so I'll give it a try.

GrantKeymer commented 9 months ago

First thing to note is that issuance of new credentials doesn't affect the validity of the old ones. In fact, the clock was already ticking on my new credentials, from the date they were made available.

juicejuice commented 9 months ago

OK so I've just pushed an update to the integration. It turns out Home Assistant has a standard "re-authentication" mechanism that other integrations also use. I've added this re-authentication support for the Redback integration now. The way it works is to detect when credentials are expired and notify you of the issue. You then have the option to supply new credentials and it will test that those are working before updating your configuration. I've tested out here and it is working fine, please check it out and let me know? (BTW, I haven't found a way to manually trigger re-authentication except for editing the core.config_entries file by hand with incorrect credentials)

GrantKeymer commented 9 months ago

I just had a go at editing the core.config_entries file and didn't get very far. Following your instructions...

Login to HA and launch File editor add-on Click folder button in top-left to open the /config/.storage/core.config_entries file

For some reason, the File Editor cannot see the .storage directory in the config directory. I'm guessing it's because there is a '.' in front of it. However, I can't see any way to change that behaviour.

Using Terminal, I can successfully navigate to the .storage directory and using the Cat command, I can view the contents of the file and see the redback section.

I guess I could use Vim or Nano to edit the file, but would prefer to use File Editor if possible. Any idea on how I could make it work?

I am running Home Assistant OS, rather than Core, so maybe that has something to do with it.

juicejuice commented 9 months ago

Check the configuration tab of the File Editor add-on. It has an "ignore" setting which might be what is hiding your storage folder. Looks like there is a thread here on the subject too: https://community.home-assistant.io/t/access-storage-folder/190186/18 Also, when I was testing out I had to restart HA for the updated config to take effect. Reloading the integration wasn't enough.

GrantKeymer commented 9 months ago

Many thanks once again Juice, for your excellent support and clear instructions.

As you suggested, the .storage folder was hidden because of an entry in the ignore setting. I deleted that entry, along with 3 others, turned off another switch which was restricting me to the config folder, and voila!, there was .storage. Now I can navigate anywhere in the file system. No doubt, the authors of the File Editor add-on did this to protect newbies from tinkering with stuff they shouldn't be tinkering with.

Upon restarting HA, I was prompted to download an updated version of your Redback integration, then prompted for the new Configuration (credentials), and finally needed to restart HA again to allow the new credentials to take effect.

After a short delay, all the Redback entities reappeared as they were before.

Great work Juice! I will save these instructions for use when my new credentials expire in 2 years time 👍

Meanwhile, I hope this thread will be helpful to others when their credentials expire.

juicejuice commented 9 months ago

Thanks Grant for being the guinea pig and reporting back! I'm sure this will help others :) I will mark this issue as closed for now as it seems we have now resolved the immediate need to refresh Redback API credentials.