question

rafl53 avatar image
rafl53 asked

How do change to ordere of the devices in the device list?

I am trying to change the order of the devices on my Venus GX. No idea how to do. Can anybody help me?

Tanks in advance.


Rainer

Venus OS
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

3 Answers
Kevin Windrem avatar image
Kevin Windrem answered Ā·

The code responsible for this page is /opt/victronenergy/gui/qmlPageMain.qml

The function addService is called from a loop in Component.onCompleted when the the GUI switches to the DeviceList page.

You would need to insert code in Component.onCompleted so that addService is called in the order in which you want to see services in the list. I would run the loop and build an array of active services, then recursively look through the list for the first desired service, then the second, etc. each time calling addService.

Notifications and Settings are handled differently and you'd need to play with the VisualItemModel to see if it can be modified to place them in your desired order.


addService is also called from the Connections object. if a new service comes on line after the page was initially built, that service will be appended to the end of the list, bypassing your rearrangement. However, switching to a different page then returning to the Device List page will rebuild the list from scratch, restoring your desired order.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

jbakuwel avatar image
jbakuwel answered Ā·

Hi @Kevin,

I'm familiar with quite a few programming languages but unfortunately not with QML nor Qt.

I have the same request as @Rainer, in my case I'd be very happy with a device list that is sorted alphabetically: that way I can create the order I would like by choosing the device names. Is that just a matter of adding a few lines? Would you be able to show us how? Once done, does the qml file needs to be processed/compiled? Your help is much appreciated :-) !

2 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Kevin Windrem avatar image Kevin Windrem commented Ā·

I looked at the existing code and it is already sorting the list by name. One catch, it apparently builds the list when the system boots so the device's name must be changed then the GUI restarted (or Venus rebooted).

Notifications and Settings are always added at the end of the list.

The code that sorts the list is at the end of /opt/victronenergy/gui/qml/PageMain.qml. There are three options with the first two commented out so option 3 (sort) handles adding devices in alphanumeric order.

If you want devices sorted in another order, this is the place to change the code. Forgive me but I'm not an expert on QML nor do I have visibility into the methods associated with the objects used in that code.

0 Likes 0 Ā·
jbakuwel avatar image jbakuwel Kevin Windrem commented Ā·

Hi Kevin,

Thanks! Restarting the GUI (by killing the process; supervise will restart it) indeed does the job, which is good enough for my purposes. Must say I don't understand the QML code but I guess I already said I'm not familiar with it :-)

have a great day,
Jan

0 Likes 0 Ā·
rossirossi avatar image
rossirossi answered Ā·

You can simply rename devices by starting each one as a number--e.g. "1-BMV712" , "2-Phoenix Charger," "3-Solar Controller" . They will appear in that order.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Related Resources