Class Channels
java.lang.Object
org.openhab.core.model.script.lib.Channels
Channels provides DSL access to channel manipulation.- Author:
- Ravi Nadahar - Initial contribution
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemChannelLinkaddItemChannelLink(Item item, String channelUid) static ItemChannelLinkaddItemChannelLink(Item item, String channelUid, Object... configProperties) static ItemChannelLinkaddItemChannelLink(Item item, String channelUid, @Nullable Map<@NonNull String, @Nullable Object> configProperties) static Set<ChannelUID> getBoundChannels(@Nullable String itemName) Get theChannelUIDs of the channels that are bound to the specifiedItem.static @NonNull Set<@NonNull ChannelUID> getBoundChannels(Item item) Get theChannelUIDs of the channels that are bound to the specifiedItem.getBoundThings(@Nullable String itemName) getBoundThings(Item item) static Set<ItemChannelLink> getChannelLinks(@Nullable String channelUid) Get theItemChannelLinks that are linked to the specified channel.static Set<ItemChannelLink> getChannelLinks(@Nullable ChannelUID channelUid) Get theItemChannelLinks that are linked to the specified channel.static @Nullable ItemChannelLinkGet an existingItemChannelLinkfor the specified item and channel.static @Nullable ItemChannelLinkGet an existingItemChannelLinkfor the specified item and channel.static @Nullable ItemChannelLinkgetLink(Item item, ChannelUID channelUid) Get an existingItemChannelLinkfor the specified item and channel.getLinkedItemNames(@Nullable String channelUid) Get the names of all the items that are linked to a specific channel.getLinkedItemNames(ChannelUID channelUid) Get the names of all the items that are linked to a specific channel.getLinkedItems(@Nullable String channelUid) Get allItems that are linked to a specific channel.getLinkedItems(ChannelUID channelUid) Get allItems that are linked to a specific channel.static Set<ItemChannelLink> Get theItemChannelLinks that are linked to the specified item.static Set<ItemChannelLink> Get theItemChannelLinks that are linked to the specified item.static booleanisChannelLinked(@Nullable String channelUid) Check if the specified channel has at least one link.static booleanisChannelLinked(@Nullable ChannelUID channelUid) Check if the specified channel has at least one link.static booleanCheck if the specified item has at least one link.static booleanCheck if the specified item and channel are linked.static booleanCheck if the specified item has at least one link.static booleanCheck if the specified item and channel are linked.static booleanisLinked(@Nullable Item item, @Nullable ChannelUID channelUid) Check if the specified item and channel are linked.static @Nullable ItemChannelLinkremoveItemChannelLink(@Nullable String itemName, @Nullable String channelUid) static @Nullable ItemChannelLinkremoveItemChannelLink(Item item, @Nullable String channelUid) static @Nullable ItemChannelLinkremoveItemChannelLink(Item item, ChannelUID channelUid) static intremoveLinksForItem(@Nullable String itemName) Remove all managed links related to the specified item.static intremoveLinksForItem(@Nullable Item item) Remove all managed links related to the specified item.static intRemove all orphaned (item or channel missing) managed links.static @Nullable ItemChannelLinkreplaceItemChannelLink(Item item, String channelUid) static @Nullable ItemChannelLinkreplaceItemChannelLink(Item item, String channelUid, Object... configProperties) static @Nullable ItemChannelLinkreplaceItemChannelLink(Item item, String channelUid, @Nullable Map<@NonNull String, @Nullable Object> configProperties)
-
Constructor Details
-
Channels
public Channels()
-
-
Method Details
-
getLinks
Get theItemChannelLinks that are linked to the specified item.- Parameters:
itemName- the name of the item.- Returns:
- The
SetofItemChannelLinks.
-
getLinks
Get theItemChannelLinks that are linked to the specified item.- Parameters:
item- theItem.- Returns:
- The
SetofItemChannelLinks.
-
getChannelLinks
Get theItemChannelLinks that are linked to the specified channel.- Parameters:
channelUid- the UID of the channel.- Returns:
- The
SetofItemChannelLinks.
-
getChannelLinks
Get theItemChannelLinks that are linked to the specified channel.- Parameters:
channelUid- theChannelUIDof the channel.- Returns:
- The
SetofItemChannelLinks.
-
getBoundChannels
Get theChannelUIDs of the channels that are bound to the specifiedItem.- Parameters:
itemName- the name of the item.- Returns:
- The
SetofChannelUIDs of the bound channels.
-
getBoundChannels
Get theChannelUIDs of the channels that are bound to the specifiedItem.- Parameters:
item- theItem.- Returns:
- The
SetofChannelUIDs of the bound channels. - Throws:
IllegalArgumentException- Ifitemisnull.
-
getBoundThings
-
getBoundThings
- Parameters:
item- theItem.- Returns:
- The
Setof boundThings. - Throws:
IllegalArgumentException- Ifitemisnull.
-
getLinkedItemNames
Get the names of all the items that are linked to a specific channel.- Parameters:
channelUid- the UID of the channel.- Returns:
- The
Setof names of the linked items.
-
getLinkedItemNames
@NonNullByDefault({}) public static @NonNull Set<@NonNull String> getLinkedItemNames(ChannelUID channelUid) Get the names of all the items that are linked to a specific channel.- Parameters:
channelUid- theChannelUIDof the channel.- Returns:
- The
Setof names of the linked items. - Throws:
IllegalArgumentException- IfchannelUidisnull.
-
getLinkedItems
Get allItems that are linked to a specific channel. -
getLinkedItems
@NonNullByDefault({}) public static @NonNull Set<@NonNull Item> getLinkedItems(ChannelUID channelUid) Get allItems that are linked to a specific channel.- Parameters:
channelUid- theChannelUIDof the channel.- Returns:
- The
Setof linkedItems. - Throws:
IllegalArgumentException- IfchannelUidisnull.
-
isLinked
Check if the specified item has at least one link.- Parameters:
itemName- the name of the item to check.- Returns:
trueif a link exists,falseotherwise.
-
isLinked
Check if the specified item has at least one link.- Parameters:
item- theItemto check.- Returns:
trueif a link exists,falseotherwise.
-
isLinked
Check if the specified item and channel are linked.- Parameters:
itemName- the name of the item to check.channelUid- the UID of the channel to check.- Returns:
trueif a link exists,falseotherwise.
-
isLinked
Check if the specified item and channel are linked.- Parameters:
item- theItemto check.channelUid- the UID of the channel to check.- Returns:
trueif a link exists,falseotherwise.
-
isLinked
Check if the specified item and channel are linked.- Parameters:
item- theItemto check.channelUid- theChannelUIDof the channel to check.- Returns:
trueif a link exists,falseotherwise.
-
isChannelLinked
Check if the specified channel has at least one link.- Parameters:
channelUid- the UID of the channel to check.- Returns:
trueif a link exists,falseotherwise.
-
isChannelLinked
Check if the specified channel has at least one link.- Parameters:
channelUid- theChannelUIDof the channel to check.- Returns:
trueif a link exists,falseotherwise.
-
getLink
@NonNullByDefault({}) public static @Nullable ItemChannelLink getLink(Item item, ChannelUID channelUid) Get an existingItemChannelLinkfor the specified item and channel.- Parameters:
item- theItem.channelUid- theChannelUIDof the channel.- Returns:
- The
ItemChannelLinkornullif none were found. - Throws:
IllegalArgumentException- IfitemorchannelUidisnull.
-
getLink
@NonNullByDefault({}) public static @Nullable ItemChannelLink getLink(Item item, @Nullable String channelUid) Get an existingItemChannelLinkfor the specified item and channel.- Parameters:
item- theItem.channelUid- the UID of the channel.- Returns:
- The
ItemChannelLinkornullif none were found. - Throws:
IllegalArgumentException- Ifitemisnull.
-
getLink
public static @Nullable ItemChannelLink getLink(@Nullable String itemName, @Nullable String channelUid) Get an existingItemChannelLinkfor the specified item and channel.- Parameters:
itemName- the name of the item.channelUid- the UID of the channel.- Returns:
- The
ItemChannelLinkornullif none were found.
-
addItemChannelLink
@NonNullByDefault({}) public static ItemChannelLink addItemChannelLink(Item item, String channelUid) - Parameters:
item- theItemto link.channelUid- the UID of the channel to link.- Returns:
- The newly created
ItemChannelLink. - Throws:
IllegalArgumentException- Ifitemisnull, theItemChannelLinkalready exists, orchannelUidis invalid.IllegalStateException- If aManagedProviderisn't available.
-
addItemChannelLink
public static ItemChannelLink addItemChannelLink(Item item, String channelUid, Object... configProperties) - Parameters:
item- theItemto link.channelUid- the UID of the channel to link.configProperties- the pairs ofStrings andObjects that constitutes the configuration. properties for the link. Must be in pairs, the first is the key, the second is the value.- Returns:
- The newly created
ItemChannelLink. - Throws:
IllegalArgumentException- Ifitemisnull,channelUidis invalid, theItemChannelLinkalready exists, or if there is an odd number ofconfigProperties, or if any of the keys aren'tStrings.IllegalStateException- If aManagedProviderisn't available.
-
addItemChannelLink
@NonNullByDefault({}) public static ItemChannelLink addItemChannelLink(Item item, String channelUid, @Nullable Map<@NonNull String, @Nullable Object> configProperties) - Parameters:
item- theItemto link.channelUid- the UID of the channel to link.configProperties- the map of configuration properties for the link.- Returns:
- The newly created
ItemChannelLink. - Throws:
IllegalArgumentException- Ifitemisnull, theItemChannelLinkalready exists, orchannelUidis invalid.IllegalStateException- If aManagedProviderisn't available.
-
replaceItemChannelLink
@NonNullByDefault({}) public static @Nullable ItemChannelLink replaceItemChannelLink(Item item, String channelUid) - Parameters:
item- theItemto link.channelUid- the UID of the channel to link.- Returns:
- The old
ItemChannelLinkif one existed, ornull. - Throws:
IllegalArgumentException- IfitemisnullorchannelUidis invalid.IllegalStateException- If aManagedProviderisn't available.
-
replaceItemChannelLink
public static @Nullable ItemChannelLink replaceItemChannelLink(Item item, String channelUid, Object... configProperties) - Parameters:
item- theItemto link.channelUid- the UID of the channel to link.configProperties- the pairs ofStrings andObjects that constitutes the configuration. properties for the link. Must be in pairs, the first is the key, the second is the value.- Returns:
- The old
ItemChannelLinkif one existed, ornull. - Throws:
IllegalArgumentException- Ifitemisnull,channelUidis invalid, or if there is an odd number ofconfigProperties, or if any of the keys aren'tStrings.IllegalStateException- If aManagedProviderisn't available.
-
replaceItemChannelLink
@NonNullByDefault({}) public static @Nullable ItemChannelLink replaceItemChannelLink(Item item, String channelUid, @Nullable Map<@NonNull String, @Nullable Object> configProperties) - Parameters:
item- theItemto link.channelUid- the UID of the channel to link.configProperties- the map of configuration properties for the link.- Returns:
- The old
ItemChannelLinkif one existed, ornull. - Throws:
IllegalArgumentException- Ifitemisnull, orchannelUidis invalid.IllegalStateException- If aManagedProviderisn't available.
-
removeItemChannelLink
@NonNullByDefault({}) public static @Nullable ItemChannelLink removeItemChannelLink(Item item, ChannelUID channelUid) - Parameters:
item- theItemof the link to remove.channelUid- the UID of the channel of the link to remove.- Returns:
- The removed
ItemChannelLinkornullif none existed. - Throws:
IllegalArgumentException- IfitemorchannelUidisnull.IllegalStateException- If aManagedProviderisn't available.
-
removeItemChannelLink
@NonNullByDefault({}) public static @Nullable ItemChannelLink removeItemChannelLink(Item item, @Nullable String channelUid) - Parameters:
item- theItemof the link to remove.channelUid- the UID of the channel of the link to remove.- Returns:
- The removed
ItemChannelLinkornullif none existed. - Throws:
IllegalArgumentException- Ifitemisnull.IllegalStateException- If aManagedProviderisn't available.
-
removeItemChannelLink
public static @Nullable ItemChannelLink removeItemChannelLink(@Nullable String itemName, @Nullable String channelUid) - Parameters:
itemName- the name of the item of the link to remove.channelUid- the UID of the channel of the link to remove.- Returns:
- The removed
ItemChannelLinkornullif none existed. - Throws:
IllegalStateException- If aManagedProviderisn't available.
-
removeLinksForItem
Remove all managed links related to the specified item.- Parameters:
itemName- the name of the item.- Returns:
- The number of removed links.
-
removeLinksForItem
Remove all managed links related to the specified item.- Parameters:
item- theItem.- Returns:
- The number of removed links.
-
removeOrphanedItemChannelLinks
public static int removeOrphanedItemChannelLinks()Remove all orphaned (item or channel missing) managed links.- Returns:
- The number of removed links.
-