Coder Social home page Coder Social logo

Comments (3)

tykeal avatar tykeal commented on June 23, 2024

Something tells me that you've got the alert threshold too low in that case. I run my thresholds at 40% for my house and 60% for my short-term rental properties. That gives me the alert that I need to know that the device is almost out of power and the time to make sure I've got the battery on hand.

Trying to run your monitoring alerts too close to the actual power drain point isn't a really good idea! I've been bitten many times by pretty much exactly what you're talking about.

I'll see if I can figure out how to do it, but I'm not actually the original author. All I did was reflow and yamllint the blueprint because the original author's version wouldn't work for me!

If you have some critical devices that you need immediate alerting on when their battery hits certain levels I would also suggest setting up some dedicated alerts on just those.

Finally, and this is from my experience of dealing with IoT batteries for 4+ years, there are many times I've encountered were I'll get an alert at my 60% threshold and the next day the device will be out of juice. Battery estimation, especially in these devices, tends to not be very precise. Additionally, the conditions of where the device are can affect it greatly too.

from homeassistant-blueprints.

ptr727 avatar ptr727 commented on June 23, 2024

I understand your position, although the further your writing progresses, the more you supported my point of the need for instant alerting :)

from homeassistant-blueprints.

tykeal avatar tykeal commented on June 23, 2024

I've been looking into this request off and on for a bit. Mostly in conjunction with some work I've been doing for an integration. Unfortunately, there is no way (that I can find) to setup a trigger condition on a variable amount of sensors. Templates used in trigger conditions are only evaluated during automation load. After that, they're set until the next reload.

This would make the automation not work as expected if you have a long running HA that you add a new battery powered sensor to without restarting as it would not be monitored for the instant alerting.

Having done some additional looking at this particular issue, there is a forum post related to what you're wanting here: https://community.home-assistant.io/t/automation-trigger-list-of-devices/212254/2

It's a bit old as it's from July - Aug of 2020.

I played a little bit with some templates to work on it a bit and you might want to consider setting up a template sensor that does something with the following logic (I've written this so you can stick it in the dev tools templating section)

{%- set bs = namespace(batteries=[]) -%}
{%- for s in states.sensor -%}
  {%- if state_attr(s.entity_id, 'device_class') == 'battery' and state_attr(s.entity_id, 'unit_of_measurement') == '%' -%}
    {%- if states(s.entity_id) | int <= 40 -%}
      {%- set bs.batteries = bs.batteries + [ s.entity_id ] -%}
    {% endif %}
  {%- endif -%}
{%- endfor -%}
{{ bs.batteries }}

With a template sensor like that you would be able to write a notification automation if the state of the sensor has any entries in the array.

Unfortunately blueprints don't allow you to define additional entities that are not part of the automation itself, outside of the inputs. So there is no way to create a blueprint based template sensor.

In any case, I'll keep this open for a bit longer to see if I can noodle up a way to do what you want, but it's still escaping me on how to do it via a blueprint without requiring folks to also create a special template sensor which sort of defeats the intent behind blueprints!

from homeassistant-blueprints.

Related Issues (2)

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.