Comments (5)
Just to throw in my two cents.
If you need and want any of these sensors to be binary_sensors, you could create either a template sensor or a threshold sensor. What I did was create a threshold sensor since I did not have any experience with template sensors until not so long ago. I created a threshold sensor and set the upper limit to 0,5. This way when for instance the ischarging sensor is 1, it will be above 0,5 and thus be true. When back to 0 the sensor is set to false because that is obviously lower than 0. I created these kind of sensors in HA for _ischarging, _islocked and _isconnected.
I then also decided to dig into the template sensors because I wanted to add my NIU moped/scooter on a map. So I created a template sensor like this:
- sensor:
- name: NIU MQi GT
unique_id: niu_mqi_gt_device
state: "{{ states('binary_sensor.niu_scooter_is_locked') }}"
picture: /local/local-images/niu-scooter-mqi-gt.png
attributes:
latitude: "{{ states('sensor.niu_scooter_axelf_latitude') }}"
longitude: "{{ states('sensor.niu_scooter_axelf_longitude') }}"
Which shows me an image of the scooter/moped (taken from the NIU official website and uploaded it to my own HA to prevent any dependancies on their website structure) in the location reported by the sensors.
Now, I am fully aware you don't need to create a template sensor for this, you can justr use the _scooterconnected sensor but I wanted a custom image to appear on the map instead of the letters of the sensor name. I had no idea if I could modify the existing sensor to accomodate for this. So, if someone has a better way of doing this, I am happy to take suggestions for my configuration.
from home-assistant-niu-component.
Why do you want to change this ?
from home-assistant-niu-component.
Please keep in mind: This isn't an easy task and will be a breaking change. I will try to describe the required steps to be able to register binary_sensor
entities:
- Move the platform schema from
sensors.py
to__init__.py
. So we can load & setup the platform like this:
niu:
username: [email protected]
password: mysecretpassword
country: 49
scooter_id: 0
- Introduce a
DataUpdateCoordinator
to retrieve the data from the API endpoints once and distribute these data to all entities (sensor
andbinray_sensor
).
This is the preliminary work that is necessary to be able to register binary_sensor
s (with boolean state). I have avoided this work until now because the the added value is low.
from home-assistant-niu-component.
Hi,
it follows the documentation, and it generates a better view (with better semantic) in the UI.
from home-assistant-niu-component.
component has a new setup
from home-assistant-niu-component.
Related Issues (20)
- Known bug is solved by new firmware (v3,TRA01E18) HOT 2
- no location HOT 4
- Add new oauth2 endpoint support HOT 24
- location on map HOT 1
- downloding i HOT 1
- Integration not working after HA update to 2022.8.0b4 HOT 3
- dataTrack - TypeError: 'bool' object is not subscriptable HOT 3
- No sensors found... HOT 2
- component doesn't work when updated to home assistant os 8.5
- KeyError: 'distance' HOT 6
- Battery Status never updates
- Installation not working HOT 34
- china 86 HOT 2
- Several entities still not populating after issue #46 was fixed HOT 6
- data never refresh HOT 43
- not work with China service HOT 6
- Only Last Track sensor available HOT 1
- Integration hangs until HA restart HOT 4
- Invalid authentification HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from home-assistant-niu-component.