Disabling items for a "possibleValues" List


I’m developping a Nymea plugin for a Mect Device (a 4.3" HMI Panel with TCP Modbus interface) that acts like a Burglar Alarm.

I can’t find a template (a device interface) for a similar device.

Also I would like to set a “stateType” of type QString with some predetermined values (in the “possibleValues” list), to set internal device properties.

However, I would need to be able to disable some items in this list depending on the current state of the device, but I couldn’t find a way to do it.

Has anyone tried to do something similar?


You’re right that currently it’s not possible to disable values from that list. Also this is a known limitation and should sure be improved at some point. Recently we’ve added api to adjust min/max values dynamically but we intentionally haven’t added this to the possibleValues list yet, as the topic is a bit more complex. For instance they’re also not translatable right now. Ideally we’d find a solution that solves all those things at once.

That said, there may be options to approach your current implementation differently. Can you post the possible values for this case and which ones would need to be disabled in which circumstance so I can wrap my head around it properly?

Hi Mr Zanetti,

thanks for your fast and kind reply.

The devices we are connecting to nymea are quite complex and have an information-rich HMI on board, and are part of a new line of Smart Home products that we are designing, for which Nymea seems a very valid choice.

I’m trying to simplify the interface to the anti-theft device in nymea to implement status changes (eg OFF, ARMED, ENABLED, RINGING) and commands that depend on the current status (ARM, NOTHING, DAYTIME, NIGHTIME, TEST) without displaying all the other properties of the device, just to do the most important things from a remote device connected with Nymea

Perhaps the simplest thing is to show the current state as a QString with a list of “possibleValues” and set the state to something like a QPushButton (speaking in Qt) to which I can change the “Caption” in the Plugin code and better yet also the “background color” according to the current state.

Unfortunately I don’t understand how buttons can be defined in the plugin and how to use them.

If possible, an example of how to implement this feature would help me a lot.

Thank you in advance

So, we’ve taken the design decision that plugin developers must not have a direct influence on the UI. Because low level developers that shift registers and UX designers that paint figma pictures are the most distant species on earth when it comes to how a user interface should look like… The app UI clearly is the area of the UX designer. So you will not be able to set any button color or text directly from the plugin unless you develop the client app and somehow inject data where the plugin dev and UX designer agreed on. This will cause the UI to only work/look good with that defined set of plugins from the same developer, so we don’t do that. The proper approach for this would be to define such behaviors in so called interfaces (interfaces · documentation). Those can define, for example in their description, that in a particular case, only some of the possibleValues may be valid and the UI should hide the others.

If you only want to get going with the actual functionality, and don’t really care much about how the UI looks as long as you can execute those actions, you may (or may not) find the browsing feature useful. With that, the app would dynamically load a list of entries. Could be browsing a media library, scenes like the hue bridge plugin does, or rooms to clean like the neato botvac plugin does. You could probably also list the currently available commands there.

That all being said, having an option to just disable some of the possibleValues in a stateType may still be a valid use which we will eventually add (not giving any time estimate here).

FIY: if you are developing for nymea something modbus related, I’m working currently on a tool which saves you a lot of typing and all the boring register code typing. Maybe you can have look at it. It gernates you a class to interact with the modbus device on c++ types, and all the data conversion and modbus handling, initialization and update mechanism covered within the generated class. From the plugin perspective you just need to use the generated class.

It is a quiet early stage of the tool, and still some things to do, but the most common stuff is covered.
If you want to contribute something modbus related, this would be the place to add modbus stuff (since modbus is not available on all plattforms we support). Also, the tool is designed to work within this repository.

Hi Simon,
thanks for your suggestion.

A few weeks ago when I started developing the Plugin, I saw that the QtSerialBus module was not included in the standard Qt / QtCreator installation for Nymea, so I had to use a modbus.cpp module (https://github.com/fanzhe98 / modbuspp) that we had already used for the development of a small App for Android, and manually parse the registers I need.

How did you solve this problem?

For the moment this solution is sufficient (as you have read at the moment there are more serious problems still to be solved), but I will gladly consider alternatives when the rest works better.

Thanks a lot!


Hi Michael,

I absolutely don’t want to upset the UI layout of the Plugins, I’m not a UI Designer, I just need to make things work at the simplest level possible! :slight_smile:

I think it would be enough for me to be able to define some pushButtons in Plugin (as a Qt QPushbutton), set the text in the button (fixed) and find out when the user presses a button.
The best would be to be able to disable and enable the buttons from code, but I can also decide not to do anything if the current state of the system does not allow it (ugly but it could work for the moment)

The problem is that I didn’t understand how to do it … (and I haven’t been able to find an example in the GitHub Plugin library to learn something from …)

Forgive me but I’m a old Qt Widgets programmer …

Thanks for your patience!


Right… so, you can define buttons in the raw thing view (The one you get when clicking on “Details”) by defining actions. They cannot be enabled/disabled at runtime (although I need to think about that, could be a valid addition) so for now, your best bet is to just do nothing with them as you suggested - ugly but it’ll do). I’ll keep dynamic disabling of actions in mind though.


Thanks, simple buttons now work!

It was simpler than I thought … :upside_down_face:

Many thanks!