Interface ScriptBusEvent
@NonNullByDefault
public interface ScriptBusEvent
The static methods of this class are made available as functions in the scripts.
This gives direct write access to the event bus from within scripts.
Items should not be updated directly (setting the state property), but updates should
be sent to the bus, so that all interested bundles are notified.
Note: This class is a copy from the
org.openhab.core.model.script.actions.BusEvent
class- Author:
- Kai Kreuzer - Initial contribution, Jan N. Klug - Refactored to interface
-
Method Summary
Modifier and TypeMethodDescription@Nullable Object
postUpdate
(@Nullable String itemName, @Nullable String stateAsString) Posts a status update for a specified item to the event bus.@Nullable Object
postUpdate
(@Nullable Item item, @Nullable Number state) Posts a status update for a specified item to the event bus.@Nullable Object
postUpdate
(@Nullable Item item, @Nullable String stateAsString) Posts a status update for a specified item to the event bus.@Nullable Object
postUpdate
(@Nullable Item item, @Nullable State state) Posts a status update for a specified item to the event bus.@Nullable Object
restoreStates
(@Nullable Map<Item, State> statesMap) Restores item states from a map.@Nullable Object
sendCommand
(@Nullable String itemName, @Nullable String commandString) Sends a command for a specified item to the event bus.@Nullable Object
sendCommand
(@Nullable Item item, @Nullable Number number) Sends a number as a command for a specified item to the event bus.@Nullable Object
sendCommand
(@Nullable Item item, @Nullable String commandString) Sends a command for a specified item to the event bus.@Nullable Object
sendCommand
(@Nullable Item item, @Nullable Command command) Sends a command for a specified item to the event bus.@Nullable Object
sendTimeSeries
(@Nullable String itemName, @Nullable Map<ZonedDateTime, State> values, String policy) Sends a time series to the event bus@Nullable Object
sendTimeSeries
(@Nullable Item item, @Nullable TimeSeries timeSeries) Sends a time series to the event busstoreStates
(Item @Nullable ... items) Stores the current states for a list of items in a map.
-
Method Details
-
sendCommand
Sends a command for a specified item to the event bus.- Parameters:
item
- the item to send the command tocommandString
- the command to send
-
sendCommand
Sends a number as a command for a specified item to the event bus.- Parameters:
item
- the item to send the command tonumber
- the number to send as a command
-
sendCommand
Sends a command for a specified item to the event bus.- Parameters:
itemName
- the name of the item to send the command tocommandString
- the command to send
-
sendCommand
Sends a command for a specified item to the event bus.- Parameters:
item
- the item to send the command tocommand
- the command to send
-
postUpdate
Posts a status update for a specified item to the event bus.- Parameters:
item
- the item to send the status update forstate
- the new state of the item as a number
-
postUpdate
Posts a status update for a specified item to the event bus.- Parameters:
item
- the item to send the status update forstateAsString
- the new state of the item
-
postUpdate
Posts a status update for a specified item to the event bus.- Parameters:
itemName
- the name of the item to send the status update forstateAsString
- the new state of the item
-
postUpdate
Posts a status update for a specified item to the event bus.- Parameters:
item
- the item to send the status update forstate
- the new state of the item
-
sendTimeSeries
Sends a time series to the event bus- Parameters:
item
- the item to send the time series fortimeSeries
- aTimeSeries
containing policy and values
-
sendTimeSeries
@Nullable Object sendTimeSeries(@Nullable String itemName, @Nullable Map<ZonedDateTime, State> values, String policy) Sends a time series to the event bus- Parameters:
itemName
- the name of the item to send the status update forvalues
- aMap
containing the timeseries, composed of pairs ofZonedDateTime
andState
policy
- eitherADD
orREPLACE
-
storeStates
Stores the current states for a list of items in a map. A group item is not itself put into the map, but instead all its members.- Parameters:
items
- the items for which the state should be stored- Returns:
- the map of items with their states
-
restoreStates
Restores item states from a map. If the saved state can be interpreted as a command, a command is sent for the item (and the physical device can send a status update if occurred). If it is no valid command, the item state is directly updated to the saved value.
-