Getting Started - Logic variables

Thanks, yes I understood, and alr created a flow for that :wink: Playing with the script examples right now.
So ofcourse I want the month tag also, but, no way it returns something else but weekday

Inside the Playground



"dateHuman": string "donderdag 29ste april 2021 17:31:41"

I can’t even let the homeyscript return that, and I want to pick the 3rd word of the string in some way I was thinking.

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(' '));
1 Like

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

Many thanks again.

1 Like

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

The var’s (missing in shared flow views)

1 Like

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

Sorry, no.

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

// 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


And I just read the Q from @Simon_Skotheimsvik again,

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

// 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


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.

Yup, 2 hrs difference according to

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:

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.

Hi Simon en Jan @JPe4619 @Simon_Skotheimsvik

With one idea, you get another one :wink:
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)

// 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);

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

1 Like

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

Actually I ment the screenshots from your phone.



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 :flushed: :nerd_face:
Which post do you like to be Englified @Kindbo?

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.


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.


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

{{((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

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}}


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

No problem :grin:
Thank you anyway, both of you were a good help :ok_hand:

1 Like