# Read a value with a camera, then AI writes it to a virtual sensor

**URL:** <https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276>\
**Category:** Demandes livrées\
**Created:** [June 17, 2026, 2:30pm UTC](https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276 "2026-06-17T14:30:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Psoy](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/psoy/32/9005_2.png) [@Psoy](https://community.gladysassistant.com/u/Psoy)\
**Post date:** [June 17, 2026, 2:30pm UTC](https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276/1 "2026-06-17T14:30:51Z")

</div>

\*\* One could imagine adding a new tool, for example `sensor_set_state`, which would allow the AI to write a value to a virtual sensor. \*\*  
Example:  
Reading a license plate to compare it with a list of authorized plates to open the gate.  
Reading the pH of my pool dispenser, for information and alarm if the pH is too low or too high, and if the indication goes to «&nbsp;AL&nbsp;», being able to automatically restart the device.

---

<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:** [June 19, 2026, 6:35pm UTC](https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276/2 "2026-06-19T18:35:50Z")

</div>

Hi @Psoy 🙂

Hope I’ve added the new tool, it was pretty easy!

Tested in the chat, but it will work the same way in the scenes:

 ![Screenshot 2026-06-19 at 20.29.50](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/0/8/085b3a5ab2249dcc93f8c4059c411834d0407eb9.png)

 ![Screenshot 2026-06-19 at 20.29.54](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/0/0/006d5cb58574abfd78ff8fdc1385553c90e8c086.png)

 ![Screenshot 2026-06-19 at 20.31.05](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/1/1/119fd3236ea0cad68ceb812f93ad6e8b177127b4.png)

 ![Screenshot 2026-06-19 at 20.31.09](https://gladys-assistant-community.b-cdn.net/uploads/default/original/3X/b/d/bd5c9a7307804affb292474579e61e9fc9c89ee6.png)

This will be ultra convenient for using AI to read values from meters 🤩

The PR:

> <https://github.com/GladysAssistant/Gladys/pull/2569>
>
> \### 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 affect the code, did you 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 feature/service, did you run the 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 (\[forum\](https://community.gladysassistant.com/)) for testing before merging.
> \- \[\] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
> \- \[\] If you are adding a new features/services which needs explanation, did you modify the user documentation? See \[the GitHub repo\](https://github.com/GladysAssistant/v4-website) and the \[website\](https://gladysassistant.com).
> \- \[\] Did you add fake requests data for the demo mode (\`front/src/config/demo.js\`) so that the demo website is working without a backend? (if needed) See \[https://demo.gladysassistant.com\](https://demo.gladysassistant.com).
> 
> NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
> 
> \### Description of change
> 
> AI: Add sensor.set-state tool ( https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276 ) 
> 
> 
> 
> \## Summary by CodeRabbit
> 
> \## Release Notes
> 
> \* \*\*New Features\*\*
> \* Added ability to save and store values (including from camera images) to virtual sensors through AI assistant requests. The system validates device and feature selection, handling both numeric and text values appropriately.
> 
> \* \*\*Tests\*\*
> \* Added comprehensive test coverage for virtual sensor state saving functionality.

---

<div class="post-metadata">

**Author:** ![mutmut](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/mutmut/32/14064_2.png) [@mutmut](https://community.gladysassistant.com/u/mutmut)\
**Post date:** [June 19, 2026, 7:11pm UTC](https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276/3 "2026-06-19T19:11:33Z")

</div>

Did you plan for it not to write to real devices?  
As you mentioned electronics, I was thinking of Linky values, for example, for devices that can have set operations and not just get operations.

---

<div class="post-metadata">

**Author:** ![Psoy](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/psoy/32/9005_2.png) [@Psoy](https://community.gladysassistant.com/u/Psoy)\
**Post date:** [June 20, 2026, 2:55pm UTC](https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276/4 "2026-06-20T14:55:31Z")

</div>

Hello @pierre-gilles,  
Thanks for your quick response.  
How does the «&nbsp;asked the AI&nbsp;» action work? Does it take a picture at time t and analyze it, or does it visualize for a few seconds and analyze the video? I lean towards the first hypothesis, because I have a refresh problem on the 7-segment displays. They are powered by multiplexing and, as the value is displayed on 2 digits, they are not lit at the same time.  
To fix this problem, the AI would need to analyze over a few images. Is this possible, or is it already the case? I hope I’ve been clear.

---

<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:** [June 22, 2026, 5:49am UTC](https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276/5 "2026-06-22T05:49:49Z")

</div>

> [@mutmut](#):
>
> Is it possible that it doesn’t write to real devices?

Good point! I had limited it to devices with «&nbsp;read\_only = true&nbsp;», but we should actually restrict it to devices in the «&nbsp;Virtual MQTT Devices&nbsp;» integration only. 🙂

> [@Psoy](#):
>
> How does the «&nbsp;Ask the AI&nbsp;» action work? Does it take a picture at time t and analyze it?

Yes, it takes a picture at the moment the «&nbsp;Ask the AI&nbsp;» action is executed!

> [@Psoy](#):
>
> To fix this issue, the AI would need to analyze several images. Is this possible, or is it already the case? I hope I was clear.

Ah, that’s more complex. Even if we added a dynamic option to inject multiple camera images, how can we ensure that the two images are taken at different times? 😅

---

<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:** [June 22, 2026, 6:22pm UTC](https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276/6 "2026-06-22T18:22:51Z")

</div>

This feature is available in Gladys Assistant 4.80:

> [@Gladys Assistant 4.80 : Matter, Netatmo, Tuya et IA rocket](https://community.gladysassistant.com/t/gladys-assistant-4-80-matter-netatmo-tuya-et-ia/10295?u=pierre-gilles):
>
> Salut à tous ! Beaucoup de nouveautés en ce moment smiley Cette version 4.80 apporte de nombreuses améliorations de stabilité, des corrections sur Matter, Netatmo et Tuya, ainsi que plusieurs nouveautés autour de l’IA. robot IA L’agent IA continue de s’améliorer avec deux nouveautés : plus Ajout d’un nouvel outil sensor.set-state, permettant à l’agent de modifier directement l’état de certains capteurs lorsque demandé. Par exemple, vous pouvez utiliser l’IA pour lire une image de cam…

I’m closing this topic!

@Psoy for your refresh issue, don’t hesitate to create another topic so we can discuss it 😉

---

<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:** [June 22, 2026, 6:22pm UTC](https://community.gladysassistant.com/t/lire-une-valeur-avec-une-camera-puis-lia-lecrit-dans-un-capteur-virtuel/10276/7 "2026-06-22T18:22:55Z")

</div>


