You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Current »


let timeOfJustNow = new Date();
/*
  just now is a absolute time, if the date shall calculate correctly also 
  a few minutes after midnigth, the time must be absolutely precise

  Homey seemsm to miss the corrrect time with 1 hour, so just test the script and see 
  if it's precise like your armwatch.

  Just run this script i HomeyScript and observe the out put.
*/


// add skew (adjusted time) here
let skew = 1;

// adjust the time with plus or minus skew
timeOfJustNow.setHours(timeOfJustNow.getHours()+skew);

// verify your timezone here, you migth want to comment the next line after assuring the timezone is correct
console.log("time", timeOfJustNow);

// Returns the day of the month (1 – 31) for the specified date according to local time.
let dayInMonth = timeOfJustNow.getDate();
let monthInYear = timeOfJustNow.getMonth();
  
  
// it's only these 3 next lines you should upadet to match your requrements
  
let sheetName = 'Ark 8'; // put the name of your tab in your sheet
let startingColumnChar = 'B'; // set your coumn character for January
let startingRowNbr = 2;       // set your starting row for the first day in month
  
// calulating the column, based on monthNumber
let column = String.fromCharCode( startingColumnChar.charCodeAt(0) + monthInYear);
  
let calulatedCellReference = sheetName + "!"+ column + (startingRowNbr + dayInMonth-1);

// uncomment next line to get result logged
// console.log("result", calulatedCellReference);
  
return calulatedCellReference;




In your flow, create a HomeyScript Run card that returns a Text-tag, and paste the code from above. Then in the next Easy Logger set-cell card, the #Result will contain the reference to the cell of this day

  • No labels