How to get Item name or attributes in HabPanel

Hi All,

Creating a dashboard in HabPanel. All working fine, but I can only access information regarding the channel using “getItem”. Is it possible to access information about the channels parent item?

For example, lets say I have an Openhab item for controlling a pump. In OH, I name the Item “Hot Water Pump” and a second one “Cold Water Pump”.

A pump has two channels, one for On/Off and another for flow-rate.

In HabPanel, if I want to make a nice dashboard to represent each of the pumps, I would prefer not to duplicate the name of each pump in HabPanel through a configuration item in HabPanel, rather read the name of the channels parent Item and display that instead.

I cant see to find a way to do this? Any ideas or am I going about it wrong?


Sorry, just thought of another aspect also! In the previous example, the HabPanel widget I am creating is one where I want to display both the state of the pump and the flow rate. So, in configuration, I would need to specify two items. However, it would be preferable to only specify one and then dynamically get the details of the sibling channel. Any way to do this?

Thanks again

HABPanel doesn’t know about channels and things, only items. You can get the label of the item in a template with getItem(name).label

Not possible, but if you have some sort of naming convention for your items like Hot_Water_Pump_State, Hot_Water_Pump_Flow you can specify only one of them in the configuration and derive the other with something like <div ng-init="flow_item=config.state_item.replace('_State', '_Flow')">

1 Like

Thanks Yannick.

Unfortunately, the label’s of my items are labelled as “Pump Switch”, so getting the .label for same will not give a meaningful name. That said, I think I can look at changing my binding so that it deliberately names the items in a more expressive way such as “Cold Water | Pump Switch” and then use your second trick to parse and display it etc…

Thanks a Million,

OOps, scratch that. The label for the channel is defined in channels.xml, so cannot change dynamically at startup to have the Items label appended. Hmmm…back to the drawing board!