Giter Club home page Giter Club logo

battery_control's Introduction

Battery_Control.py

Set image on battery sensors to show state.

Install:

Download the pictures you want. Green, Yellow and Red battery images are available in this repository. Update the config below to match the names you give them in your system. Place them in the .homeassistant/www directory. Create the www directory if its not there. Put the Battery_control.py app in your appdaemon code storage directory. Add the app to your appdaemon.cfg file as follows

[battery_control]
module=battery_control
class=battery_control

  Setup the self.batteries JSON string below as follows All non-numeric values must be in double quotes
  batteries={"sensor.upstairs_sensor_battery":{"attribute":"state",
                                               "levels":{"1":{"value":25,"img":"/local/battery1.jpg"},
                                                     "2":{"value":50,"img":"/local/battery2.jpg"},
                                                     "3":{"value":75,"img":"/local/battery3.jpg"},
                                                     "4":{"value":100,"img":"/local/battery4.jpg"}},
                                               "notify":"EmailChip"},
           "sensor.office_sensor_battery":{"attribute":"state",
                                               "levels":{"1":{"value":33,"img":"/local/battery1.jpg"},
                                                     "2":{"value":66,"img":"/local/battery2.jpg"},
                                                     "3":{"value":100,"img":"/local/battery4.jpg"}},
                                             "notify":"EmailChip"}}

Setup the self.batteries JSON string below as follows, remember to use double quotes.

  self.batteries={"<HA Sensor name for battery state>":
                        {"attribute":"<Attribute name>",
                         "levels":{"1":{"value":<Max value for this level>,"img":"<ImageFile>"},
                                   "2":{"value":<Max value for this level>,"img":"<ImageFile>"},
                                   "3":{"value":<Max value for this level>,"img":"<ImageFile>"},
                                   "4":{"value":<Max value for this level>,"img":"<ImageFile>"}},
                         "notify":"<HA Notify Component>"},
                  "<repeat for next sensor>":
                        {"attribute":"<Attribute name>",
                         "levels":{"1":{"value":<Max value for this level>,"img":"<ImageFile>"},
                                   "2":{"value":<Max value for this level>,"img":"<ImageFile>"},
                                   "3":{"value":<Max value for this level>,"img":"<ImageFile>"}},
                         "notify":"<HA Notify Component>"},
                  }
                  
  • HA Sensor name : The full sensor name : sensor.den_sensor_battery
  • attribute : the attribute that holds the battery level (state, battery_level, etc)
  • levels : one or more levels that are represented by icons on the page. In the example above, one sensor uses four levels, while the other uses three.
    • value : max value for battery levels contained in that level
    • img : image file to display as icon. Must be in .homeassistant/www directory. I know it says /local/, I don't know why, but this is how it works.
  • notify (Optional) : HA notify component to send message. Only one notify method is allowed per sensor but different sensors can use different notify methods. Sensor A can send a page sensor b can send an email. Just set up notify components in you HA configuration.yaml file.

battery_control's People

Contributors

turboc1208 avatar

Watchers

James Cloos avatar  avatar

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.