# Be able to inject a variable into HTTP request + control a device

**URL:** <https://community.gladysassistant.com/t/etre-capable-dinjecter-une-variable-dans-requete-http-controler-un-appareil/7045>\
**Category:** Demandes livrées\
**Tags:** feature-integration, scene, scene-action\
**Created:** [March 9, 2022, 6:14pm UTC](https://community.gladysassistant.com/t/etre-capable-dinjecter-une-variable-dans-requete-http-controler-un-appareil/7045 "2022-03-09T18:14:03Z")\
**Posts on this page:** 1\
**Showing post:** 31

<div class="post-metadata">

**Author:** ![bertrandda](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/bertrandda/32/5929_2.png) [@bertrandda](https://community.gladysassistant.com/u/bertrandda)\
**Post date:** [September 18, 2022, 9:45pm UTC](https://community.gladysassistant.com/t/etre-capable-dinjecter-une-variable-dans-requete-http-controler-un-appareil/7045/31 "2022-09-18T21:45:39Z")

</div>

Hi, I was wondering how you’d picture it when you imagine a possible different block to control a device with a variable.

> [@pierre-gilles](#):
>
> What really blocks me from closing this request is the second part of the request about the «&nbsp;Control a device&nbsp;» block; I have no idea how to do it in terms of design, it might even be a different block to develop.

I tried something by reusing the component that already existed for inserting variables. If the value is a number, we save the new value in `value` as usual; otherwise it is saved as a string. In my trial I added a database field `evaluate_value`. Since we also have a request to do calculations on variables I thought that would allow doing both.

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

When the scene runs, if we encounter `evaluate_value` fields as the value of «&nbsp;control a device&nbsp;» actions, we replace the variables with their values and run the calculation (I was thinking of using the [simple-evaluate](https://www.npmjs.com/package/simple-evaluate) package).

On the validation side I added on the `evaluate_value` field a `@hapi/joi` validation with a regex allowing only numbers, operators and {{variables}} (a complete formula — if the user enters "{{variable…}} + " without a second value it won’t save).

What do you think? What was your vision for how it should work?

---

_[View the full topic](https://community.gladysassistant.com/t/etre-capable-dinjecter-une-variable-dans-requete-http-controler-un-appareil/7045)._
