# Getting Started - Logic variables

**URL:** <https://community.homey.app/t/getting-started-logic-variables/20132>\
**Category:** Tutorials\
**Created:** [November 2, 2019, 12:54pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132 "2019-11-02T12:54:10Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [April 29, 2021, 5:14pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/61 "2021-04-29T17:14:33Z")

</div>

Indeed the 3rd word, but it has not a fixed place in the string, so I used the index of the spaces:

> console.log (SysInfo.dateHuman); // just to show dateHuman

```
   var temp = SysInfo.dateHuman.slice(SysInfo.dateHuman.indexOf(' ')+1);
    temp = temp.slice(temp.indexOf(' ')+1);
    var Maand = temp.slice(0,temp.indexOf(' '));

```

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [April 29, 2021, 5:17pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/62 "2021-04-29T17:17:39Z")

</div>

> [@JPe4619](#):
>
> I used the index of the spaces

Clever. I wondered why it was empty, and had more than one space between the ’ ’

Many thanks again.  
Cheers

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [April 29, 2021, 7:38pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/63 "2021-04-29T19:38:09Z")

</div>

So, here’s the flow (instead of 19 flows 🤪 )

The var’s (missing in shared flow views)  
 ![naamdagmaandhscript](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/6/f6ac04803ee4376be81321152ce91eeef4992c45.png)

---

<div class="post-metadata">

**Author:** ![Simon\_Skotheimsvik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/simon_skotheimsvik/32/34205_2.png) [@Simon\_Skotheimsvik](https://community.homey.app/u/Simon_Skotheimsvik)\
**Post date:** [April 30, 2021, 11:39am UTC](https://community.homey.app/t/getting-started-logic-variables/20132/64 "2021-04-30T11:39:59Z")

</div>

> [@JPe4619](#):
>
> `SysInfo.dateHuman.slice`

Thanks for input regarding this issue. Do you know how I can figure out the dateHuman for tomorrow?

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [April 30, 2021, 12:13pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/65 "2021-04-30T12:13:21Z")

</div>

Sorry, no.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [May 13, 2021, 7:35pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/66 "2021-05-13T19:35:05Z")

</div>

> [@JPe4619](#):
>
> some/most can be done in HomeyScript:
> 
> ```auto
> //MyCreateDay-Tag.js
> 
> let SysInfo = await Homey.system.getInfo();
> var weekDay = SysInfo.dateHuman.slice(0,(SysInfo.dateHuman.indexOf(' ')));
> await tag("WeekDay", weekDay ); //creating new HomeyScriptTag 'WeekDay'
> console.log("Weekdag", weekDay);
> return(true);
> 
> ```

`-----------------------------------`  
Just for fun, I got a q how to display the weekday on a dash, and found out this works also:

```auto
// Create a date object
    var date = new Date();
    var week = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag']; // Create an array of weekday names
    await tag("NaamVanDag", week[date.getDay()] ); //creating new HomeyScriptTag 'NaamVanDag'
    console.log( "NaamVanDag", week[date.getDay()] ); // Displays the name of today
return(true);

```

`--------------------------------`

And I just read the Q from @Simon_Skotheimsvik again,

> [@Simon\_Skotheimsvik](#):
>
> Do you know how I can figure out the dateHuman for tomorrow?

this should be quite simple when using the array of weekdays. Just start the array with a different day 😉

```auto
// Create a date object
var date = new Date();
var week = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag']; // Create an array of weekday names
var weekTomorrow = ['Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag','Zondag']; // Create an array of weekday names, but one day ahead
   
   await tag("NaamVanDag", week[date.getDay()] ); //creating new HomeyScriptTag 'NaamVanDag'
   await tag("NaamVanMorgen", weekTomorrow[date.getDay()] ); //creating new HomeyScriptTag 'NaamVanMorgen'

   console.log( "NaamVanDag", week[date.getDay()] ); // Displays the name of today
   console.log( "NaamVanMorgen", weekTomorrow[date.getDay()] ); // Displays the name of tomorrow

return(true);

```

 ![weekdag_morgen_opvragen](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/6/c67685229a645c55f0262c06a76ef370033c4111.png)

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [May 14, 2021, 7:48am UTC](https://community.homey.app/t/getting-started-logic-variables/20132/67 "2021-05-14T07:48:17Z")

</div>

Always fun to hassle with HomeyScript, btw, did you test this also between 00:00h and 02:00h? I had the problem that Homey is using UTC time in HomeyScript, so the day change is at 02:00h in the summer. That’s the reason for me to use dateHuman.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [May 14, 2021, 9:14am UTC](https://community.homey.app/t/getting-started-logic-variables/20132/68 "2021-05-14T09:14:08Z")

</div>

Yup, 2 hrs difference according to [developer.athom.com](http://developer.athom.com):

```auto
date|2021-05-14T08:41:54.727Z
dateHuman|vrijdag 14de mei 2021 10:41:54|

```

Yea, I’m aware of the UTC vs. local time sh\*t.  
Why did Athom change the system time to UTC. Very impractical for ‘normal’ @ home use imho.

Well, it’s a big discussion about what time to use, this is Geurt’s view on it:

> [@\[App\]\[Pro\] PaperTrails Log - Advanced Logging and SysLog](https://community.homey.app/t/app-papertrails-log-advanced-logging-and-log-management-v0-6-3/40/20):
>
> Hi Aart, Sorry I missed your msg. Question, What is your Timezone (Where does your Homey Live) and what time do you see in: [Homey Developer Tools](https://developer.athom.com/tools/system) in Papertrials Log and in your Syslog server? I use internally and send the UTC/ Zulu time in my app ( var logDate = new Date(); ) For me it is in [Homey Developer Tools](http://developer.athom.com/tools/system:) |date|“2019-03-05T20:43:20.533Z”| |dateHuman|“dinsdag 5de maart 2019 21:43:20”| and in Papertrails Log I see: [2019-03-05T20:43:40.035Z] test 21:43 in my Syslog server…

So if Hscript Date() returns zulu time, the new day / next day flows which triggers scripts using that, should be running at 02:01AM during Day Saving time,  
and at 01:01AM during ‘normal local time’.  
My holy, who invented this mess🙈

But, to keep it practical, for me this does the job:  
I won’t need written / spoken weekdays or months before 6:00AM UTC+2  
So the flows can run at 02:01AM UTC on my system.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [May 14, 2021, 1:49pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/69 "2021-05-14T13:49:55Z")

</div>

Hi Simon en Jan @JPe4619 @Simon_Skotheimsvik

With one idea, you get another one 😉  
This script returns the name of **the next day** (a bit quick ‘n’ dirty, but it works), and it can be run right after midnight (no hassle with UTC times and what not)

```auto
//MyCreateTomorrowName-Tag.js
// This script creates tag named NaamVanMorgen and then this script
// updates the value of it with the name of the *the next* weekday.

let SysInfo = await Homey.system.getInfo();
var weekDay = SysInfo.dateHuman.slice(0,(SysInfo.dateHuman.indexOf(' ')));
if ( weekDay == "maandag" ) { weekDay = "dinsdag" } // if contents of 'weekDay' equals [maandag], then overwrite it with [dinsdag]
 else if ( weekDay == "dinsdag" ) { weekDay = "woensdag" }
  else if ( weekDay == "woensdag" ) { weekDay = "donderdag" }
   else if ( weekDay == "donderdag" ) { weekDay = "vrijdag" }
    else if ( weekDay == "vrijdag" ) { weekDay = "zaterdag" }
     else if ( weekDay == "zaterdag" ) { weekDay = "zondag" }
      else if ( weekDay == "zondag" ) { weekDay = "maandag" }
       else weekDay = "Unknown until tomorrow..."

await tag("NaamVanMorgen", weekDay ); //creating new HomeyScriptTag 'NaamVanMorgen'
console.log("NaamVanMorgen", weekDay);
return(true);

```

---

<div class="post-metadata">

**Author:** ![Kindbo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kindbo/32/9660_2.png) [@Kindbo](https://community.homey.app/u/Kindbo)\
**Post date:** [October 20, 2021, 12:55pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/70 "2021-10-20T12:55:04Z")

</div>

Would it be too much trouble to switch to English when making screen dumps?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [October 20, 2021, 1:22pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/71 "2021-10-20T13:22:14Z")

</div>

If you mean the weekdays (the rest is in English?):

 ![Screenshot_20211020-152043_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/2/f24f7c032889361df6b28596fa53169083aeaab3.jpeg)

---

<div class="post-metadata">

**Author:** ![Kindbo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kindbo/32/9660_2.png) [@Kindbo](https://community.homey.app/u/Kindbo)\
**Post date:** [October 20, 2021, 1:36pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/72 "2021-10-20T13:36:08Z")

</div>

Actually I ment the screenshots from your phone.

BR

Thomas

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [October 20, 2021, 4:47pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/73 "2021-10-20T16:47:53Z")

</div>

Thanks Thomas, I’ll try to remember switching to EN first when taking screenshots. Oh crap, I just discover Homey has to restart to change the language 😳 🤓  
Which post do you like to be Englified @Kindbo?

---

<div class="post-metadata">

**Author:** ![Kindbo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kindbo/32/9660_2.png) [@Kindbo](https://community.homey.app/u/Kindbo)\
**Post date:** [October 21, 2021, 7:13am UTC](https://community.homey.app/t/getting-started-logic-variables/20132/74 "2021-10-21T07:13:51Z")

</div>

I just don’t read more than English and Swedish, so every other language makes it harder for me.

I am Swedish, but use English for Windows, Android and Homey. That way it is easier to search for help and apply what I find.

---

<div class="post-metadata">

**Author:** ![Ricardo\_Nunes](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ricardo_nunes/32/30598_2.png) [@Ricardo\_Nunes](https://community.homey.app/u/Ricardo_Nunes)\
**Post date:** [January 12, 2022, 8:36pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/75 "2022-01-12T20:36:38Z")

</div>

Hello there.

I want to obtain the result of a calculation in a flow but I’m not being able to achieve what I want.

I want something like this {{tag from power meter \* 0.1445+23%}}  
That being whatever kws that are in that tag, x 0.1445€ (price of electricity in my country) +23% taxes…

But homey does not make that multiplication, i have created a numerical variable in logic with the 0.23 value but even using that tag from logic it doesn’t work, i must be doing something wrong for sure…

If someone can explain me how to achieve this I’ll appreciate it.

---

<div class="post-metadata">

**Author:** ![Dijker](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dijker](https://community.homey.app/u/Dijker)\
**Post date:** [January 12, 2022, 8:46pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/76 "2022-01-12T20:46:04Z")

</div>

> [@Ricardo\_Nunes](#):
>
> I want something like this {{tag from power meter \* 0.1445+23%}}

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 12, 2022, 8:55pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/77 "2022-01-12T20:55:22Z")

</div>

Edit: didn’t see the easier calculation from Geurt, while I was busy with this 😉

{{((tag from power meter \* 0.1445) + (tag from power meter \* 0.1445) \* 0.23)}}

My meter reads 1835 kWh  
With your data and this flow

this is the result

 ![Screenshot_20220112-215011_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/d/add8809e125f8df2dce35a142c4a084c55379542.jpeg)

If you’d like to round the price to 2 decimals:  
{{round(((tag from power meter \* 0.1445) + (tag from power meter \* 0.1445) \* 0.23)\*100)/100}}

---

<div class="post-metadata">

**Author:** ![Ricardo\_Nunes](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ricardo_nunes/32/30598_2.png) [@Ricardo\_Nunes](https://community.homey.app/u/Ricardo_Nunes)\
**Post date:** [January 12, 2022, 10:21pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/78 "2022-01-12T22:21:29Z")

</div>

That’s actually pretty easy, but i didn’t know it.  
Thank you soo much 👌

---

<div class="post-metadata">

**Author:** ![Ricardo\_Nunes](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ricardo_nunes/32/30598_2.png) [@Ricardo\_Nunes](https://community.homey.app/u/Ricardo_Nunes)\
**Post date:** [January 12, 2022, 10:24pm UTC](https://community.homey.app/t/getting-started-logic-variables/20132/79 "2022-01-12T22:24:07Z")

</div>

No problem 😁  
Thank you anyway, both of you were a good help 👌

---

<div class="post-metadata">

**Author:** ![Matti\_Hirvonen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/matti_hirvonen/32/79184_2.png) [@Matti\_Hirvonen](https://community.homey.app/u/Matti_Hirvonen)\
**Post date:** [April 25, 2024, 7:01am UTC](https://community.homey.app/t/getting-started-logic-variables/20132/81 "2024-04-25T07:01:06Z")

</div>

Hi! What am i doing wrong because result is “Nan”.

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/5/1556b5e18a61df99fd86d74e3fb5409c121ea416.png)

[Previous page](https://community.homey.app/t/getting-started-logic-variables/20132.md?page=3)

[Next page](https://community.homey.app/t/getting-started-logic-variables/20132.md?page=5)
