# Different action day/night

**URL:** <https://discourse.nodered.org/t/different-action-day-night/58335>\
**Category:** General\
**Tags:** node-red-dashboard, function-node\
**Created:** [14 February 2022 19:18 UTC](https://discourse.nodered.org/t/different-action-day-night/58335 "2022-02-14T19:18:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maceddy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maceddy/32/34648_2.png) [@maceddy](https://discourse.nodered.org/u/maceddy)\
**Post date:** [14 February 2022 19:18 UTC](https://discourse.nodered.org/t/different-action-day-night/58335/1 "2022-02-14T19:18:39Z")

</div>

I am playing around with weather icons linked to a weather API and the wi icons library.  
However, I want to split some of the icons in day and night (for example, Clear Sky).

I build a function with a switch/case. When the status is 'clear sky' use icon wi-clear sky (for example).  
However, this means I have the same icon day or night time (the sun).

How can I also implement day and night? I have the nighttime addin which returns isNight in true or false but I can not figure out how I can implement this into my function properly. I read some things about the join node but not quite clear yet.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [14 February 2022 19:22 UTC](https://discourse.nodered.org/t/different-action-day-night/58335/2 "2022-02-14T19:22:45Z")

</div>

save the isNight boolean to a context variable, then in your function you can get the context variable and change icon if true or false.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 February 2022 20:43 UTC](https://discourse.nodered.org/t/different-action-day-night/58335/3 "2022-02-14T20:43:48Z")

</div>

I have several bits of info that I send out to MQTT either every minute or every day:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/97916ea32a7140e325a5c37601895d113937c6f9.png)

Notably the sleep and daylight entries. Sleep on/off is at a set time each day. Daylight is true or false depending on the sun position and time of year.

CRON+:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c05906e21c52af029065f1a1304d0f2149565494.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/0873e824a984e1be515e3e35f892e7eaf22be414.png)

Then lighting can be controlled in various ways:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/7/177c79d81bd926020dbc4c0c06ed2d53f2907d09.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/ef8dc6aa6ae48b267c069aa916001013f0854de2.png)

Both of those are Ikea Zigbee devices controlled via Zigbee2MQTT.

---

<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:** [15 April 2022 20:44 UTC](https://discourse.nodered.org/t/different-action-day-night/58335/4 "2022-04-15T20:44:40Z")

</div>

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