marcelwestrahome / home-assistant-niu-component Goto Github PK
View Code? Open in Web Editor NEWniu scooter integration for Home assistant.
License: Apache License 2.0
niu scooter integration for Home assistant.
License: Apache License 2.0
Hey,
Would you mind adding a new entity with both latitude and longitude attributes so this entity can be used to display the location of the scooter on the map?
https://www.home-assistant.io/lovelace/map
Thank you :)
What format does the Country setting take in the sensor setup?
Telephone Country code eg +49
International Country code eg DE
Global Country name eg Germany
or
Local Country name eg Deutschland
??
I can't get it to connect but narrowing down the correct format will at least put me one step closer.
I configured the integration as to the README but unfortunately I get the following error
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, 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 392, in setup_platform
NiuSensor(
File "/config/custom_components/niu/sensor.py", line 499, in __init__
self._state = self._data_bridge.dataDist(self._id_name)
File "/config/custom_components/niu/sensor.py", line 425, in dataDist
return self._dataMoto["data"]["lastTrack"][id_field]
KeyError: 'distance'
Configuration in configuration.yml
- platform: niu
username: *****
password: *****
country: 49
scooter_id: 0
monitored_variables:
- BatteryCharge # Battery
- Isconnected # Battery
- TimesCharged # Battery
- temperatureDesc # Battery
- Temperature # Battery
- BatteryGrade # Battery
- CurrentSpeed # Moto
- ScooterConnected # Moto (has attributes lon. lat. for plotting on a map)
- IsCharging # Moto
- IsLocked # Moto
- TimeLeft # Moto
- EstimatedMileage # Moto
- centreCtrlBatt # Moto
- HDOP # Moto
- Longitude # Moto
- Latitude # Moto
- totalMileage # OverAll
- DaysInUse # OverAll
- Distance # Distance
- RidingTime # Distance
- LastTrackStartTime # LastTrack
- LastTrackEndTime # LastTrack
- LastTrackDistance # LastTrack
- LastTrackAverageSpeed # LastTrack
- LastTrackRidingtime # LastTrack
- LastTrackThumb # LastTrack
NIU NQi Sport FW TRA01E19
Some of my entities now have correct data after issue #46 was solved, however not all of them do.
The following entities continue to show 'unknown' or have meaningless data:
So it appears certain entities are still not getting data from the server correctly.
Hi. I've installed the component and configured it. I receive this error when it inits:
2022-08-01 13:38:35 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up niu platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, 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 392, in setup_platform
NiuSensor(
File "/config/custom_components/niu/sensor.py", line 503, in __init__
self._state = self._data_bridge.dataTrack(self._id_name)
File "/config/custom_components/niu/sensor.py", line 436, in dataTrack
(self._dataTrackInfo["data"][0][id_field]) / 1000
TypeError: 'bool' object is not subscriptable
Platform error sensor.niu - Exception importing custom_components.niu.sensor
Unexpected exception importing platform custom_components.niu.sensorTraceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 657, in get_platform cache[full_name] = self._import_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 674, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 879, in exec_module File "", line 1017, in get_code File "", line 947, in source_to_code File "", line 241, in _call_with_frames_removed File "/config/custom_components/niu/sensor.py", line 564 self._state = self._data_bridge.dataBat(self._id_name) IndentationError: unexpected indent
After upgrading to 2022.8.0b4 no values are returned.
Awesome work, but hasnt able to make it work. I created a python_scripts folder inside the config root folder, inside I have placed the sensor.py and I added the yaml to the configuration.yaml, but it shows as invalid niu component is not a component. if you can write install instructions it would help a lot, I was able to get my token already dont know if that helps. Thank you, keep the great work!
I using niu rqi with China app/ How to connect to China services?
I saw your comment on my pull request for the niu integration in home assistant and looked into this repo. The known bug that's causing the updates to stop is fixed by Niu in the scooters firmware v3,TRA01E18. This update has to be manually installed at a authorized dealer (so no automagical OTA install). I have this version on my scooter for a while and it's stable for me 👍
I have tested your component for NIU scooter integration and it seems to work OK, but lately I am experiencing problems with my HA instance that perhaps is due to communication locking up occasionally.
I have this example in my log:
Logginformation (WARNING)
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:545
Integration: Sensor (documentation, issues)
First occurred: 21:06:15 (3 occurrences)
Last logged: 21:08:18
Updating niu sensor took longer than the scheduled update interval 0:00:30
Does this mean that the fetching of information does not time out until 30 seconds has passed? Couldn't this potentially lock up the frontend/backend of Home Assistant?
Also I am not aware of how often the values are polled from NIU, perhaps introducing a configuration option for poll interval would be possible to implement?
it says Unsupported url if you add it to Blueprints
Dear.
Since HA version 2021.6.0 the component doesen't work anymore.
I get this message:
Platform error sensor.niu - Integration 'niu' not found.
I've tried to reinstall it but nothing.
This situation stops HA from restarting or updating.
Thanks
Andrea
I would be happy if you add a license to the code / repository. An Apache 2.0 license would be cool!
I have installed this component added the config as described.
I only see this in my log and no new sensors: 2020-07-14 13:02:47 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for niu which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
Hi, Thank you very much to supply this component.
Could you consider to support +86 (China) Country Code ?
Here is the log:
2021-11-28 22:59:57 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up niu platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/niu/sensor.py", line 374, in setup_platform
token = get_token(username, password, country)
File "/config/custom_components/niu/sensor.py", line 287, in get_token
return data["data"]["token"]
KeyError: 'token'
Can you update the component for working with the API instead using username/password?
Hello, I have installed this extension (v 2.1.3) using HACS.
It detected my scooter but it only refresh data when I reboot home assistant.
Hi,
first of all - thank you for providing this component!!
As I was trying to activate this component, I found an issue that should be easily resolvable :)
If the Name of the scooter contains whitespaces or includes capital letters, you get the error below. So if you would implement x.lower and maybe replace whitespaces, this should be it.
Log:
2020-08-23 21:06:30 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up niu platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 192, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 443, in _async_add_entity
raise HomeAssistantError(f"Invalid entity id: {entity.entity_id}")
homeassistant.exceptions.HomeAssistantError: Invalid entity id: sensor.niu_scooter_NAME_battery_charge
Thanks!
The NIU scooter is no longer showing on the map. The scooterconnected no longer has lat&long attributes. Any ideas on how ti fix this?
I tried changing the password several times but it will be stuck at 88% battery nomatter what the real value is
Brands PR: home-assistant/brands#2646
Custom wheels PR: Not required. No third party library in use.
HACS PR: hacs/default#998
I bought my Niu MC in August last year, and am very happy with the HA integration! However, my experience is that the integration stops receiving/updating data after a while, and the only fix is to restart the entire HA instance. Reloading the the integration is not successful. Is this familiar, and/or is there a fix?
Please change the device Class of the following sensor values to the right class.
I'm not a python developer so I can understand the code but can't change it. But I hope I found the right code lines.
sensor.niu_scooter_$NAME_isconnected
connectivity
sensor.niu_scooter_$NAME_ischarging
battery_charging
sensor.niu_scooter_$NAME_islocked
lock
Thanks
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.