DerOetzi
(Der Oetzi)
January 7, 2020, 5:28pm
1
Is there an easy way to access the location information of an item within NGRE python, which I already set for habot in my configuration:
I have configured my location groups and items following the HABot Walkthrough in this community forum and using the python with Helper Libraries:
https://openhab-scripters.github.io/openhab-helper-libraries/index.html
rlkoshak
(Rich Koshak)
January 7, 2020, 5:56pm
2
Location is defined using a Group. A Group, whether it is being used by HABot or for some other purpose is the same. It’s just a Group.
First you must get your Item:
myItem = ir.getItem("My_Item")
Then get the list of Groups it belongs to and see if it’s a member of the Group that represents the location.
myItem.getGroupNames.contains("Kitchen")
DerOetzi
(Der Oetzi)
January 7, 2020, 6:51pm
3
Thanks for your reply. But isn’t it possible to automatically check whether the Group is a room and although the hierachy above whether there is Floor Group above and so on?
rlkoshak
(Rich Koshak)
January 7, 2020, 6:59pm
4
Automatically? No. But you can get what Group an Item is a member of and you can get what Items are members of a given Group.
See https://openhab-scripters.github.io/openhab-helper-libraries/Guides/But%20How%20Do%20I.html#groups
There is absolutely nothing special about the Groups that HABot uses. They are just regular plain old Groups.
DerOetzi
(Der Oetzi)
January 7, 2020, 7:09pm
5
But the groups that HABot uses are tagged? So I can parse that groups on rules init and later check whether items inside this lists. I will try this.
Thanks again