Custom widget for multiple measurements

Hi there,
I’m trying to adjust the measurement widget to accommodate 2 or 3 measurements, however, since coding is not my strenght I’m using chatgpt. So far the custom widget is imported successfuly, it has fields for the measurements etc, however it does not show the values:

Any idea how to fix that?
Here is the code:

widget_measurement_custom.py (10.2 КБ)

1 Like

There were some strange edits I found. I got this working and made a commit with the new widget:

You can upgrade to master if you would like to test. Please let me know if you encounter any issues.

1 Like

Hi Kyle,
thanks for taking the time to look in to this!
Upgraded to master, after a nginx 403 forbidden error and restarting the flask service it works as expected.
image
Just to confirm - if I want to create a 3 measurement widget should I just edit the code in custom file, or there are other changes that needs to be done elsewhere?

edit: it seems the 1 value widgets are somewhat broken - the same input which is visualized in 2-value does not show up

All widget code is contained in the single file.

I’ll look into the single measurement widget. Does that issue only present itself when both widgets are on a dashboard, or does the single measurement widget never work on your system? The more information about replicating the issue, the better.

I wasn’t able to replicate the issue. Both widgets work as expected for me. If you can provide detailed steps to replicate the issue, I’ll investigate further.

After deleting all the old widgets (created prior to upgrade to master) the new 1-v widgets started working. However for some reason the daemon status is lost and nothing is to be found in logs (it’s not a restart i guess)
Anyway, created another dashboard and 1-v widgets are working
image
After adding 2-v widget with same measurement the 1-v stops visualizing data:


If I add same measurement to another 2-v it works

Another thing on the old dashboard is if i have 1-v widget with measuremment which is also present on the graph daemon goes orange:


After removing the 1-v everything works as expected.
Anyway, i’ll delete all graphs etc later and recreate it to see if the graph could be causing it.
If there are any logs that could be of use to you?

1 Like

The browser console log will show Javascript errors and the Mycodo Frontend log will show errors with widget Python code.

I was able to replicate the issue. I’ll look into how it can be fixed.

1 Like

Strange enough I couldn’t replicate it several days ago. Perhaps i didn’t do the exact same thing.
Anyway,happy to hear you found it.
For anyone interested attached is the code for 3 measurement custom widget.
image


widget_measurement_custom.py (22.1 КБ)

This fix should resolve the issue: