Script Error
Cannot read property ‘id’ of undefined: Cannot read property ‘id’ of undefined
at /node_modules/athom-api/dist/index.js:1:1186403
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I tried to find a solution in this forum and documentation, but I am a little bit lost.
Is it even possible to do it this way?
What did I wrong?
// Run 'Show Animation' Flow 'Then' Card
// This will pulse Green (#00FF00) when it's a weekend
// or pulse Red (#FF0000) when it's a weekday
await Homey.flow.runFlowCardAction({
uri: 'homey:manager:ledring',
id: 'show_animation',
args: {
animation: 'pulse',
color: isWeekend
? '#00FF00'
: '#FF0000',
},
});
Ok, it’s your experience, thx for your description, I learnt a lot.
And reached my goal to call flows by name in an action card with a logic variable via homeyscript:
/*
* This script starts a flow by Flow Name with a logic variable in a 'Then' Flow Card.
* This script overcomes the disadvantage of the manual Flow Start Card,
* which currently (6-17-2021) does not allow you to use tags to start other flows.
*/
// homeyscript action card argument -> flow name
const flow_name = (typeof args[0] === 'string')
? args[0]
: 'dummy';
// filter flow object by flow name
const flow_obj = await Homey.flow.getFlows({ filter: {name: flow_name}});
// fetch flow id from flow object
const flow_id = Object.keys(flow_obj)[0];
// start flow
if (flow_id){
await Homey.flow.runFlowCardAction({
uri: 'homey:manager:flow',
id: 'programmatic_trigger',
args: { flow: { id: flow_id } }
});
}
Edit: improved code a little bit
flow-start = homeyscript name
BW* = logic text variable with flow name
Very interesting. So, from what I understand your goal is:
you can start flow X from flow A, while the name of flow X depends on the value of a variable?
Exactly, that’s the charm vs. the manual configuration of a flow start because in this case you can’t use tags.
Reduces the flow amount immense. My use case is an irrigation system with a lot of cascading flows which are reused for each of 12 cycles.
So with this configuration the finish of a timer flow starts other flows dynamically. Which means I need only this one timer flow and not 12 of them which start distinct other flows.