# Starting flows from a script

**URL:** <https://community.homey.app/t/starting-flows-from-a-script/147445>\
**Category:** Flows\
**Created:** [December 20, 2025, 6:35pm UTC](https://community.homey.app/t/starting-flows-from-a-script/147445 "2025-12-20T18:35:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheKos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thekos/32/33969_2.png) [@TheKos](https://community.homey.app/u/TheKos)\
**Post date:** [December 20, 2025, 6:35pm UTC](https://community.homey.app/t/starting-flows-from-a-script/147445/1 "2025-12-20T18:35:12Z")

</div>

I need to start a flow from a script. I have been experimenting with the code below, I partly found in this community and partly used the help from copilot. However it will not work, it finds the correct flow id, however it throws an error ❌ Script Error​:warning: null . I have no clue anymore what’s wrong. here is my simple script. The error arises from await Homey.flow.runFlowCardAction({.

I have a 2019 Homey pro. Any ideas what I’m not seeing ?

const flow\_name = ‘LogToTimeline’  
log (‘start script’);  
// filter flow object by flow name

const flows = await Homey.flow.getFlows();

//Find the flow name  
const flow\_obj = Object.values(flows).find(f =\> f.name === flow\_name);

log(flow\_obj);  
// fetch flow id from flow object  
const flow\_id = flow\_obj.id;  
log (flow\_id);  
// start flow if there is a flowid found  
if (flow\_id){  
await Homey.flow.runFlowCardAction({  
uri: ‘homey:manager:flow’,  
id: ‘programmatic\_trigger’,  
args: { flow: { id: flow\_id } }  
});  
}

---

<div class="post-metadata">

**Author:** ![TheKos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thekos/32/33969_2.png) [@TheKos](https://community.homey.app/u/TheKos)\
**Post date:** [December 21, 2025, 9:55am UTC](https://community.homey.app/t/starting-flows-from-a-script/147445/2 "2025-12-21T09:55:33Z")

</div>

To overcome the issue, I now use a workaround, I trigger the flow when a variable has changed, and change the variable from the script. From software development perspective an awful solution, but I did not see another one, and end of the day it works. Here is my updated script :

const varsObj = await Homey.logic.getVariables();  
const vars = Object.values(varsObj);

const variable = vars.find(v =\> v.name === ‘TimeLineMessage’);  
const varlog = vars.find(v =\> v.name === ‘PublishLog’);  
log(variable);  
log(varlog);

if (!variable || !varlog) {  
throw new Error(“Logic variable not found”);  
}

if (variable.type !== ‘string’) {  
throw new Error(`Variable 'TimeLineMessage' must be of type 'string', but got '${variable.type}'`);  
}

if (varlog.type !== ‘boolean’) {  
throw new Error(`Variable 'TimeLineMessage' must be of type 'boolean', but got '${varlog.type}'`);  
}

const message = "Sensor restarted at " + new Date().toLocaleString();

await Homey.logic.updateVariable({id: variable.id, variable: {value: message}})  
await Homey.logic.updateVariable({id: varlog.id, variable: {value: true}})  
await Homey.logic.updateVariable({id: varlog.id, variable: {value: false}})
