# Scenes: retrieve a state type from all devices (e.g.: battery type)

**URL:** <https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154>\
**Category:** Demandes livrées\
**Tags:** feature-core, scene, scene-action\
**Created:** [March 2, 2021, 9:38pm UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154 "2021-03-02T21:38:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [March 2, 2021, 9:38pm UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/1 "2021-03-02T21:38:40Z")

</div>

**Very illustrative example:**

- I have 20 battery-powered devices
- I want to check if one of my devices has less than 25% battery

Currently, I have to create a scene with x20 «&nbsp;Retrieve the last state&nbsp;» boxes, followed by x20 tests on these states (I was too lazy, there are only 9):

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/b/b3ac1545c2fa21138d714feb2c62c6728bccf956.png)

  

**Description**

What I propose as a new feature is the ability to retrieve all values of a certain type.  
So here, all the battery levels of all the sensors and check if one of them is below 25%. In this specific case, a message can be sent to me with the name and room of the sensor.

One can imagine a multitude of applications: all temperature values, battery levels, brightness, power consumption of outlets, etc.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [March 3, 2021, 3:00am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/2 "2021-03-03T03:00:30Z")

</div>

Mmmm not stupid, I agree on the problem then I’m not sure if the solution is to do this in the scenes 🙂

For the battery story, I think it would be something we might want «&nbsp;natively&nbsp;» in Gladys. Like Gladys warning you, without your intervention, that some of your devices have less than 25% battery 🙂

Same for devices that are turned off, receiving an alert in «&nbsp;sensor XX has not sent data for 24 hours&nbsp;» mode

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [March 3, 2021, 6:23am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/3 "2021-03-03T06:23:58Z")

</div>

That’s exactly what I was saying to @cicoub13 last night, in my opinion as a native user, we should:

- manage battery levels
- manage turned off or inactive equipment
- manage reception levels (poor Bluetooth or Zigbee links for example)
- manage presence (via Bluetooth) without creating a scene, since a device is already linked to a user

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [March 3, 2021, 3:57pm UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/4 "2021-03-03T15:57:54Z")

</div>

> [@lmilcent](#):
>
> - manage battery levels
> - manage turned off or inactive equipment
> - manage reception levels (poor Bluetooth or Zigbee links, for example)

I agree with that 🙂

> [@lmilcent](#):
>
> - manage presence (via Bluetooth) without creating a scene, since a device is already linked to a user

I’m less in agreement with that.

First, a device is not linked to a user (maybe we’re not talking about the same thing?), and moreover, I think presence management is a specific case for each individual and is difficult to generalize.

For example, you might want to manage presence through multiple factors: Wi-Fi presence + Bluetooth presence + OwnTracks (GPS smartphone) + who knows what!

And doing it via scenes allows you to be infinitely flexible, and above all, it’s more understandable/transparent for the user; it’s not something magical.

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [March 3, 2021, 4:24pm UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/5 "2021-03-03T16:24:01Z")

</div>

> [@pierre-gilles](#):
>
> And doing it through scenes allows you to be infinitely flexible, and above all, it is more understandable/transparent for the user; it’s not something magical.

I understand your point of view, and perhaps it is not the right solution after all.  
However, I find that it is still not intuitive when using the presence detection service via Bluetooth.

At a minimum, it would be necessary to explain that you need to create the scene, or even provide an example of a scene?  
This way, the basic need is covered (detecting my presence with Bluetooth), but the scene can be modified for advanced users or needs.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [March 4, 2021, 1:33am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/6 "2021-03-04T01:33:27Z")

</div>

@lmilcent Ah, maybe some things are missing in the doc?

> **[Gérer la présence avec la détection Bluetooth | Gladys Assistant](https://gladysassistant.com/fr/docs/integrations/bluetooth/)**
>
> L'intégration Bluetooth est utile pour la gestion de la présence.

Or just a link to the doc in Gladys otherwise 🙂

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [March 4, 2021, 6:53am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/7 "2021-03-04T06:53:45Z")

</div>

It would be at least the link to the documentation, yes 🙂

---

<div class="post-metadata">

**Author:** ![ArMour85](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/armour85/32/7457_2.png) [@ArMour85](https://community.gladysassistant.com/u/ArMour85)\
**Post date:** [May 29, 2021, 9:49am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/8 "2021-05-29T09:49:20Z")

</div>

I am in favor of it being native to Gladys and that a message indicates it in the chat with the name and battery level.

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [May 29, 2021, 10:19am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/9 "2021-05-29T10:19:30Z")

</div>

Thanks for your support 🙏  
The more of us who vote, the more important this feature request will be and the more likely it is to be developed by @pierre-gilles or one of the community developers!

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [May 31, 2021, 1:37am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/10 "2021-05-31T01:37:03Z")

</div>

Oh, but this feature is not the same as the one described in the title.

Is there a feature request for the low battery alert/ lost device?

---

<div class="post-metadata">

**Author:** ![Will\_71](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/will_71/32/9582_2.png) [@Will\_71](https://community.gladysassistant.com/u/Will_71)\
**Post date:** [April 11, 2022, 11:01am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/11 "2022-04-11T11:01:10Z")

</div>

I just realized that I made the same scene @lmilcent.  
I just integrated 6 sensors and this can be really tedious if there are many more sensors/actuators.  
Has anyone started developing this feature?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [April 11, 2022, 11:08am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/12 "2022-04-11T11:08:23Z")

</div>

To my knowledge 🙂

---

<div class="post-metadata">

**Author:** ![Will\_71](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/will_71/32/9582_2.png) [@Will\_71](https://community.gladysassistant.com/u/Will_71)\
**Post date:** [April 11, 2022, 11:28am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/13 "2022-04-11T11:28:24Z")

</div>

Too bad 🥲, this could be useful when you have many sensors that run on batteries!  
I’ll look for another solution in the meantime.

---

<div class="post-metadata">

**Author:** ![Lokkye](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lokkye/32/5881_2.png) [@Lokkye](https://community.gladysassistant.com/u/Lokkye)\
**Post date:** [November 14, 2023, 10:15am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/14 "2023-11-14T10:15:33Z")

</div>

Hello everyone,

I worked a bit on this topic 🙂  
Here is the result :

- The battery level configuration is set at the global config level :  

- The message received in the chat (sent according to the user’s language) :  

Does this match your expectations @_Will_71, @lmilcent, @ArMour85 and @pierre-gilles ?

The PR draft :

> <https://github.com/GladysAssistant/Gladys/pull/1936>
>
> \### Pull Request check-list
> 
> To ensure your Pull Request can be accepted as fa…st as possible, make sure to review and check all of these items:
> 
> \- \[x\] If your changes affects code, did your write the tests?
> \- \[x\] Are tests passing? (\`npm test\` on both front/server)
> \- \[x\] Is the linter passing? (\`npm run eslint\` on both front/server)
> \- \[x\] Did you run prettier? (\`npm run prettier\` on both front/server)
> \- \[x\] If you are adding a new features/services, did you run integration comparator? (\`npm run compare-translations\` on front)
> \- \[x\] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community (\[french forum\](https://community.gladysassistant.com/)/\[english forum\](https://en-community.gladysassistant.com/)) for testing before merging.
> 
> \### Description of change
> 
> 
> !\[Screenshot 2023-11-14 at 11 10 47\](https://github.com/GladysAssistant/Gladys/assets/11317212/e3fa604f-3427-409b-b962-29a0b0b6478c)
> !\[Screenshot 2023-11-14 at 11 10 38\](https://github.com/GladysAssistant/Gladys/assets/11317212/7fe7a160-16a2-4e71-a3f8-4c7063c43dfd)

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [November 15, 2023, 8:14am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/15 "2023-11-15T08:14:21Z")

</div>

@Lokkye That’s really nice and it’s exactly what’s needed 🙂

Maybe there should be an option to disable this setting (if you’re on vacation and it spams you every day 😛 )

As for the frequency, we’ll see what to set.

Could be once or twice a week?

---

<div class="post-metadata">

**Author:** ![Will\_71](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/will_71/32/9582_2.png) [@Will\_71](https://community.gladysassistant.com/u/Will_71)\
**Post date:** [November 15, 2023, 9:26am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/16 "2023-11-15T09:26:11Z")

</div>

Thanks @Lokkye yes that works for me.

---

<div class="post-metadata">

**Author:** ![lmilcent](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lmilcent/32/7023_2.png) [@lmilcent](https://community.gladysassistant.com/u/lmilcent)\
**Post date:** [November 15, 2023, 10:04am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/17 "2023-11-15T10:04:42Z")

</div>

Great!  
@pierre-gilles is right, we need to see whether to notify once or regularly.

To avoid spamming, I’d propose:

- A configurable info threshold (30%)
- A configurable alert threshold (10%)
- A final alert when the sensor is no longer accessible, or reaches 0%

That way we have 3x alerts per product, no more and especially not every day!

---

<div class="post-metadata">

**Author:** ![Lokkye](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/lokkye/32/5881_2.png) [@Lokkye](https://community.gladysassistant.com/u/Lokkye)\
**Post date:** [November 15, 2023, 7:48pm UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/18 "2023-11-15T19:48:32Z")

</div>

> [@pierre-gilles](#):
>
> Maybe we need an option to disable this setting (if you’re on vacation and it spams you every day 😛 )

And a button for the 10 !! 🙂

 ![Screenshot 2023-11-15 at 20.39.55](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/3/3ba6bf22a6d4b6751557ab2c9452f03ff847b161.png)  
 ![Screenshot 2023-11-15 at 20.41.54](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/0/0cf65b1cf61660920a3967cb851e5dedb0e6b130.png)

I took the liberty of putting it in a separate «&nbsp;box&nbsp;».  
What do you think?  
What would you say about putting the settings in separate «&nbsp;boxes&nbsp;» to distribute them across the 2 columns?

> [@pierre-gilles](#):
>
> As for the frequency, we’ll see what to set.

For now, I set it to every hour; I can change it to 1 or 2 times per week or even make it configurable (I don’t know if that’s possible)

> [@lmilcent](#):
>
> To avoid spamming, I would suggest:
> 
> - A configurable info threshold (30%)
> - A configurable alert threshold (10%)
> - A final alert when the sensor is no longer accessible, or reaches 0%
> 
> That way we have 3 alerts per product, no more, and especially not every day!

That’s a good idea, but I don’t know if that’s possible. For the moment, I went with a system that «&nbsp;checks&nbsp;» the battery level every day. But if I take your idea, I’d need to notify when the device changes level and therefore «&nbsp;listen&nbsp;» to each change in battery level to check whether it has dropped below 30% for example. I’m not sure if I’m being clear 🙂

---

<div class="post-metadata">

**Author:** ![spenceur](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/spenceur/32/1961_2.png) [@spenceur](https://community.gladysassistant.com/u/spenceur)\
**Post date:** [November 15, 2023, 8:12pm UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/19 "2023-11-15T20:12:28Z")

</div>

Can you just check without adding a listener and verify at intervals?

Actually, whether your device is at 26 or 30 doesn’t matter, but when your cron runs you notify those between 30 and 20, between 20 and 10, and \<10.

That avoids having a listener on every battery event ^^

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [November 16, 2023, 8:14am UTC](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154/20 "2023-11-16T08:14:15Z")

</div>

> [@Lokkye](#):
>
> And a button for the 10!! 🙂

Excellent!

> [@Lokkye](#):
>
> I allowed myself to put it in a separate «&nbsp;box&nbsp;».  
> What do you think?  
> What would you say about putting the settings in separate «&nbsp;boxes&nbsp;» to distribute them across the 2 columns?

That works very well for me, we’ll see how it looks in practice but in principle I agree!

> [@Lokkye](#):
>
> For the moment, I set it to every hour; then I can set it to 1 or 2 times per week or even make it configurable (I don’t know if that’s possible)

I think we can keep it simple for now: once a week at a fixed date/time, like Saturday at 9am for example? (that allows for a notification at the start of the weekend when the user is potentially available to take care of it?)

We should just specify that in the feature description so it’s clear 🙂

> [@Lokkye](#):
>
> It’s a good idea, but I don’t know if that’s possible. For now, I started with a system that «&nbsp;checks&nbsp;» the battery level every day.

I prefer your approach @Lokkye!

I like the idea of doing it at a fixed interval, so if we have 5 sensors that start to weaken, we don’t get 5 random notifications during the week but a batch of notifications on a day that makes sense, so the user can tell themselves «&nbsp;Ah, there are 5 devices that are almost dead, I’ll place an order for 5 batteries&nbsp;»

[Next page](https://community.gladysassistant.com/t/scenes-recuperer-un-type-detat-de-tous-les-peripheriques-ex-type-batterie/6154.md?page=2)
