Add Homey Scripts section to forum?

Just wanted to pitch for a dedicated “Homey Scripts” section on the forum. This would not necessarily be a “help” or “developer” section like already available, but a dedicated section where users can share working / ready-to-go scripts.

I believe this can help to showcase and optimise scripts and spark many new creative ideas (that might turn in to apps).

3 Likes

In the meantime you can have a look at:

1 Like

Thank you for sharing (consolidating). Already becoming my favorite post :wink:

1 Like

as for further reference, this has been asked before and kind of declined because we have tags:

1 Like

Thank you for pointing this out. Did not find that post myself. Sad to hear though, requested by multiple users but no considered because of a “feature” on the forum. A feature doesn’t make a good content section that thrives by itself.

Small script i use in flows to send push messages to all users easily based on groups. Need to refine it a bit though.

/* 
  Group Push Notifications
  Accepts a homey user group (owners, managers, guests) as input to send push messages to all group members.
*/ 

const obj = JSON.parse(args[0]);
const role = obj.role;
const msg = obj.msg;

/* Run checks */
if (typeof args[0] !== 'string') {
  throw new Error('This script must be run from a Flow!');
}
if (typeof role !== 'string') {
  throw new Error('A role selector required as first argument!');
}
else if (typeof msg !== 'string') {
  throw new Error('A push message is required as second argument!');
}

/* Get Users */
const users = await Homey.users.getUsers();

const pushList = Object.values(users).filter(user => user.role === role);

/* Send Push Notification(s) */
for (const user of pushList) {
  console.log(user);
  const response = await Homey.flow.runFlowCardAction({
    uri: 'homey:manager:mobile',
    id: 'homey:manager:mobile:push_text',
    args: {
      user: {
        athomId: `${user.athomId}`
      },
      text: obj.msg
    },
  });
}
  
return(true);
1 Like