Hey!
I can’t get the HomeyScript console to work.
I’ve tried running several of the examples. But the console is just blank.
Scripts seem to work, I can make Homey say something, but nothing is being written to the console.
Is this a known issue? Any way to get it working?
Thanks!
/Olof
I’ve also tried uninstalling HomeyScript and reinstalling. Logging out and logging back on again.
So far I haven’t tried a re-start of Homey, I guess that might be next.
This is what it looks like when I’m running a script, no output. I tried on my iPad using safari. There I can get the output, so most likely something is wrong with my laptop browser… much annoying…
Maybe you can try a portable browser. You can find different browsers at Portableapps website.
Then you don’t have the problem of installed plug-ins, custom settings, which can cause strange effects.
Are you using any browser extensions that might be causing this issue? Check your browser’s developer console to see if there are any errors popping up.
Hej!
Thanks for the suggestions!
It seems like the issue might be that I was using my company-laptop. There must be something blocking the Homey Script.
I’ve finally found my old private MacBook and using that one I got the Homey Script to work.
Now I just need to learn scripting!
Hoi ik wil een export maken naar google sheets en ik kan dan als variabel de datum meenemen b.v. 17-01-2023.
Wat ik graag zou willen is ook alleen de maand ( 01 ) van die datum (huidige datum van de export) meenemen in mijn export.
Dat moet volgens mij niet moeilijk zijn alleen heb ik geen kaas gegeten van Homeyscript c.a. programeren.
Of eigenlijk nog beter zou ik de datum los als jaar, maand en dag willen zien, nu ik toch bezig ben.
Here is some code. All data will be given as a tag. De tags you don’t need, just add // in front of ‘await tag’. This will give e.g //await tag(‘CurrentDay’, currentDay); and this tag will not be available
var date = new Date();
date.setDate(date.getDate());
const currentDay = date.getDate();
await tag('CurrentDay', currentDay);
console.log('1 CurrentDay is: ' +currentDay);
const currentMonth = date.getMonth() +1; // getMonth() returns month from 1 to 12
await tag('CurrentMonth', currentMonth);
console.log('2 CurrentMonth is: '+currentMonth);
const currentYear = date.getFullYear();
await tag('CurrentYear', currentYear);
console.log('3 CurrentYear is: '+currentYear);
var date = new Date(); // current date
date.setDate(1); // going to 1st of the month
date.setHours(-1);// going to the last day of the previous Month
const yearPreviousMonth = date.getFullYear();
await tag('YearPreviousMonth', yearPreviousMonth);
console.log('4 YearPreviousMonth is: '+yearPreviousMonth);
const lastDayPreviousMonth = date.getDate();
await tag('LastDayPreviousMonth', lastDayPreviousMonth);
console.log('5 LastDayPreviousMonth is: '+lastDayPreviousMonth);
const previousMonth = date.getMonth() +1;
await tag('PreviousMonth', previousMonth);
console.log('6 PreviousMonth is: '+previousMonth);
var date = new Date(); // current date
date.setDate(1); // going to 1st of the month
date.setMonth(-2)// going back two months
date.setHours(-1);// going to the last day of the previous Month
const yearPreviousTwoMonth = date.getFullYear();
await tag('YearPreviousTwoMonth', yearPreviousTwoMonth);
console.log('7 YearPreviousTwoMonth is: '+yearPreviousTwoMonth);
const previousTwoMonth = date.getMonth() +1;
await tag('PreviousTwoMonth', previousTwoMonth);
console.log('8 PreviousTwoMonth is: '+previousTwoMonth);
var date = new Date();
date.setDate(date.getDate());
function getDaysInMonth(year, month) {
return new Date(year, month, 0).getDate();
}
const daysInCurrentMonth = getDaysInMonth(currentYear, currentMonth);
await tag('DaysInCurrentMonth', daysInCurrentMonth);
console.log('9 DaysInCurrentMonth is: '+daysInCurrentMonth);
const daysInPreviousMonth = getDaysInMonth(currentYear, previousMonth);
await tag('DaysInPreviousMonth', daysInPreviousMonth);
console.log('10 DaysInPreviousMonth '+previousMonth +' is: '+daysInPreviousMonth);
var date = new Date();
date.setDate(date.getDate()-1);
const yesterDay = date.getDate();
await tag('YesterDay', yesterDay);
console.log('11 YesterDay is: ' +yesterDay);
const yesterDayMonth = date.getMonth() +1; // getMonth() returns month from 0 to 11
console.log('12 YesterDayMonth is: ' +yesterDayMonth);
await tag('YesterDayMonth', yesterDayMonth);
const yesterDayYear = date.getFullYear();
await tag('YesterDayYear', yesterDayYear);
console.log('13 YesterDayYear is: '+yesterDayYear);
var date = new Date();
date.setDate(date.getDate());
@Jeroen_W
There is also a Get Insights card, which you can set to 0 minutes. It contains the same tokens.
That one can be used on any trigger, so you don’t need the Watch/listener card perse.
Dipping my toes into HomeyScript, sorry for newbie question but I tried to but could not find answer in the linked documentation. I found how to set a tag, but not how to read it.
In a “Run and return …” Advanced When-action, how do I get the value that is passed in a tag, for example in this little test flow?
Use case: I want to extract the “0” from the text here, so I need to read the “Result” text-tag (this is for testing, in real life the tag would be a topic from the MQTT cient).
And a second question while I’m at it, how do I set and read an Advanced Flow variable?
I think this is a good start to get into Homey logics
Use the Hscript card Run code with Argument and return text-tag.
You also see the local tag of both cards is called [Result]. (Local tag = this flow only); the info popup is shown while hovering the tag symbol in the flowcard.
The local tag from the Logic card is used as argument to the Hscript card; In the tag picker, the tags under “This flow” are tags provided by the used flowcards
When we have equally named tags, hover the tag in the picker list, to discover to which flowcard it belongs. The flowcard will glow blue and the tag symbol becomes blue: