Page 1 of 1

Changing values with query results?

PostPosted: Thu Dec 31, 2020 1:16 pm
by Ramias
I'm trying to show status for ZWave Locks and Alarm Sensors (doors/windows/garage doors) on the same panel.

The issue is:
Locks show onState of True when locked.
Door sensors show onState of False when the door is closed.

I'd like both of these to map to the same green color on the dashboard. Fortunately locks also have a a value of onOffState.ui which I can use instead of onState so I can map the onOffState.ui Locked of the lock to the same color as onState of False on the door sensors.

But I have a few other edge cases where this could be interesting. Does anybody know if there's a way to do this with Grafana transformations or with a case statement in the SQL query? I'm ok running separate queries for the locks vs the door sensors. I'd like to have both queries query against onState, and then transform one so True/Locked is the same as False/Closed for doors. I've read that grafana can support Case Statements in SQL but not with influxDb.

Thanks

Re: Changing values with query results?

PostPosted: Tue Jan 05, 2021 8:57 am
by vtmikel
I did some brief looking into this, and I haven't found an obvious way. I personally separate the panels. It doesn't look like Grafana's transformations support changing values, only filtering records. Influx queries also do not seem to support it. I'll keep looking but so far nothing.

Re: Changing values with query results?

PostPosted: Tue Jan 05, 2021 4:54 pm
by Colly
Ramias wrote:
I'm trying to show status for ZWave Locks and Alarm Sensors (doors/windows/garage doors) on the same panel.

The issue is:
Locks show onState of True when locked.
Door sensors show onState of False when the door is closed.

Would the Device Extensions plugin work for you and then add the converted state to Grafana?