marcelwestrahome / home-assistant-niu-component

niu scooter integration for Home assistant.
Apache License 2.0
46 stars 28 forks source link

Installation not working #46

Closed jevburchell closed 1 year ago

jevburchell commented 1 year ago

Having trouble installing this component - have downloaded via HACS and also tried manually copying custom_components folder. Both have no entities showing after entering the sensor code into configuration.yaml and altering login details. Email and password definitely correct and code set to 44 (uk). Scooter_id is 0.

There is an integration which appears in devices & services > add integration called “Nui Scooters” [sic] but on attempting to add the integration it says “ This device cannot be added from the UI, You can add this device by adding it to your 'configuration.yaml'. See the documentation for more information.“

I’m a little unsure what to try next. Can anyone help?

marcelwestrahome commented 1 year ago

strange for me the integration works for me for more then 2 years, do you get any errors in your logs ?

jevburchell commented 1 year ago

do you get any errors in your logs ?

I do, yes:

Logger: homeassistant.components.sensor Source: custom_components/niu/sensor.py:375 Integration: Sensor (documentation, issues) First occurred: 10:34:28 (1 occurrences) Last logged: 10:34:28

Error while setting up niu platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/niu/sensor.py", line 375, in setup_platform sn = get_vehicles_info(api_uri, token)["data"][scooter_id]["sn"] IndexError: list index out of range

I’ve no idea what any of this means but happy to try any fixes to get it working. Thanks 🙏

marcelwestrahome commented 1 year ago

wat is the name of your scooter

jevburchell commented 1 year ago

wat is the name of your scooter

It’s a Niu NQi GTS - 2019

marcelwestrahome commented 1 year ago

I update the version in HACS and with me it is working. Be aware you scooter name in your niu app can not have special characters

jevburchell commented 1 year ago

I update the version in HACS and with me it is working. Be aware you scooter name in your niu app can not have special characters

Amazing, your update has allowed me to install and the repo looked totally updated in HACS. Thank you. I now have my credentials in and the integration has found the name of my scooter. All entities showing “Unknown” at the moment but I guess this might take a little while to update. Once this is resolved I’ll be up and running :)

jevburchell commented 1 year ago

I update the version in HACS and with me it is working. Be aware you scooter name in your niu app can not have special characters

Amazing, your update has allowed me to install and the repo looked totally updated in HACS. Thank you. I now have my credentials in and the integration has found the name of my scooter. All entities showing “Unknown” at the moment but I guess this might take a little while to update. Once this is resolved I’ll be up and running :)

To clarify, the integration is installed but I’ve no data yet

jevburchell commented 1 year ago

Screenshot_20230523_181907_Home Assistant

Nil data persisting on all entities after installation. Integration has pulled my scooter name from my account so login credentials are definitely correct. I have no special characters in scooter name. Have tried reloading integration and restarting HA, with no effect.

@marcelwestrahome what could I try?

Zamboniman commented 1 year ago

Did you get this sorted out @jevburchell ? I am having precisely the same issue.

jevburchell commented 1 year ago

Did you get this sorted out @jevburchell ? I am having precisely the same issue.

It’s not working no, I’ve tried reinstalling multiple times, reloading the integration, changing the scooter_id, changing the country code from 44, nothing is having any effect. @marcelwestrahome is there anything else we can do to get this working?

Zamboniman commented 1 year ago

Yes, precisely the same issue here despite trying various similar things. I certainly hope this gets a response so we can work on sorting this out. As it stands, this integration is completely non-functional.

marcelwestrahome commented 1 year ago

Hi I am on holiday at this moment. So can not look to this in detail. The older version is still working, so if you realy need the integration.. All names of sensors are the same for both versions. I installed the integration by myself and it is still working in the Netherlands, so may be it has something to do with location.

Zamboniman commented 1 year ago

Thank you for the response. I was thinking it may have something to do with the country as well. I am in Canada so am using country code 1.

Enjoy your holiday! I look forward to more investigation of this issue once you're available.

jevburchell commented 1 year ago

Sorry to disturb you on holiday Marcel. Happy to wait and assist in any way I can at a later date. It’s a very useful integration (I’ll be automating the charging of my scooter from excess solar generation) so I’m looking forward to seeing it in action :)

marcelwestrahome commented 1 year ago

Try to do some research with my phone, @jevburchell,@Zamboniman, you both not in Europe, right. Its seems the interface (the url) that is used works only for europe @pikka97 you any comments. I am based in the Netherlands, for me the plugin is working well, so makes me difficult to solve the issue :-(

jevburchell commented 1 year ago

I’m in Scotland 🏴󠁧󠁢󠁳󠁣󠁴󠁿

Zamboniman commented 1 year ago

And I am in Canada

jevburchell commented 1 year ago

Try to do some research with my phone, @jevburchell,@Zamboniman, you both not in Europe, right.

So given that I'm in Europe, the url should work? Possibly there is another bug in the mix

syssi commented 1 year ago

May be somebody could provide (in private) a mitmproxy capture of the Android app traffic. It's pretty simple to record such a capture: https://github.com/cascha42/niu-info#how-to-get-your-token

It will help to understand the differences between the different countries / regions.

Zamboniman commented 1 year ago

Thanks @syssi

The URL it's attempting is https://ncsi-fk.niu.com on port 443

For Home Assistant, it's definitely getting some information as it knows the make, model, serial, etc of my scooter, but none of the entities are getting data.

I can send more details if required. Let me know what specific info you need from mitmproxy.

syssi commented 1 year ago

Could you provide the full capture by mail?

Zamboniman commented 1 year ago

Sure. Not quite sure what info you needed from mitmproxy or how to access it as I've never used this before. I sent screenshots of the Request, Response, and Detail screens of the NUI app contacting the server. Let me know what else is needed and how to go about accessing that.

syssi commented 1 year ago

Could you update the files at your custom_components/niu folder and apply these changes just for testing?

https://github.com/marcelwestrahome/home-assistant-niu-component/pull/49/files

jevburchell commented 1 year ago

Could you update the files at your custom_components/niu folder and apply these changes just for testing?

https://github.com/marcelwestrahome/home-assistant-niu-component/pull/49/files

I have edited the code in api.py and const.py as specified here. Reloaded all YAML, restarted HA, Reloaded Integration and Restarted HA again with no change - all entities still Unavailable

Zamboniman commented 1 year ago

Made the changes requested. Unfortunately, the integration is not working at all now. No entities. I'm just double checking now to make sure I didn't mess up the editing of api.py and const.py

jevburchell commented 1 year ago

Made the changes requested. Unfortunately, the integration is not working at all now. No entities. I'm just double checking now to make sure I didn't mess up the editing of api.py and const.py

Ah, I now have the same effect as @Zamboniman - all entities are gone. I've deleted the integration and reinstalled and now it's empty - no device or entities within the integration

Zamboniman commented 1 year ago

Dump file from mitmproxy sent.

syssi commented 1 year ago

Thanks! I will have a look tomorrow.

Zamboniman commented 1 year ago

Thanks! Let me know if there's anything else I can do to help.

syssi commented 1 year ago

I've pushed some more changes. You can download the updated version here:

https://github.com/syssi/home-assistant-niu-component/archive/refs/heads/update-api-version.zip

Please overwrite the content of the custom_components/niu folder and restart Home Assistant for testing.

jevburchell commented 1 year ago

I've pushed some more changes. You can download the updated version here:

https://github.com/syssi/home-assistant-niu-component/archive/refs/heads/update-api-version.zip

Please overwrite the content of the custom_components/niu folder and restart Home Assistant for testing.

Amazing, this has worked for me. I see the entities and they are populated with data. Thank you kind sir for your excellent support. It is highly appreciated. This will be extremely useful :)

Zamboniman commented 1 year ago

This update seems to have done the trick. Most of the entities now have data. However, none of the 'last track' entities are working, all still show 'unknown'.

Zamboniman commented 1 year ago

Also, 'max times charged' shows unknown, and latitude and longtitude show '0'

marcelwestrahome commented 1 year ago

please create a new issue