# Outside - Light pir and switch mechanic

**URL:** https://discourse.nodered.org/t/outside-light-pir-and-switch-mechanic/45986
**Category:** General
**Created:** [20 May 2021 15:36 UTC](https://discourse.nodered.org/t/outside-light-pir-and-switch-mechanic/45986 "2021-05-20T15:36:50Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![JobbeDeluxe](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@JobbeDeluxe](https://discourse.nodered.org/u/JobbeDeluxe)
#### Post date: [21 May 2021 13:53 UTC](https://discourse.nodered.org/t/outside-light-pir-and-switch-mechanic/45986/5 "2021-05-21T13:53:41Z")

</div>

Ok,

now!

i used a change node to put the status of the swotch in a global var, that can be used by the function node, too.

so now i have If it is dark (depends on my position) and if switch is "off" it will let the PIR trigger... if on of this is not set. It will do nothing.

great job 🙂

thanks for your input und to the other thretads that help me out:

> [@How to set global variable parameters?](https://discourse.nodered.org/t/how-to-set-global-variable-parameters/19470):
>
> Hi, I would like to store 5 temperature values in one global object. I have created the global object with several temp values: var GlobalTemp = {}; GlobalTemp.a = 10; GlobalTemp.b = 15; GlobalTemp.c = 22; global.set("Temp",GlobalTemp); and I can read the Global Var and get the values I need: var work\_GlobalTemp = global.get("Temp"); msg.payload = work\_GlobalTemp.b; return msg; but I have now Idea how to set a speciel value inside the global object with a new value. Something like global…

> [@If condition with a function](https://discourse.nodered.org/t/if-condition-with-a-function/25389/22):
>
> Perfect! I can manage do that with the switch node instead.

[https://nodered.org/docs/user-guide/writing-functions](https://nodered.org/docs/user-guide/writing-functions)

---

_[View the full topic](https://discourse.nodered.org/t/outside-light-pir-and-switch-mechanic/45986)._
