For Homeyscript I want to activate two flows at the THEN part. The app MQTT Hub has the possibility at the THEN part for “Trigger Broadcast”, and Homey System has the possibility at the THEN part for “Restart an App” MQTT Hub. How can I make this possible in a script?
Not sure if you mean something like this:
These scripts show all And & Then cards for your apps in script version.
There’s also an example.
Yes, exactly what i needed. Was aware these exaples were there, but had no idea how to work with it. First attempt was bullseye;
await Homey.flow.runFlowCardAction({
uri: 'homey:app:nl.hdg.mqtt',
id: 'broadcast',
});
But the second one doesn’t work, any idea?
await Homey.flow.runFlowCardAction({
uri: 'homey:manager:system',
id: 'restartApp',
'args': [
{
'name': 'nl.hdg.mqtt',
'type': 'autocomplete'
}
]
});
Check Develop tools in your browser on test of a simple Flow:
{
"id": "restartApp",
"uri": "homey:manager:system",
"group": "then",
"delay": null,
"duration": null,
"args": {
"app": {
"id": "nl.klikaanklikuit",
"name": "KlikAanKlikUit"
}
}
}
Leave away the “group”: “then”, “delay”: null, “duration”: null,
await Homey.flow.runFlowCardAction({
'id': 'restartApp',
'uri': 'homey:manager:system',
'args': {
'app': {
'id': 'nl.hdg.mqtt',
'name': 'MQTT Hub'
}
}
});
This way You mean? Doesn’t work either
This should work:
await Homey.flow.runFlowCardAction({
uri: 'homey:manager:system',
id: 'restartApp',
args: {
app: {
id: 'nl.hdg.mqtt',
name: 'MQTT-Hub'
}
}
})
.catch(err => {
log('error:', err);
})
.then(res => {
log('result:', res);
});
In theorie you only wrote the name wrong (the .catch()
and .then()
are optional), but I like the additional error catching and being able to do anything if the action card succeeded.
works great,thx. Out of curiosity; How do I know what is the right name? I had a little script which gave the name, but that name was wrong
let Appsopvraag = await Homey.apps.getApps();
_.forEach(Appsopvraag, app =>{
console.log(app.name, '',app.id);
})
return true
I copied the name of the app from the app store (the URL).
Looks like it is based on that I guess the regular name (i18n) is able to be changed thus not reliable.
Not sure if you can get it with a script, doesn’t look like it is in the app’s object.
This is the full link
https://homey.app/en-us/app/nl.hdg.mqtt/MQTT-Hub/
https://homey.app/en-us/app/id/name/
That’s the redirect link to the local language app page, curious why your webbrowser still shows that, even all the links on my laptop are all the full-on link, not the redirect link as it already knows the local language.
Perhaps it is being blocked by a (privacy) setting?
Because i always on my iphone that’s the url i get. I tried with my laptop and in that case i get the full link. This is helpfull for the next time i want to script something.
In Firefor I open the app store with apps.athom.com and get redirected to Apps für Homey Pro
After selecting the app I’m on Home Assistant App für Homey | Homey