Hello everyone,
For about 1 week i am a proud owner of the Niu N1s electric scooter ( https://www.niu.com/en/ ). There is an app in iOS and Android markets that can be used to see info about the scooter(location, battery, etc) and it would be nice if there are other owners that want to integrate this in homeassistant or nice people that are willing to help. Probably some reverse engineering is needed to find out how we can integrate it.
Looking forward to hear some good news.
Thanks
Share your projects is for people who have something to share. I think you are looking for “feature requests”.
Topic moved to featured requests. Would be nice even if it will be a custom component and not a homeassistant integrated one.
Hey guys, I did a little something there. It is no custom component but at least something:
Check it out here https://github.com/H89P/niu_card
Managed to do something similar using only REST sensor from homeassistant and some lovelace card. So we can close this future request unless someone wants to make a custom component, definitely it would be nice but i don t have python knowledge for that
Please explain what you did and how you got there.
I’ve setup up everything as per you git repo (Except I’m not using Hass.io, but that shouldn’t be an issue) and I’ve entered my SN & API token but I’m not getting any actual data from the device. My MQTT messages are like this:
node_red/niu_last_ride_starttime {"data":"","desc":"参数错误","status":1301,"trace":"参数错误"}
node_red/niu_last_ride_endtime {"data":"","desc":"参数错误","status":1301,"trace":"参数错误"}
node_red/niu_last_ride_distance {"data":"","desc":"参数错误","status":1301,"trace":"参数错误"}
node_red/niu_last_ride_avgspeed {"data":"","desc":"参数错误","status":1301,"trace":"参数错误"}
node_red/niu_last_ride_ridingtime {"data":"","desc":"参数错误","status":1301,"trace":"参数错误"}
node_red/niu_last_ride_date {"data":"","desc":"参数错误","status":1301,"trace":"参数错误"}
node_red/niu_battery (null)
node_red/niu_mileage 0
node_red/niu_battery_temp 0
node_red/niu_consumed_today 0
node_red/niu_charge_count {"data":{"batteries":{"compartmentA":{"bmsId":"","isConnected":true,"gradeBattery":"100","faults":[],"healthRecords":[]}},"isDoubleBattery":false},"desc":"成功","trace":"成功","status":0}
node_red/niu_battery_grade 100
node_red/niu_latitude (null)
node_red/niu_longitude (null)
I know that my token & SN are correct, so I’m lost as to what is going wrong. Any ideas?
It seems that the Chinese characters translate as “Parameter Error”, and the ones in the “niu_charge_count” translate as “success”…
EDIT
After a bit of routing through other repos I could see that a different api url was being used. I changed the api call from https://app-api.niu.com
to https://app-api-fk.niu.com
and it all appears to be working now.
i didn’t use node-red, i used some rest sensors to get the data:
- platform: rest
name: Niu N1s scooter
resource: https://app-api.niu.com/v3/motor_data/index_info?sn=YOURSERIALNUMBER
headers:
token: Bearer YOURTOKEN
value_template: '{{ value_json.value }}'
json_attributes:
- data
scan_interval: 600
- platform: template
sensors:
niu_batteryisconnected:
friendly_name: 'Niu battery'
value_template: '{{ states.sensor.niu_n1s_scooter.attributes["data"]["batteries"]["compartmentA"]["isConnected"] }}'
niu_batterypercentage:
friendly_name: 'Niu battery percentage'
value_template: '{{ states.sensor.niu_n1s_scooter.attributes["data"]["batteries"]["compartmentA"]["batteryCharging"] }}'
unit_of_measurement: '%'
niu_estimatedmileage:
friendly_name: 'Niu range'
value_template: '{{ states.sensor.niu_n1s_scooter.attributes["data"]["estimatedMileage"] }}'
unit_of_measurement: 'km'
Using this created sensors i did some automations, scripts and input_number to be able to calculate and know what time should i charge the battery to reach the desired %
final result is
Hope it helps you.
Cheers!
Thanks for that.
I actually went for the Node Red option and that works well but not perfectly I actually didn’t know about the REST sensor, so that is really interesting and I like the simplicity of your solution.
I might have a play with doing something similar.
Thanks.
So cool and way simpler can you share the whole sensor lists? I would appreciate your help
Really great job!
I am using it and it works perfectly.
I did everything you describe in the read me, but no way. Maybe the country code is wrong ?
For Italy is niu_country: italy ?
There is an unanswered issue on github re format of country.
can use in the niu china??
Hi, i don’t understand how can i find my Token.
Is this still working?
I added it to HACS in home assistant, installed, configured. But it is not working.
In general the custom integration should still do the job. It works fine here.
Are you get information, how to use this component with china scooters/app