Package org.openhab.core.thing
Interface Thing
- All Superinterfaces:
Identifiable<ThingUID>
- All Known Subinterfaces:
Bridge
A
Thing
is a representation of a connected part (e.g. physical device or cloud service) from the real world.
It contains a list of Channel
s, which can be bound to Item
s.
- Author:
- Dennis Nobel - Initial contribution, Thomas Höfer - Added thing and thing type properties, Simon Kaufmann - Added label, location, Kai Kreuzer - Removed linked items from Thing, Yordan Zhelev - Added method for getting the enabled status, Christoph Weitkamp - Added method
getChannel(ChannelUID)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
the key for the firmware version propertystatic final String
the key for the hardware version propertystatic final String
the key for the MAC address propertystatic final String
the key for the model ID propertystatic final String
the key for the serial number propertystatic final String
the key for the vendor property -
Method Summary
Modifier and TypeMethodDescription@Nullable ThingUID
Gets the bridge UID.@Nullable Channel
getChannel
(String channelId) Gets the channel for the given id or null if no channel with the id exists.@Nullable Channel
getChannel
(ChannelUID channelUID) Gets the channel for the given UID or null if no channel with the UID exists.Gets the channels.getChannelsOfGroup
(String channelGroupId) Gets the channels of the given channel group or an empty list if no channel group with the id exists or the channel group does not have channels.Gets the configuration.@Nullable ThingHandler
Gets the handler.@Nullable String
getLabel()
Returns the human readable label for this thing.@Nullable String
Get the physical location of theThing
.Returns an immutable copy of theThing
properties.Gets the status of a thing.Gets the status info of a thing.Gets the thing type UID.getUID()
Gets the uid.boolean
Returns information whether theThing
is enabled or not.void
setBridgeUID
(@Nullable ThingUID bridgeUID) Sets the bridge.void
setHandler
(@Nullable ThingHandler thingHandler) Sets the handler.void
Sets the human readable label for this thing.void
setLocation
(@Nullable String location) Set the physical location of theThing
.void
setProperties
(Map<String, String> properties) Updates all properties of the thing.@Nullable String
setProperty
(String name, @Nullable String value) Sets the property value for the property identified by the given name.void
setStatusInfo
(ThingStatusInfo status) Sets the status info.
-
Field Details
-
PROPERTY_VENDOR
the key for the vendor property- See Also:
-
PROPERTY_MODEL_ID
the key for the model ID property- See Also:
-
PROPERTY_SERIAL_NUMBER
the key for the serial number property- See Also:
-
PROPERTY_HARDWARE_VERSION
the key for the hardware version property- See Also:
-
PROPERTY_FIRMWARE_VERSION
the key for the firmware version property- See Also:
-
PROPERTY_MAC_ADDRESS
the key for the MAC address property- See Also:
-
-
Method Details
-
getLabel
@Nullable String getLabel()Returns the human readable label for this thing.- Returns:
- the human readable label
-
setLabel
Sets the human readable label for this thing.- Parameters:
label
- the human readable label
-
getChannels
Gets the channels.- Returns:
- the channels
-
getChannelsOfGroup
Gets the channels of the given channel group or an empty list if no channel group with the id exists or the channel group does not have channels.- Returns:
- the channels of the given channel group
-
getChannel
Gets the channel for the given id or null if no channel with the id exists.- Parameters:
channelId
- channel ID- Returns:
- the channel for the given id or null if no channel with the id exists
-
getChannel
Gets the channel for the given UID or null if no channel with the UID exists.- Parameters:
channelUID
- channel UID- Returns:
- the channel for the given UID or null if no channel with the UID exists
-
getStatus
ThingStatus getStatus()Gets the status of a thing. In order to get all status information (status, status detail and status description) please usegetStatusInfo()
.- Returns:
- the status
-
getStatusInfo
ThingStatusInfo getStatusInfo()Gets the status info of a thing. The status info consists of the status itself, the status detail and a status description.- Returns:
- the status info
-
setStatusInfo
Sets the status info.- Parameters:
status
- the new status info
-
setHandler
Sets the handler.- Parameters:
thingHandler
- the new handler
-
getHandler
@Nullable ThingHandler getHandler()Gets the handler.- Returns:
- the handler (can be null)
-
getBridgeUID
@Nullable ThingUID getBridgeUID()Gets the bridge UID.- Returns:
- the bridge UID (can be null)
-
setBridgeUID
Sets the bridge.- Parameters:
bridgeUID
- the new bridge UID
-
getConfiguration
Configuration getConfiguration()Gets the configuration.- Returns:
- the configuration (not null)
-
getUID
ThingUID getUID()Gets the uid.- Specified by:
getUID
in interfaceIdentifiable<ThingUID>
- Returns:
- the uid
-
getThingTypeUID
ThingTypeUID getThingTypeUID()Gets the thing type UID.- Returns:
- the thing type UID
-
getProperties
Returns an immutable copy of theThing
properties.- Returns:
- an immutable copy of the
Thing
properties (not null)
-
setProperty
Sets the property value for the property identified by the given name. If the value to be set is null then the property will be removed.- Parameters:
name
- the name of the property to be set (must not be null or empty)value
- the value of the property (if null then the property with the given name is removed)- Returns:
- the previous value associated with the name, or null if there was no mapping for the name
-
setProperties
Updates all properties of the thing.- Parameters:
properties
- the properties to set (must not be null)
-
getLocation
@Nullable String getLocation()Get the physical location of theThing
.- Returns:
- the location identifier (presumably an item name) or
null
if no location has been configured.
-
setLocation
Set the physical location of theThing
.- Parameters:
location
- the location identifier (preferably an item name) ornull
if no location has been configured.
-
isEnabled
boolean isEnabled()Returns information whether theThing
is enabled or not.- Returns:
- Returns
true
if the thing is enabled. Returnfalse
otherwise.
-