Monitoring Smart Home Device Battery Levels with Home Assistant

Sdílet
Vložit
  • čas přidán 17. 03. 2023
  • In this video, I cover how to download and install the custom battery card, two required sensors for monitoring, as well as an automation to alert you when a device has a low battery.
    If you'd like to support the channel, you can do so by becoming a Patron at / fasthowto
    This episode's t-shirt: amzn.to/3JrZy9t
    HACS: • Home Assistant startin...
    Mushroom cards: • How to create a Home A...
    IMPORTANT! CZcams does not allow the use of '<' or '>' in descriptions. The characters below LOOK like those, but they are NOT THE SAME. Wherever you see one of those characters below, delete them and replace them with the same character (above the period or the comma). Thank you!
    battery card configuration code:
    ---
    type: custom:battery-state-card
    color_gradient:
    - '#ff0000'
    - '#ffff00'
    - '#00ff00'
    entities:
    - entity: sensor.my_device_battery
    name: My Sensor
    ---
    Mushroom template card code:
    Icon:
    ---
    {% if is_state('binary_sensor.devices_with_low_battery', 'on') %}
    mdi:battery-10
    {% else %}
    mdi:battery
    {% endif %}
    ---
    Icon Color:
    ---
    {% if is_state('binary_sensor.devices_with_low_battery', 'on') %}
    red
    {% endif %}
    ---
    sensor:
    - platform: template
    sensors:
    devices_with_low_battery:
    friendly_name: 'Devices with low battery'
    unit_of_measurement: devices
    value_template: >-
    {% set ignore_entities = ['sensor.device1_battery_level','sensor.device2_battery_level'] %}
    {{ states.sensor
    | selectattr('attributes.device_class', 'eq', 'battery')
    | rejectattr('entity_id', 'in', ignore_entities)
    | map(attribute='state')
    | map('int', -1) | select('le', 10)
    | list | count
    }}
    icon_template: >-
    {% if is_state('sensor.devices_with_low_battery', '0') %}
    mdi:check-circle
    {% else %}
    mdi:battery-alert
    {% endif %}
    binary_sensor:
    - platform: threshold
    entity_id: sensor.devices_with_low_battery
    name: Devices with low battery
    upper: 0.5
    Some of my favorite home automation things:
    Aqara temperature and humidity sensor (zigbee): amzn.to/3X2ubr3
    Aqara water leak sensor (zigbee): amzn.to/3JkWH3P
    Aqara door & window sensor (zigbee): amzn.to/3Ril7N7
    Aqara mini switch (zigbee): amzn.to/3HlmmGK
    Aqara motion sensor (zigbee): amzn.to/3kV2eDS
    Zigbee and Zwave coordinator: amzn.to/3yuqPTG
    USB extension for Zigbee/Zwave sticks: amzn.to/3ySQGVL
    Intel Nuc: amzn.to/3JcVivA
    KASA outdoor outlet (wifi): amzn.to/3XOLoFl
    KASA indoor outlet HS103 (wifi): amzn.to/3XOLVai
    KASA single pole dimmer HS220 (wifi): amzn.to/3HgOaft
    KASA single pole switch HS200 (wifi): amzn.to/3HHNEsC
    KASA three way switch HS210(wifi): amzn.to/3kSZ0ks
    KASA three way dimmer KS230 (wifi)" amzn.to/3kQm2s8
    Shelly 2.5 relay switch (wifi): amzn.to/40drGon
    Honeywell T9 thermostat (wifi, homekit): amzn.to/3WOVvsD
    Honeywell T9 remote zone sensor: amzn.to/3jfr5Sw
    Sonoff S31 Lite smart plug (zigbee): amzn.to/3HDsb3U
    Sonoff S31 smart plug with power monitoring (zigbee): amzn.to/40fkvMk
    Sengled bulbs (zigbee): amzn.to/3JH95vl
    MyQ Homebridge for Chamberlain/Liftmaster MyQ garage door openers (wifi, homekit): amzn.to/3DrfxSW
    MyQ Chamberlain/Liftmaster garage door controller for non-MyQ openers (wifi): amzn.to/3HIctVm
    August 4th generation WiFi smart lock: amzn.to/3ksXZj3
    Motorola MoCA Adapters: amzn.to/41h9LxI
    My studio gear:
    Canon 90D: amzn.to/3WOvmKz
    Canon EF 28mm f/1.8 USM: amzn.to/3DkPvAH
    Canon EF 50mm f/1.4 USM: amzn.to/3jinlQk
    Canon EF-S 17-55 f/2.8 IS USM: amzn.to/3kRZgQK
    Canon AC adapter: amzn.to/3RgogNC
    Canon DC coupler: amzn.to/3HcmTuK
    Lexar Pro 128GB SDXC cards: amzn.to/3Drg7jA
    ProGrade SD card reader: amzn.to/3HmPRYQ
    Lowepro ProTactic 450 camera bag: amzn.to/3DoJras
    Manfrotto 055 CX Pro tripod: amzn.to/3XOaMei
    Manfrotto 055LC leveling center column: amzn.to/40aYm1R
    Manfrotto MVH502AH fluid head: amzn.to/40eyOkw
    Rode NTG-3B mic: amzn.to/3kGEbIL
    Rode SM4-R shockmount: amzn.to/3Y8zo1m
    Shure SM7B mic: amzn.to/3wEnX5H
    Zoom H4n pro 4-track digital recorder: amzn.to/3Y365x6
    Zoom F6 digital field recorder: amzn.to/3ZWxjHa
    Cloudlifter: amzn.to/3Z31tqO
    GLS balanced XLR cables: amzn.to/3kXb97K
    TASCAM DR-10 lav mic: amzn.to/3kRvGLb
    windjammer for lav mics: amzn.to/3HFPDNM
    Neewer boom arm mic stand: amzn.to/3WH8YCI
    Samson MD5 mic stand: amzn.to/3HHP46q
    Aputure Amaran 100x lights: amzn.to/40dJqQp
    Aputure Light Dome SE: amzn.to/40dJBex
    Light stands: amzn.to/3Rethq2
    Green screen: amzn.to/3jcOjJ3
    Rim light: amzn.to/3RkyzQW
  • Věda a technologie

Komentáře • 50

  • @arthurkazanis4283
    @arthurkazanis4283 Před 6 měsíci +2

    Great video. Accurate and to the point. I also learnt some stuff on template cards. Love your work Jeff.

    • @fasthowto
      @fasthowto  Před 6 měsíci

      Thank you for the kind words, and thanks for watching!

  • @KozakPlus
    @KozakPlus Před 10 měsíci +2

    Really usefull, concise and exciting videos from Mr. Jeff. Thank you a lot and greetings from Ukraine

    • @fasthowto
      @fasthowto  Před 10 měsíci +1

      Many thanks, glad you are enjoying the videos! Thank you for watching!

  • @HATipsByLarry
    @HATipsByLarry Před rokem

    Off topic i know but finally got one of the aqara FP1 mmWave presence detector. Works really well, no false positives about movement. I use it to turn the lights off and use my existing PIR motion sensor to turn the lights on as the FP1 takes about 5 to 10 secs to detect motion again. This works great even me not trying to move and it still see's my chest moving when I breath.

  • @DanBrown1010
    @DanBrown1010 Před 4 měsíci +1

    Excellent work! Earned my sub!!

    • @fasthowto
      @fasthowto  Před 4 měsíci

      Thank you so much for the kind words, and thank you for watching - and for the sub! :)

  • @Hupihovi
    @Hupihovi Před rokem +1

    Good job man! Man of your word ;)

    • @fasthowto
      @fasthowto  Před rokem +1

      Thank you! It actually shipped this morning. Been a bear of a week at my day job.
      Do you have any creative ideas for giving away these two Fire 10 tablets I've still got? Doesn't look like those guys are going to come forward any time soon... LOL

  • @OutdoorDreamsHunt
    @OutdoorDreamsHunt Před rokem +1

    Love watching this content just for the shirt messages 😂

  • @RandomTorok
    @RandomTorok Před 2 měsíci

    I am working on a couple of devices that are basically thermometers. One will be a weather station that I will put outside and it will record temperature, humidity and barometric pressure. I've got it running on an TTGO T-Dislplay and powered by 2 18650 batterys. I have a 4056 charger connect to the battery and the device with a small solar panel connect to the charger. I'm not sure that the small solar panel is sufficient to power the device as well as charge the battery. My dashboard card currently shows the temperature, humidity, pressure as well as battery voltage and battery level. What I'd really like is a battery state that shows charging or discharging. The dashboard card for my phone has this field. Would you know how I can add battery state for my weather station?

  • @killerx4307
    @killerx4307 Před 2 měsíci

    Nice video.. You are the reason that make me to convert my home to a Smart Home.. and you are a true smart home solver!

    • @fasthowto
      @fasthowto  Před 2 měsíci +1

      Thank you so much for the kind words! I'm so happy to hear that my videos are helpful. :) thanks for watching!

  • @HATipsByLarry
    @HATipsByLarry Před rokem +1

    I use a blue print called Low battery level detection & notification for all battery sensors. This blue print allows you to set % low battery warning, time to make the test, days of week, month, year to test (i have it do it at 4am every day) and then you can set any action you want HA to take when it drops below the level you set from notifying you to blinking a light to saying it on your assistant of choice to whatever you want. It automatically adds any new sensors to its list of sensors as you add them (as long as they are battery operated). You can also exclude any sensors that you wish for it not to check as well. Been running this for over a year now and it works great. 😀 Just have to import the blueprint and fill in the % low battery warning days to test and actions to take and that's it. All GUI based no coding at all.

    • @fasthowto
      @fasthowto  Před rokem

      Sounds interesting! Why do you have to tell it when to test though, and what exactly is it "testing"? The devices all report their battery status, so... ??

    • @HATipsByLarry
      @HATipsByLarry Před rokem

      @@fasthowto Wrong word i guess, It's checking the battery levels at that time. It works well though in 24 hours your not going to lose more then a % or 2 on battery level anyway so 🤷‍♂

    • @fasthowto
      @fasthowto  Před rokem

      @@HATipsByLarry No, I understood what you meant, but I still don't understand why anything has to be "checked". The battery state is always known/available to HA. I guess this is simply one area where the way I did it is better since I get instant notification when a device battery requires replacement, rather than only when I schedule it to check. :)

    • @HATipsByLarry
      @HATipsByLarry Před rokem

      @@fasthowto Possibly but i have had no problems at all this way and its completely code free on part of the user so easier to setup and use in that regard. 😀

    • @fasthowto
      @fasthowto  Před rokem +1

      @@HATipsByLarry code-free isn't the plus many people think it is. IMO, it does a disservice to people. There are a LOT of things that can only be done in code, so refusing to learn that skill leaves them with a system not living up to it's full potential. ;)

  • @MadMike78
    @MadMike78 Před 9 měsíci

    I don't have the same settings as you do for the alert trigger to send a notification. Do i need to install something?

    • @fasthowto
      @fasthowto  Před 6 měsíci

      Do you have the companion app installed on your phone?

  • @frankraym
    @frankraym Před rokem

    My other question as well is if I have another device that goes low battery will I get notified ? Since the automation from the beginning of the video has when it goes from off to on. But if you have already a low battery it stays on and when another device would get low battery it won't switch from off to on....unless I don't fully understand

    • @fasthowto
      @fasthowto  Před rokem

      Great question! Your understanding ia correct. If you want multiple notifications, you'd need to add additional sensors and rewrite the automation, or you'd need to notify based on each device individually. I have WAY too many devices for that. (In fact, you'll see the same logic in my upcoming video on environment change notifications). Since I keep batteries for everything on hand, when I get a notification, I look at the batteries view and see what device needs batteries. Then I go replace them, and I'm back to green and the red light on the card on the dashboard turns off. No idea why you would let one device sit there long enough with a near-dead battery that a second would also go into that state - but regardless, if it happens it should easily be seen on the batteries view by the red battery icon in a sea of otherwise green/yellow.
      Thanks for watching!

  • @travismailsa1
    @travismailsa1 Před rokem

    Thanks, once configured how do you set a homeassistant notification to notify you when a battery is at or below a certain level?

    • @fasthowto
      @fasthowto  Před rokem

      Did you watch the video?

    • @travismailsa1
      @travismailsa1 Před rokem +1

      @@fasthowto shot for the reply, I did watch the entire video yes. And setup exactly as shown just modified the sensors/batteries I want monitored.

    • @fasthowto
      @fasthowto  Před rokem

      @@travismailsa1 OK, cool. Perhaps I didn't understand what you were asking then? Could you try to explain what you'd like to do in a little greater detail?

    • @travismailsa1
      @travismailsa1 Před rokem

      I have the exact same setup now as per the video, what i am wanting is Homeassistant to push a notification to my Wifes mobile phone when her cell battery hits below 50% for example to put it on charge. She is famous for not charging her phone and this has caused majour issues when emergencies have occured. So i am wandering now how i could possibly create a trigger for the setup provided in the current video. Currently we receive no notifications when either our batteries are low. Both our phones are currently low now on the Battery dash i created like your. configuration.yaml is setup exactly like yours excluding the ignore entities

    • @travismailsa1
      @travismailsa1 Před rokem +1

      @@fasthowto Hi There, just an update, i managed to create automations to do what i wanted via the battery entity and a blueprint to notify me when a battery reaches 50% then 40% and finally 30%. Thank your for your responses though.

  • @akhosha2
    @akhosha2 Před 11 měsíci

    My configuration.yaml file already contains a sensor: key and it will not let me add the code per your instructions. What am i missing here?

    • @fasthowto
      @fasthowto  Před 11 měsíci

      If you already have a sensor key, just add the rest of the code below that. The sensor key in the video is to tell you what section to add it to, you cannot have multiple keys of the same type.

  • @frankraym
    @frankraym Před rokem

    Update : so I got the template in I got the yaml file in but when I go to make an automation it shows the sensor as off. Now it's my understanding that it will only show the checkmark once a device becomes low battery. So I went into developer tools and change the state of a battery to see if it would turn the binary all batteries sensor to on......nothing happened 😢.... So is there something I'm missing ?!

    • @fasthowto
      @fasthowto  Před rokem

      Hard for me to say if you're missing something without being able to see what you've done, so... My first question though would be did you reload the config and/or reboot?

    • @frankraym
      @frankraym Před rokem +1

      ​@@fasthowto ok it was my fault I had an extra spacing in yaml config. Now my next question would be why is it always showing as 1 device with low battery ?

    • @fasthowto
      @fasthowto  Před rokem

      It automatically checks everything with a battery in your system. Go to your entities, and type "battery" in the search bar. There you'll find what the device is, and if you don't want to track that device, you can add it to the exclusions in the config. As mentioned in the video, I ignore phones and tablets and stuff like that. I don't need an alert every time my wife's phone dies. 😂

    • @frankraym
      @frankraym Před rokem

      @@fasthowto ok thank you for that quick response. Is it normal to always show 1 low battery even though in the dashboard all my batteries are higher than 30 %?

    • @frankraym
      @frankraym Před rokem

      @@fasthowto is the binary sensor always supposed to go on ,off on off since as you mentioned it checks the batteries automatically?

  • @JeffAycan
    @JeffAycan Před 7 měsíci

    I may have missed the obvious, but what percentage dictates a "low battery"?

    • @fasthowto
      @fasthowto  Před 7 měsíci

      Sorry about that! Line 103 in config yaml. Great question, and thanks for watching!

    • @JeffAycan
      @JeffAycan Před 7 měsíci

      @@fasthowto Thanks, I was thinking that but figured I'd ask first. The absolutely crazy part is, my line 103 coincidently happens to be the same as your line 103. Who'd have thought they'd line up with completely separate systems.