Why Ignition module automatically update the initial record

Hi everyone,

I create a demo module which will create an initial record at the setup procedure.

But when I want to add new record, I find that the initial record will automatically updated.

For example, the initial record I create is “HomeConnect Hub” at the setup procedure.
But if I add a new record which is “NEW CREATED”, the initial record will be updated to “NEW CREATED”.


So my questions are:
1.Is there a way to avoid updated the initial record?
2.I tried not to create the initial record at first time, but then run into an internal error. Why does that happen?
I think the initial record is necessary but I do not know the reason.

Any PersistentRecords (and thus, tables in the internal DB) required for your module to run should be created in your modules GatewayHook#setup() by calling GatewayContext.getSchemaUpdater().updatePersistentRecords()

What it does after that is attempt to create a ‘singleton’ instance of the Home Connect record, in the maybeCreateHCSettings method. What modifications did you make to this example? The 0L primary key is the important part; it’s always referring to records by the HCSETTINGSRECORD_ID. As the module is written, a default record will be created and any editing on the config page will happen on that single record.

For a slightly different approach - say you want to be able to configure additional devices, you can try the secret-keeper module I just wrote up as a proof of concept.
The GatewayHook ensures the required table exists, but does not create any records.
Meanwhile, the SecretManagerPage uses the Ignition API class RecordActionTable to create the default CRUD interaction around a PersistentRecord implementation - you’ll be able to add new records, update existing ones, etc.

2 Likes

Thanks for your reply sir.
I will have a deep look into the code. :+1: :+1: :+1:

Hi @PGriffith, could you provide a link to ‘SecretManagerPage’ (the one in your above comment 404’s)? I am trying to implement the RecordActionTable, but cannot figure out how to get it fully working.

If you browse that repository, you’ll see that it was renamed.

I cannot figure out why, but I am not getting any config panel to show up in my gateway at all. I followed the secret keeper example, but instead created my own config category.

Is there something else I need to do in the gateway setup to create the config link?

The rest of the module is mounted and running? At a glance your code seems fine. Can you upload your code anywhere, or DM me a built module?

Just sent it, the module is in a running state for me… let me know if you need the code, I have it on github but in a private repository… do you do remote support?

IA doesn’t do remote support for module development, it’s very much a ‘pursue at your own risk’ endeavor. I’ll usually help people get started “on my own time” because more module authors means more modules means more community engagement :slight_smile:

Okay I understand. I will DM you the GatewayHook, SettingsRecord, SettingsPage and corresponding properties files!

You’re creating a new ConfigCategory, but not returning it in getConfigCategories() on your gateway hook:

default List<ConfigCategory> getConfigCategories() {
        return null;
    }
1 Like

Wow just like that the ConfigCategory popped up. I’ll keep playing around! Thank you for the help.

1 Like