Assuming the env value always exactly matches the property names in the payload, you can use
const prop = env.get('sensor')
indata = RED.util.getObjectProperty(msg.payload,prop);
...
PS: About your post formatting:
In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```
)
```
code goes here
```
You can edit and correct your post by clicking the pencil icon.
See this post for more details - How to share code or flow json