# Access to all sensor values over time

**URL:** <https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245>\
**Category:** Demandes livrées\
**Tags:** feature-core\
**Created:** [April 7, 2021, 1:22pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245 "2021-04-07T13:22:06Z")\
**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:** [April 7, 2021, 1:22pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/1 "2021-04-07T13:22:07Z")

</div>

**Feature description**  
The idea would be to allow access to the old values of a sensor in a scene.  
Concrete examples:

1. If a movement has been detected **in the last 10 minutes** in any of my rooms, do something.
2. If my room is lit, but there has been no movement **for 15 minutes** , then turn off the room.

These examples are not achievable with a «&nbsp;wait&nbsp;» + «&nbsp;retrieve the last value&nbsp;», as events would be missed.

Finally, this would allow adding widgets to the dashboard with a history of sensor values 😃

---

<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 7, 2021, 1:27pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/2 "2021-04-07T13:27:56Z")

</div>

Could you be more specific about the feature request? ^^

I think we’re only talking about scenes here, then we would really need to refine what this feature request means, for example, I don’t understand the concrete example 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:** [April 7, 2021, 1:30pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/3 "2021-04-07T13:30:31Z")

</div>

Mode 1: Compare a value over a period.  
Example: motion detected in all values of the last 10 minutes (relative time).\n\nMode 2: Compare a value on a given date (or relative time).  
Example: temperature 10 minutes ago was 17°C, or it was 17°C at 15:30 and it is 18°C at 16:45 (without using a «&nbsp;wait&nbsp;» block).

---

<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 7, 2021, 1:35pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/4 "2021-04-07T13:35:19Z")

</div>

Ok I see

Now we need to think about what this could look like functionally 🙂

@lmilcent Are you up for writing some functional specs? A small mockup with an explanation of the functionality is enough. I use [https://whimsical.com/](https://whimsical.com/) on my side for mockups

---

<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:** [April 7, 2021, 1:36pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/5 "2021-04-07T13:36:52Z")

</div>

What are you expecting in terms of content (briefly)?

A high-level description, a flowchart, a «&nbsp;fake&nbsp;» interface?

---

<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 7, 2021, 1:40pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/6 "2021-04-07T13:40:20Z")

</div>

A purely user-oriented description of the expected behavior (textual) + a mockup 🙂 As for the description, it should be very concrete: what happens in the UI?

An example of a functional spec I had made for multi-user functionality:

> [@Multi-utilisateurs](https://community.gladysassistant.com/t/multi-utilisateurs/5510/6?u=pierre-gilles):
>
> Salut à tous ! Venant de finir le développement des variables injectées dans les scènes, je me lance sur cette fonctionnalités qui est dans les plus demandées slight_smile J’ai écris des spécifications fonctionnelles + designé quelques screens et je voulais voir avec vous ce que vous en pensiez. Spécification fonctionnelle En tant que premier utilisateur d’une instance Gladys, je suis par défaut “administrateur”. Cet utilisateur a la possibilité de créer d’autres utilisateurs, d’autres “a…

---

<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:** [April 7, 2021, 1:41pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/7 "2021-04-07T13:41:24Z")

</div>

Thanks, I’ll look into it!

It will take some time, but I’ll update this topic as soon as I have a first version 🙂

---

<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 7, 2021, 1:42pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/8 "2021-04-07T13:42:52Z")

</div>

Ok cool 🙂 For me, the «&nbsp;specification&nbsp;» part is the bulk of the work for development, so it really helps when there are clear specs of what we want!

---

<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:** [April 7, 2021, 1:45pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/9 "2021-04-07T13:45:26Z")

</div>

Oh, I’m well aware of that, it’s so much simpler and faster to develop something that’s already precise and framed than to go in all directions!

Unfortunately, I don’t count the hours spent on unframed projects with a pseudo idea as the project base.

---

<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:** [April 7, 2021, 9:22pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/10 "2021-04-07T21:22:31Z")

</div>

@pierre-gilles, is this mockup already functional?

(Public access) [Mockup: Retrieve a state over time](https://whimsical.com/menu-7Mcts2rSVCMHXvTU7s8b2y).

## Functional Specification

- «&nbsp;Retrieve the last state&nbsp;» becomes «&nbsp;Retrieve a state&nbsp;»
- The state of a device can be retrieved in several ways:
  1. Last value
  2. Relative time (X minutes ago)
  3. By date
  4. Over a period

## Details of the mentioned possibilities

### 1. Last value

This is exactly what is currently done, and quite clear 😉

### 2. Relative time

Here the idea is to be able to say: I want to compare the value from 10 minutes ago (based on the scene execution time).

We will be able to compare two values 10 minutes apart, without having to wait!

If the scene runs at 12:00 and the user has chosen «&nbsp;10 minutes ago,&nbsp;» the value will be compared to that of 11:50:00 (±30s to find a value). If no value is found between 11:49:30 and 11:50:30, the test fails.

### 3. By date

This is a bit similar to relative time, but you can specify a very precise date without any particular limit. We will therefore be able to compare values several days or even months apart.

Here, you can imagine comparing a value to a «&nbsp;reference value&nbsp;» on a specific date.

**Note here:** the user must be alerted if they choose a date for which there is no value.

### 4. Over a period

This is the most interesting in my opinion: the user will be able to compare a value with all those retrieved over a certain period of time.

Examples:

- You can check if a motion sensor detected movement in the last 10 minutes (based on the scene execution time).
- You can check if a plug has consumed a certain level of instantaneous power in the last 30 minutes
- etc…

In the case of a sensor (or actuator) whose values can change very regularly and are not necessarily binary (temperature, power consumption in watts, brightness in lux, etc.), the «&nbsp;reference&nbsp;» value used in the scene for the test will be compared to all those recorded.

If I want to check that my plug has consumed less than 15W in the last 30 minutes, the test will be written as: «&nbsp;My plug&nbsp;» \< «&nbsp;15W&nbsp;» in the «&nbsp;last 30 minutes&nbsp;». Gladys will then check in the database if all the values retrieved in the last 30 minutes do not exceed 15W.

## Retrieval of test values

As with the «&nbsp;retrieve the last value&nbsp;» block, the value used during tests should be automatically retrieved (value recording time + value).

Example:

- I perform a test on the device «&nbsp;my-sensor&nbsp;» to check if there has been movement in the last 10 minutes, i.e. between 11:50 and 12:00 (scene execution time).
- If movement was recorded at 11:56, two variables are created in the scene: «&nbsp;my-sensor-test-1-value&nbsp;» and «&nbsp;my-sensor-test-1-time&nbsp;».
- I am able to send a message with these two variables to alert me «&nbsp;motion detected (value = 1) at 11:56.&nbsp;»

---

<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:** [April 7, 2021, 9:59pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/11 "2021-04-07T21:59:15Z")

</div>

I really like your suggestions and I can already imagine using the feature to say «&nbsp;It’s okay, I’m turning off the light in the room.&nbsp;»

---

<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 8, 2021, 1:23am UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/12 "2021-04-08T01:23:59Z")

</div>

> [@lmilcent](#):
>
> the value from 10 minutes ago

What does «&nbsp;the value from 10 minutes ago&nbsp;» mean to you?

> [@lmilcent](#):
>
> The user will be able to search for a value over an entire time period.

What happens when there are multiple values in the period? Which one does Gladys take?

I don’t think this is what we want. I see the need, but in the spec, the way you address the need seems very strange and odd to me 😃

@VonOx Without reading the proposal above to avoid influencing you, how would you see the implementation of the scene you mentioned to me with your motion sensors?

---

<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:** [April 8, 2021, 5:12am UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/13 "2021-04-08T05:12:30Z")

</div>

I added a few clarifications, is it more understandable now?

Otherwise, don’t hesitate to tell me what’s missing, what’s unclear, or could lead to illogical situations. I’ll continue the reflection!

---

<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:** [April 8, 2021, 6:56am UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/14 "2021-04-08T06:56:34Z")

</div>

Message updated @pierre-gilles, with more details on the expected user-side behavior and management in Gladys.

I don’t see any other special cases to handle yet, let’s see what everyone thinks to improve all this 🙂

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [April 8, 2021, 7:05am UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/15 "2021-04-08T07:05:18Z")

</div>

Ok (but too late, I already read it :D)

# Trigger:

Motion detected

# Condition: (Continue only if)

Time range (define a range of action)  
1. Direct selection on a double slider  
or  
2. Based on sunset/sunrise (with an offset as we usually turn on lights before the sun sets)  
Bonus if we can also choose which day of the week the scene is active

# Action:

=\> Turn on a room or certain lights  
The extra touch to make life easier and avoid too many scenes. Allow the user (checkbox?) to choose if Gladys should turn off these lights after a certain time without motion detected (like 2 minutes)

* * *

Some screenshots from HA, it’s ugly and we can really do better in terms of UX

**Condition** (Sunset/Sunrise with 10-minute offset)

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

**Turn off after 2 minutes**

 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/1/134ce14196f187759648568f973d6755628ea796.png)  
 ![image](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/7/76ccd3e866a24a41eb553aaf272ee4f45366ef5f.png)

---

<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:** [April 9, 2021, 10:55am UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/16 "2021-04-09T10:55:55Z")

</div>

What do you think of my (since modified) proposal above?  
What would you change, add, or clarify for you?

---

<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:** [April 12, 2021, 7:33pm UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/17 "2021-04-12T19:33:49Z")

</div>

@VonOx and @pierre-gilles, how should I proceed with the specification-side feature?  
What are your (new) feedbacks? 😇

---

<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 13, 2021, 1:41am UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/18 "2021-04-13T01:41:17Z")

</div>

I’m not entirely in agreement with your proposal from my side, I think we really need to think more about the end user and all the use cases that will stem from this feature.

I don’t have precise answers to give you without working on the subject full-time myself, I think I need to spend a couple of hours on it before I can answer you 😃 it won’t be before the end of the week/next week in my opinion 🙂

---

<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 16, 2021, 8:09am UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/19 "2021-04-16T08:09:23Z")

</div>

Hello!

So I’ve been working all day on the subject, and I have 3 proposals to address the different issues 🙂

I’m responding here because it’s a topic where we talk about scenes, but it has nothing to do with the title of the topic. Once we agree, we can rename the development.

**The Problem**

I started from the different needs, without thinking about the product, just the final need:

- Be able to turn off the light in a room if there is no movement for XX minutes
- Be able to receive an alert if the fridge temperature drops below 10°C for at least 1 hour.
- Be able in a scene to execute actions only if the sun is in the state of rising/setting/before sunrise minus 10 minutes, after sunset plus 30 minutes, etc..
- Be able to execute a scene (or part of a scene) according to a time condition. Example: if it is before 12 p.m./after 2 p.m./between 12 p.m. and 2 p.m./on Tuesday, Wednesday and Thursday between 7 a.m. and 8 a.m./and many others.

Based on this specification, I dug a bit into how we could have this in Gladys.

I quite liked what home assistant did on the «&nbsp;maintain a condition for XX minutes&nbsp;» part, and I went for a solution close to theirs for this part.

After that, I still have some questions (marked on the document), not everything is clear on the functional side.

The mockups (with explanations) are available here: [New scenes triggers/conditions/actions](https://whimsical.com/new-scenes-triggers-conditions-actions-Jgihy2BschUGTcwcp9VjsZ)

Also available as image export below:

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

 ![nouveau trigger](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/8/87f3bb3b18d7cdb9de1ba27ce4d248b7ae55c53f.png)

What do you think?

@lmilcent In the end, it’s very different from your proposal 😛 Sorry, to save time I went with what I saw, and then we can indeed see what best addresses the issues.

**Note:** If you have cases that are not well covered by my proposal, feel free to bounce back on them 🙂 I’m talking about practical and concrete cases at your place, we’re really in practice here, not in theory.

---

<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:** [April 16, 2021, 8:37am UTC](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245/20 "2021-04-16T08:37:27Z")

</div>

> [@pierre-gilles](#):
>
> practical and concrete examples at your place, we are

I’ll look into all of that, thanks for the time you spent on it 🙂  
This morning, I was actually thinking about it in relation to a new need (linked):

- Being able to execute a scene based on the average values of a sensor over a period of time  
Example: If the fridge temperature averages 1°C over the last 2 hours, send a message to remind you to change the thermostat.

I’ll study your proposal and give you my feedback as soon as possible 🙂

[Next page](https://community.gladysassistant.com/t/acces-a-toutes-les-valeurs-dun-capteur-dans-le-temps/6245.md?page=2)
