Beginner needs a quick tip

Hello together

I am currently trying my hand at developing my first app, settings etc are already working…

But what I can not manage, that the flow card runs. I always get the following error message:

Flow Card not registered (type: action, id: disable-piholes)

What do I have to do in app.js to make this work? I am on the hose right now …

If someone has a good example so that I can understand this, I would be grateful.

Please share your code.

1 Like

Thanks for your reply, happy to share what I already have, it’s not much since I’m learning :wink:

So:
There is the whole repository, an action flow called:

disable-piholes.json
{
“title”: {
“en”: “Disable PiHole(s)”
},
“hint”: {
“en”: “Disable PiHole”
},
“args”: [
{
{ “type”: “number”,
}, “name”: “time”,
“placeholder”: {
“en”: “0”
},
“min”: 0,
“max”: 60,
“step”: 5
}
]
}

Then I found out via the docs and a few examples that it should now probably continue in App.js:

const Homey = require(‘homey’);

class App extends Homey.App {
async onInit() {

//Write to the log
this.log('MyApp has been initialized');

//Supply the necessary information
const instance1_url = this.homey.settings.get('Instance1_URL');
const instance1_port = this.homey.settings.get('Instance1_PORT');
const instance1_api = this.homey.settings.get('Instance1_API');

const instance2_url = this.homey.settings.get('Instance2_URL');
const instance2_port = this.homey.settings.get('Instance2_PORT');
const instance2_api = this.homey.settings.get('Instance2_API');

That’s where I’m at now.

Now comes the question, how do I get rid of the error mentioned at the beginning, obviously I need a listener which listens if something happens but its implementation is not clear to me even after reading. I have tried many things and derived, but it has always remained with the error.

Therefore my request for a little push in the right direction :slight_smile:

Thank you very much.

“For every Flow card your app includes, you should register a “run” listener”:

this.homey.flow.getActionCard('disable-piholes').registerRunListener(async (args, state) => {
  console.log('A', args, 'S', state);
});

Ok, that coincides with what I found, and shows me that I am at least on the right track.

Nevertheless the error remains … and that’s what I don’t understand, or not yet :wink:

image

That code fixes the issue, if the error remains it’s either placed in the wrong location or you didn’t restart the app. I assume you’re also not getting the console log message?

1 Like

Hmmmm …
Then it is probably in the wrong place …

I have restarted the app. Console messages I also do not see, resp. I would not know where :frowning:

But if I know that the code works I like to read in further :slight_smile:

So actually I am of the opinion it should be correct, but it still does not go …

What am I missing?

const Homey = require('homey');

class App extends Homey.App {
  async onInit() {

    //Write to the log
    this.log('MyApp has been initialized');

    //Supply the necessary information
    const instance1_url = this.homey.settings.get('Instance1_URL');
    const instance1_port = this.homey.settings.get('Instance1_PORT');
    const instance1_api = this.homey.settings.get('Instance1_API');
    
    const instance2_url = this.homey.settings.get('Instance2_URL');
    const instance2_port = this.homey.settings.get('Instance2_PORT');
    const instance2_api = this.homey.settings.get('Instance2_API');

    //Define the listeners for each necessary FlowCard  
    
    //disable-piholes.json
    this.homey.flow.getActionCard('disable-piholes').registerRunListener(async (args, state) => {
      console.log('A', args, 'S', state);
    });  

    //enable-piholes.json
    this.homey.flow.getActionCard('enable-piholes').registerRunListener(async (args, state) => {
      console.log('A', args, 'S', state);
    });  

  }
}
module.exports = App;

I don’t know what you’re doing wrong (apart from not using the </> button to format your code :wink: ) , this works just fine for me.

Where are the JSON files located? They should be in .homeycompose/flow/actions/

Thanks for your reply again and your time :slight_smile:

Also thanks for the input of the code formatting :slight_smile:

Yes, they are actually really in the right place…

Would it be possible to put your app online somewhere, like Github? The forum isn’t really a great medium to debug these issues.

Answered via DM

Tada…

image

Thank you so much for your help, Robert

1 Like

Will you make this available in the store?

When I get the rest of the functionality, eventually, running, I’ll consider it, yes.

Currently it’s missing something like that and for me it’s my training project to deal with homey app development.

2 Likes

Brief Update:
The app is finished so far and is waiting for approval …

I’m curious whether this works :wink:

The app is now available :slight_smile:

As a result of further development, I am now facing a new problem.

I am currently dealing with the tokens …

image

image

According to SDK the tokens are also defined in app.js, no matter if local or global I have the same error.

If I take the example and the token configuration from the SDK documentation I have the same error.

Does anyone else have an idea?

Hi,
I think you mixed up flow arguments with tokens.

Flow arguments are the input elements in your flow card where the user inserts values you are using in your flow handler.
Flow tokens are returning parametersm the flow card passes back to the flow and you can use in following cards.

Please check if your flow handler is returning the defined tokens.
If you don’t need result tokens, you can remove them from your flow definition.
In general: The flow handler can return tokens (if defined) and in case of an error just throw an error. This will trigger the error output of your flow card (like your screenshot is showing).

Example: Flow definition:
https://github.com/RonnyWinkler/homey.mysql/blob/main/.homeycompose/flow/actions/post_query.json

Example flow handler:
https://github.com/RonnyWinkler/homey.mysql/blob/main/app.js#L21
And the tokens that are returned:
https://github.com/RonnyWinkler/homey.mysql/blob/main/app.js#L159

Your “example” object is missing its end curly bracket.

If it did the app wouldn’t even build.

1 Like