# Why my lamp is going when bigtimer is set

**URL:** <https://discourse.nodered.org/t/why-my-lamp-is-going-when-bigtimer-is-set/35319>\
**Category:** General\
**Created:** [4 November 2020 10:36 UTC](https://discourse.nodered.org/t/why-my-lamp-is-going-when-bigtimer-is-set/35319 "2020-11-04T10:36:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sniperxnl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sniperxnl/32/18250_2.png) [@sniperxnl](https://discourse.nodered.org/u/sniperxnl)\
**Post date:** [4 November 2020 10:36 UTC](https://discourse.nodered.org/t/why-my-lamp-is-going-when-bigtimer-is-set/35319/1 "2020-11-04T10:36:43Z")

</div>

Hello guys, i have a ikea motion sensor and use it the halway, now i want that the lamp only goes on when there is motion in the morning and night

what do i wrong in my flow

```auto
[{"id":"7bae246d.839dfc","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"4b7c590a.f56cf8","type":"trigger","z":"7bae246d.839dfc","name":"","op1":"ON","op2":"OFF","op1type":"str","op2type":"str","duration":"90","extend":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":870,"y":40,"wires":[["92cae6d8.0fa0e8"]]},{"id":"92cae6d8.0fa0e8","type":"Tasmota Switch","z":"7bae246d.839dfc","broker":"80cd643f.d8bb58","device":"hal","name":"Lamp Hal","outputs":1,"uidisabler":false,"fullTopic":"%topic%/%prefix%/","cmndPrefix":"","statPrefix":"","telePrefix":"","x":1040,"y":40,"wires":[[]]},{"id":"e780029b.2cd52","type":"mqtt in","z":"7bae246d.839dfc","name":"Motion Hal","topic":"zigbee2mqtt/0x680ae2fffe36ddc8","qos":"0","datatype":"json","broker":"80cd643f.d8bb58","x":60,"y":40,"wires":[["6ac7a8bd.da7478"]]},{"id":"6ac7a8bd.da7478","type":"change","z":"7bae246d.839dfc","name":"","rules":[{"t":"move","p":"payload.occupancy","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":120,"wires":[["e9d0cac9.447bd8"]]},{"id":"e9d0cac9.447bd8","type":"switch","z":"7bae246d.839dfc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":40,"wires":[["5f9f33b9.b081bc"]]},{"id":"5f9f33b9.b081bc","type":"change","z":"7bae246d.839dfc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":40,"wires":[["59050aab.8bfbb4","1deefb9d.fcbae4"]]},{"id":"1deefb9d.fcbae4","type":"debug","z":"7bae246d.839dfc","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":120,"wires":[]},{"id":"59050aab.8bfbb4","type":"bigtimer","z":"7bae246d.839dfc","outtopic":"","outpayload1":"ON","outpayload2":"OFF","name":"Big Timer","comment":"","lat":"52.2661° N","lon":"6.1552° E","starttime":"1080","endtime":"480","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"","outtext2":"","timeout":"1440","sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":0,"month7":0,"day8":0,"month8":0,"day9":0,"month9":0,"day10":0,"month10":0,"day11":0,"month11":0,"day12":0,"month12":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"repeat":false,"atstart":false,"odd":false,"even":false,"x":700,"y":40,"wires":[["4b7c590a.f56cf8"],[],[]]},{"id":"80cd643f.d8bb58","type":"mqtt-broker","z":"","name":"","broker":"192.168.2.23","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 November 2020 10:45 UTC](https://discourse.nodered.org/t/why-my-lamp-is-going-when-bigtimer-is-set/35319/2 "2020-11-04T10:45:55Z")

</div>

As far as I know, the bigtimmer node outputs a msg basd on it's settings. If you only want the lamp to go on in the morning and night, I would add a `change` node right after the `mqtt-in` node and st msg.timestamp to 'timestamp. Then compare it to the time range you want to have the lamp active.

---

<div class="post-metadata">

**Author:** ![sniperxnl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sniperxnl/32/18250_2.png) [@sniperxnl](https://discourse.nodered.org/u/sniperxnl)\
**Post date:** [4 November 2020 11:27 UTC](https://discourse.nodered.org/t/why-my-lamp-is-going-when-bigtimer-is-set/35319/3 "2020-11-04T11:27:31Z")

</div>

don't know how to do that

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 November 2020 12:09 UTC](https://discourse.nodered.org/t/why-my-lamp-is-going-when-bigtimer-is-set/35319/4 "2020-11-04T12:09:22Z")

</div>

add a `change` node to the output of the `mqtt-in` node. In the 'change' node options, set it like this:

![Screen Shot 2020-11-04 at 7.07.24 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6aa3378d2a13f034fdc41f1ac6719a3dfc86647f.png)

Then you can use a `switch` node to test the time against the times you want it to work.

---

<div class="post-metadata">

**Author:** ![sniperxnl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sniperxnl/32/18250_2.png) [@sniperxnl](https://discourse.nodered.org/u/sniperxnl)\
**Post date:** [6 November 2020 13:09 UTC](https://discourse.nodered.org/t/why-my-lamp-is-going-when-bigtimer-is-set/35319/5 "2020-11-06T13:09:23Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/60b29c78919a936b2b3d0d4be5b57d1a9cd6904f.png)

solved, lamp only goes on when it is between sunrise and sunset, and when it get motion.  
Lamp goes off after 90 seconds.

```auto
[{"id":"38033fc.f8dddc","type":"bigtimer","z":"7bae246d.839dfc","outtopic":"","outpayload1":"true","outpayload2":"false","name":"Big Timer","comment":"","lat":"52.266075","lon":"6.155217","starttime":"5004","endtime":"5003","starttime2":0,"endtime2":0,"startoff":0,"endoff":0,"startoff2":0,"endoff2":0,"offs":"0","outtext1":"","outtext2":"","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"day7":0,"month7":0,"day8":0,"month8":0,"day9":0,"month9":0,"day10":0,"month10":0,"day11":0,"month11":0,"day12":0,"month12":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"repeat":false,"atstart":false,"odd":false,"even":false,"x":680,"y":40,"wires":[["6e93a46e.bebb8c","92cae6d8.0fa0e8"],[],[]]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 January 2021 13:09 UTC](https://discourse.nodered.org/t/why-my-lamp-is-going-when-bigtimer-is-set/35319/6 "2021-01-05T13:09:53Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
