[APP][Pro] HomeyScript

YW!

You can write & read logics variables like this

.

Yeah you can see the log when test run a Hscript block.
I don’t know exactly how, but you can log errors, which should be returned by the ‘red’ wire of flowcards / hscript blocks.
You should catch errors like this

‘Normal’ console.log output you can redirect to a Homeyscript tag, or a logics var.
Or, use the ‘return’, which writes to the ‘result’ tag of Hscript blocks

.
You can use (almost?) any ‘And’ or ‘Then’ flowcard as well. Take a look at the example scrips in Hscript
Write log to timeline:

Homey.flow.runFlowCardAction({
        uri: 'homey:manager:notifications',
        id: 'create_notification',
        args: {
          text: 'This is a test Timeline notification sent by Homeyscript'
        }
});


  • Write log to push message:
    First run this little script
// To send a push message for example, you'll need the id and athomId of the user
resId = await Homey.users.getUsers().then(f => Object.values(f).reduce((r,b,c)=>Object.assign(r, {[b.name]:b.id}), {}));
log("The \'id\' of the users:\n", resId);

resAthomid = await Homey.users.getUsers().then(f => Object.values(f).reduce((r,b,c)=>Object.assign(r, {[b.name]:b.athomId}), {}));
log("\n\nThe \'athomId\' of the users:\n", resAthomid);


  • Send the actual pushmessage using the id and athomId:
Homey.flow.runFlowCardAction({
        uri: 'homey:manager:mobile',
        id: 'push_text',
        args: {
			    user: {
			    id: 'xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx',
			     athomId: 'xxxxxxxxxxxxxxxxxxxxxx',
		    	},
		    text: 'This is a test push notification from HomeyScript'
        },
      });
  return(true);