Giter Site home page Giter Site logo

Comments (5)

azalin1975 avatar azalin1975 commented on August 28, 2024 1

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.

marcelwestrahome avatar marcelwestrahome commented on August 28, 2024

Why do you want to change this ?

from home-assistant-niu-component.

syssi avatar syssi commented on August 28, 2024

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:

  1. 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
  1. Introduce a DataUpdateCoordinator to retrieve the data from the API endpoints once and distribute these data to all entities (sensor and binray_sensor).

This is the preliminary work that is necessary to be able to register binary_sensors (with boolean state). I have avoided this work until now because the the added value is low.

from home-assistant-niu-component.

sethiele avatar sethiele commented on August 28, 2024

Hi,
it follows the documentation, and it generates a better view (with better semantic) in the UI.

from home-assistant-niu-component.

marcelwestrahome avatar marcelwestrahome commented on August 28, 2024

component has a new setup

from home-assistant-niu-component.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.