Open ssvenn opened 7 years ago
Hello @ssvenn, I like the goal you are chasing and the ability to select $2
seems nice indeed. Because of existing setups I would however prefer to have this transformation step as a enable/disable option.
One more thing: The reason for "wontfix" in the referenced issue was special and not directly related to the pure idea to allow underscores. Would you consider creating yet another issue to discuss the implementation inside grafana?
Related to the idea described here I want to discuss another approach, which could be implemented instead or additionally. It was first mentioned at: https://community.openhab.org/t/influxdb-grafana-persistence-and-graphing/13761/155?u=thomdietrich
As can be seen here http://docs.grafana.org/datasources/influxdb/#alias-patterns Grafana allows other placeholders to be used in the alias field which are stored in your influxdb, e.g. tag_hostname
Currently there is no additional data stored but the influxdb persistence service might be easily able to do so. I want to suggest, to store the item label inside a tag, for example tag_label
or tag_alias
.
@theoweiss what do you think`?
I don't know know if there is a way to get the item label from an item or using an item object. An item object has no getLabel or something like that: https://github.com/openhab/openhab/blob/master/bundles/persistence/org.openhab.persistence.influxdb/src/main/java/org/openhab/persistence/influxdb/internal/InfluxDBPersistenceService.java#L214
As you can see the store method has a second parameter named alias, may this can be used. It seems the alias can be set in the persistence configuration. I've no clue how this could be done.
Furthermore unfortunately I have to admit that I've really no time in the next two or three weeks to get into these things. Your welcome to ping me again after the b5 release :-(.
I do neither, maybe @kaikreuzer can help out here. (short: is it possible to pass the item label along to a persistence service?)
As you can see the store method has a second parameter named alias, may this can be used. It seems the alias can be set in the persistence configuration. I've no clue how this could be done.
Correct, the alias is the "persistence service specific label". It is provided as shown in the "Items" section at https://github.com/openhab/openhab/wiki/Persistence#configuration, e.g.
Items {
my_item -> "My Item" : strategy = everyChange
...
}
Thanks Kai. For this idea to work we would need the item label. Defining yet another string is what can already be done inside Grafana. We are looking to use the item label instead of the item identifier as the visual representation in Grafana. Hence I would be interested in a hint in regards to:
I don't know if there is a way to get the item label from an item or using an item object. An item object has no getLabel or something like that
Well, what shall I say: In ESH, the Item has a getLabel()
method; but in OH1, this isn't available.
So you might want to consider a new persistence service for ESH. If you expect it to "going to become popular with users", this might be an option to consider in any case.
Fair point indeed. @theoweiss I got your time concerns above. Are you planing to transition this service any time soon? Would you prefer for somebody else to take up this task? Community user opus seemed interested to get involved... Can you estimate the difficulty?
I was hoping to keep the change request as simple as possible with just an extra option in the .cfg file for the influxdb persistence service, pushing OH labels to influxdb would maybe cause some new challenges if the label is using variables that causes the label text to change with every update. I'm an influxdb newbie so I'm not sure if it would track the label history or if it's just stored once for a series.
Dynamic labels could maybe be used for graph annotations though? That would be another interesting use case, having the text of string items that track various states overlaid on a numerical graph!
Anyway, my current influxdb persist rule is simply this:
Items {
* : strategy = everyUpdate
}
and I would love to keep it that way, to have everything configured with as little effort as possible, hopefully that is a noble "user friendliness" goal and not just me being lazy :)
Are you planing to transition this service any time soon?
Not yet.
Can you estimate the difficulty?
Nope. @kaikreuzer can you point me to the right direction (docs / examples) how to create an ESH persistence service?
Would you prefer for somebody else to take up this task?
That would be great. I've never meant to be the owner of this piece of code, it's open source and owned by the community. I've just felt responsible to keep it running. Stand in and make PR's like others have done it in the past (e.g. @sumnerboy12 )! But since you have asked me it would be good if you ping me as soon as someone is working on it.
@kaikreuzer can you point me to the right direction (docs / examples) how to create an ESH persistence service?
Fairly similar as for openHAB1. There is no tutorial/docs on this yet, but a first PR with such an persistence service: https://github.com/eclipse/smarthome/pull/2081
I don't know anything about influxdb+grafana, so I am not sure about the licenses of dependencies and the from what you say the contribution record sounds a bit fuzzy - so it might not be easy to get it to the ESH project itself, the openHAB2-addons repo might be the easier destination. I just want to mention this before anybody takes this step.
Thinking about what you want to achieve, I came across another thought: Your persistence service could depend on ItemUIRegistry, which offers a method getLabel(String itemName)
, which could be used to retrieve the default label of an item, even in openHAB 1. You should note that a persistence service is not meant to have a dependency on UI-related services, but for your case here, it might be an acceptable workaround (while an ESH-port would definitely be the cleaner way, but leaving OH1 out of the game).
So, 2,5 years later :-)
After using influxdb for a while I wanted to make the next step and combine many items in one measurement. This will make many things easier. So I added to the influxdb binding that when you specify an "alias" in the persistence file like @kaikreuzer said, a tag is added to the point whith the real name of the item as tag value. With this you can give many items the same alias, resulting their data to be written in the same measurement, but grouped by tag to different series. Works great in my setup for more than a month :-)
Reading this topic I also implemented the underscore replacement, as this is a nice feature.
The question is, should I do a PR with these changes? As I have understand correctly, there were plans to build a completely new binding for influxdb? Is openhab1-addons still the right place for this binding?
Thanks Dominik
The question is, should I do a PR with these changes?
You could, but it'd probably be better to wait for persistence to be moved to the new OH3ish platform.
https://community.openhab.org/t/influxdb-grafana-persistence-and-graphing/13761 is a great tutorial and I think influxdb+grafana is going to become popular with users, but unfortunately the Item name restriction of Openhab (letters,numbers and underscore only) clashes with the preferred . field separator in Grafana.
If the influxdb persistence plugin for OH could translate _ as . when pushing data it would enable you to use the alias functions in Grafana so that you could have nice, short descriptions in the legend instead of the full item name for everything.
There was a feature request for this in the Grafana project last year but it got closed as wontfix: https://github.com/grafana/grafana/issues/1616
It might be easier to work around the issue in the OH binding instead with a configurable option.
I've tried modifying the sine.py sine wave test script from the tutorial to send "test.sine.wave" as the item name and that allows you to display "test" "sine" or "wave" in the legend with $0, $1 and $2 in the alias field.
http://i.imgur.com/KpgEzrV.png is an example of how the legends look now with autocreated item names from OH2. With aliasing you could build graphs with more readable legends by using the $0-9 field alias. It might also make it possible to build templates for openhab and make it much easier to group several items into the same graph with long descriptive names.
![underscore](https://cloud.githubusercontent.com/assets/3955103/20649160/ad0280a2-b4b8-11e6-83b3-9523934f9b9b.png)