and wanting to get the label of the channel automations#14214. Ideally I would find this channel through a linked item. When having access to the label, I could avoid hardcoding the local time “06:25” in my rules for switching between fixed time and sunrise, whichever comes last - described here: Automating Hunter Douglas PowerView automations
There is no easy way to get to the Channel through the Item. The Link between them is not a part of the Item nor is it part of the Channel. It’s a separate entity and there is no API exposed in rules to access them. You’ll need to use the REST API to query for all of the Links and find the ones (an Item can be a part of multiple Links) that involve that Item and from there you can get the Channel ID. You’ll still need to get the Thing and pull the Channel from the Thing.
Note, what you will get back from the above is a Java List<Channel> so you will have to use Java “stuff” to access and manipulate the list, not JavaScript.
const timeRegex = /\b\d{2}:\d{2}\b/;
var channel = things.getThing("hdpowerview:hub:hub").rawThing.getChannel("automations#14214");
var match = channel.getLabel().match(timeRegex);
if (match) {
var localTime = time.LocalTime.parse(match[0]);
console.log("Time of day found: " + localTime);
} else {
console.log("Time of day not found in label");
}