dupondje / nrgkick-ha

Home Assistant - NRGKick Integration
18 stars 3 forks source link

Connection lost after changing security pin #15

Closed smedomi closed 6 months ago

smedomi commented 6 months ago

Hi,

First of ... nice integration!

I was able to connect relatively easy by first setting a PIN code in the app and then just use the ip and the PIN code in home assistant. At some point I wanted to change some settings in the app and at that point I used a different PIN code (I remembered it wrong).

I checked the core.config_entries file in HA and made sure to reset the pin in the NRGKick app back to the one stored in HA and although HA finds the device (I can see it and if I power it off it disconnects and shows entities as unavailable) all entities are shown as 0 and I am no longer able to control anything anymore.

It seems like the access is somehow denied as you get the same behaviour in HA when the "wrong" pin is stored in the app or the "correct" pin is stored in the app (the correct pin being the pin stored in HA).

image image

No obvious errors in the logs (or I don't know where to look maybe - not an expert) all messages in the logbook show similar things like the screenshot below. (phases set to 0, energy limit stated changed to ENERGY_LIMiT-MODE_UNKNOWN). Everything still works in the app - just not getting through to HA. image

An obvious thing to try is to just remove and redo the whole integration but I am wondering if you would know of a better way to do this? Also just wanted to let you know of it.

Thanks!

dupondje commented 6 months ago

First of ... nice integration!

Thanks!

I was able to connect relatively easy by first setting a PIN code in the app and then just use the ip and the PIN code in home assistant. At some point I wanted to change some settings in the app and at that point I used a different PIN code (I remembered it wrong).

You should not be able to gain access to the app if you have the wrong PIN? Did you change anything? You did not (factory) reset your NRGKick?

In fact, the PIN code should only be needed during configuration stage. If you enter the PIN & IP in HA during configuration, a new authentication UUID is configured on the NRGKick device, and then that UUID (which you should find in your HA config/db files) is used to connect to the NRGKick. So as long as that UUID is not removed from the NRGKick (like via a factory reset), it should keep working, even after a PIN code change I suppose. Or perhaps NRGkick removes the existing auth's after a PIN change, but that is something that I can't verify.

In https://github.com/dupondje/nrgkick-proto there is a index.html file to create a new UUID. In fact you can here create a new one, and then config that new UUID in the HA config.

This should fix the issue without reconfiguring the integration in HA.

smedomi commented 6 months ago

Thanks for the quick reply!

No factory reset - only changed the pin in the app on my phone.

I don't seem to be able to kick a new UUID. When I try I get the message "Failed to kick. Please check your values". I checked IP, serial number and tried with several new generated UUID as well as the 'old' UUID as stored on HA. Tried several times but unsuccessful. No unintended spaces, really checked well.

Fyi - what's a bit weird in the app is that you don't even seem to need to provide the existing pin but you can just enter a new one... I don't need to provide a pin to access the app on my phone either (using iPhone) For clarity here is where I changed it in the app: image

image
dupondje commented 6 months ago

To generate a new uuid you need to enter the IP and the PIN, not the serial number anymore once you've set the PIN code.

smedomi commented 6 months ago

It crossed my mind at some point ... should have tried...

Just kicking a new UUID with the index.html file and adding that to the config file did the trick!

Many thanks! Owe you a pintje ;-)