History chart on insights?

I finally managed to get the logs of my devices going into a nice data table on the asset dashboard. Can I somehow get this same overview on an insights dashboard?

1 Like

Unfortunately not yet. It is not on the short term planning, but it is on the list.
Depending on your skillset you could add the widget yourself and open a pull request :slight_smile:

Don

1 Like

Hi @cheezymcsquibble , I love the way you configured your columns. Can you please share the headerConfig or what was needed to display the attribute so nicely in the history?

Thanks a lot!

Actually, turns out if you create an attribute of type JSON, it will automatically display as table data - as long as you have the ‘show on dashboard’ enabled!

Thanks for your reply. Still, for some reason, on my side it doesn’t want to display data and I also get an error: invalidAttribute


These are my attribute settings:

Any ideea @Don @Rich ?

Thanks a lot everyone!

you need to change the history timeframe to ‘Hour’ instead of ‘day’

Nah, same thing:

Seems to “crash” the history panel as soon as I select the “Status” attribute

also there is a 500 error in the console:

hmm… not really sure… One thing that is different is that my attribute name is ‘logs’, whereas yours is ‘status’ which is also a key in your json. Maybe it gets confused how to handle it?

had the exact same issue on another attribute with ValueDescriptor as ENUM
public enum ModeValueType {
AUTO,
ON,
OFF
}

public static final ValueDescriptor<ModeValueType> MODE_VALUE_TYPE_VALUE_DESCRIPTOR =
        new ValueDescriptor<>("modeValueType", ModeValueType.class);

public static final AttributeDescriptor<ModeValueType> MODE_VALUE_TYPE_ATTRIBUTE_DESCRIPTOR =
        new AttributeDescriptor<>("mode",
                MODE_VALUE_TYPE_VALUE_DESCRIPTOR,
                new MetaItem<>(MetaItemType.LABEL, "Controller Mode"));

// new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true)

Same error, same 500

I see now the manager logs:
Error for mode (enum type):
ERROR [WebService task-2 ] rnate.engine.jdbc.spi.SqlExceptionHelper : ERROR: invalid input syntax for type boolean: ““AUTO””

Error for JSON:
ERROR [WebService task-4 ] rnate.engine.jdbc.spi.SqlExceptionHelper : ERROR: invalid input syntax for type boolean: “{“reason”: “sunrise”, “status”: false}”

Still…no ideea where does this come from, yet

Still no idea what’s going on…

I keep getting this error when I select the history for the below Attribute:

public static final AttributeDescriptor<BaseJsonNode> STATUS =
        new AttributeDescriptor<>("status",
                ValueType.JSON,
                new MetaItem<>(MetaItemType.READ_ONLY),
                new MetaItem<>(MetaItemType.LABEL, "Status"),
                new MetaItem<>(MetaItemType.STORE_DATA_POINTS, true));

2023-03-31 10:45:04.974 FINE [WebService task-2 ] remote.manager.asset.AssetStorageService : Asset query took 4ms: return count=1
2023-03-31 10:45:04.989 WARN [WebService task-2 ] rnate.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 22P02
2023-03-31 10:45:04.989 ERROR [WebService task-2 ] rnate.engine.jdbc.spi.SqlExceptionHelper : ERROR: invalid input syntax for type boolean: “{“reason”: “sunrise”}”
2023-03-31 10:45:04.989 FINE [WebService task-2 ] container.persistence.PersistenceService : Rolling back failed transaction, cause follows
org.hibernate.exception.DataException: error executing work

same thing happens also if I try JSON_Object.

Any clue @Don @Rich ?

Thanks a lot!

PS:
@cheezymcsquibble would you be so kind to please share with me your JSON attribute declaration in JAVA and the JSON format example?

Thank you!

L.E:
Now I see it’s coming from @martin.peeters work:

public String getSQLQuery(String tableName, Class<?> attributeType) {
    boolean isNumber = Number.class.isAssignableFrom(attributeType);
    if (isNumber) {
        return "select timestamp, value::text::numeric from " + tableName + " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? order by timestamp desc";
    } else {
        **return "select timestamp, (case when VALUE::text::boolean is true then 1 else 0 end) from " + tableName + " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? order by timestamp desc";**
    }
}

From what I see here, it only supports boolean and integers. How did @cheezymcsquibble do it then?

1 Like

Today I pulled the latest version of openremote, and now I have the same issue as you :slightly_frowning_face: the history dropdown freezes and none of the logdata can be read…
image

Hi guys!

I indeed see this issue occuring as well.
As @accabog mentioned, only boolean and number values are supported in the type: all query.
With the introduction of the new downsample algorithms, some of the queries require number values to work. Apparently when requesting all datapoints, I forgot to remove type check.

I’ll directly work on it as it’s quite a breaking bug.
I will add more tests for it as well, to prevent issues in the future with the datapoints.
It will take a few days, but I will let you know when it’s fixed @cheezymcsquibble @accabog :wink:

Thanks for reporting it in a detailed thread, helps a lot! :grin:

1 Like

Hi @martin.peeters, thanks for the fix. At a first glance it appears to be fixed, but there are some issues unfortunately.
I have these 3 attributes with saved data points:


When I select “Controller Mode”, nothing appears:

Controller Mode is an Enum.

When I select “Status”, “Controller Mode” info appears:


And when I select again “Controller Mode”, “Status” values appear (JSON)

So I think you’re almost there but either some index or some caching make it misbehave.

Thanks again for looking into this and fixing it. Hopefully it’ll be just an easy fix.

Best regards!

No problem! I indeed did an update last friday and forgot to send a message here :wink:

When testing we indeed saw some rendering issues with the attribute history.
As you mentioned, it is broken the first time you load it, and after some interaction it is fixed again.
(or at least, most of the times :sweat_smile:)

It is a frontend UI bug only, and shouldn’t be hard to fix.
Have been busy with a lot of different bugs recently, and will add this one to the list haha
Will let you know when I got a fix ready.

1 Like