Getting Started - Logic variables

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.
Cheers

1 Like

So, hereā€™s the flow (instead of 19 flows :crazy_face: )

The varā€™s (missing in shared flow views)
naamdagmaandhscript

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
return(true);

--------------------------------

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

return(true);

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 developer.athom.com:

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:

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)

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

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.

BR

Thomas

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.

2 Likes

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.

3 Likes

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

2 Likes

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