Package org.openhab.core.items.events
Class ItemEventFactory
java.lang.Object
org.openhab.core.events.AbstractEventFactory
org.openhab.core.items.events.ItemEventFactory
- All Implemented Interfaces:
EventFactory
An
ItemEventFactory is responsible for creating item event instances, e.g. ItemCommandEvents and
ItemStateEvents.- Author:
- Stefan Bußweiler - Initial contribution
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openhab.core.events.AbstractEventFactory
AbstractEventFactory.ZonedDateTimeAdapter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemAddedEventcreateAddedEvent(Item item) Creates an item added event.static ItemCommandEventcreateCommandEvent(String itemName, Command command) Creates an item command event.static ItemCommandEventcreateCommandEvent(String itemName, Command command, @Nullable String source) Creates an item command event.protected EventcreateEventByType(String eventType, String topic, String payload, @Nullable String source) Create a new event instance based on the event type.static GroupItemStateChangedEventcreateGroupStateChangedEvent(String itemName, String memberName, State newState, State oldState, @Nullable ZonedDateTime lastStateUpdate, @Nullable ZonedDateTime lastStateChange) Creates a group item state changed event.static GroupStateUpdatedEventcreateGroupStateUpdatedEvent(String groupName, String member, State state, @Nullable ZonedDateTime lastStateUpdate, @Nullable String source) Creates a group item state updated event.static ItemRemovedEventcreateRemovedEvent(Item item) Creates an item removed event.static ItemStateChangedEventcreateStateChangedEvent(String itemName, State newState, State oldState, @Nullable ZonedDateTime lastStateUpdate, @Nullable ZonedDateTime lastStateChange) Creates an item state changed event.static ItemStateChangedEventcreateStateChangedEvent(String itemName, State newState, State oldState, @Nullable ZonedDateTime lastStateUpdate, @Nullable ZonedDateTime lastStateChange, @Nullable String source) Creates an item state changed event.static ItemEventcreateStateEvent(String itemName, State state) Creates an item state event.static ItemStateEventcreateStateEvent(String itemName, State state, @Nullable String source) Creates an item state event.static ItemStatePredictedEventcreateStatePredictedEvent(String itemName, State state, boolean isConfirmation) Creates an item state predicted event.static ItemStateUpdatedEventcreateStateUpdatedEvent(String itemName, State state, @Nullable ZonedDateTime lastStateUpdate) Creates an item state updated event.static ItemStateUpdatedEventcreateStateUpdatedEvent(String itemName, State state, @Nullable ZonedDateTime lastStateUpdate, @Nullable String source) Creates an item state updated event.static ItemTimeSeriesEventcreateTimeSeriesEvent(String itemName, TimeSeries timeSeries, @Nullable String source) static ItemTimeSeriesUpdatedEventcreateTimeSeriesUpdatedEvent(String itemName, TimeSeries timeSeries, @Nullable String source) static ItemUpdatedEventcreateUpdateEvent(Item item, Item oldItem) Creates an item updated event.Methods inherited from class org.openhab.core.events.AbstractEventFactory
checkNotNull, checkNotNullOrEmpty, createEvent, deserializePayload, getSupportedEventTypes, getTopicElements, serializePayload
-
Constructor Details
-
ItemEventFactory
public ItemEventFactory()Constructs a new ItemEventFactory.
-
-
Method Details
-
createEventByType
protected Event createEventByType(String eventType, String topic, String payload, @Nullable String source) throws Exception Description copied from class:AbstractEventFactoryCreate a new event instance based on the event type.- Specified by:
createEventByTypein classAbstractEventFactory- Parameters:
eventType- the event typetopic- the topicpayload- the payloadsource- the source, can be null- Returns:
- the created event instance
- Throws:
Exception- if the creation of the event fails
-
createCommandEvent
public static ItemCommandEvent createCommandEvent(String itemName, Command command, @Nullable String source) Creates an item command event.- Parameters:
itemName- the name of the item to send the command forcommand- the command to sendsource- the name of the source identifying the sender (can be null)- Returns:
- the created item command event
- Throws:
IllegalArgumentException- if itemName or command is null
-
createCommandEvent
Creates an item command event.- Parameters:
itemName- the name of the item to send the command forcommand- the command to send- Returns:
- the created item command event
- Throws:
IllegalArgumentException- if itemName or command is null
-
createStateEvent
public static ItemStateEvent createStateEvent(String itemName, State state, @Nullable String source) Creates an item state event.- Parameters:
itemName- the name of the item to send the state update forstate- the new state to sendsource- the name of the source identifying the sender (can be null)- Returns:
- the created item state event
- Throws:
IllegalArgumentException- if itemName or state is null
-
createStateEvent
Creates an item state event.- Parameters:
itemName- the name of the item to send the state update forstate- the new state to send- Returns:
- the created item state event
- Throws:
IllegalArgumentException- if itemName or state is null
-
createStateUpdatedEvent
public static ItemStateUpdatedEvent createStateUpdatedEvent(String itemName, State state, @Nullable ZonedDateTime lastStateUpdate) Creates an item state updated event.- Parameters:
itemName- the name of the item to report the state update forstate- the new statelastStateUpdate- the time of the last state update- Returns:
- the created item state update event
- Throws:
IllegalArgumentException- if itemName or state is null
-
createStateUpdatedEvent
public static ItemStateUpdatedEvent createStateUpdatedEvent(String itemName, State state, @Nullable ZonedDateTime lastStateUpdate, @Nullable String source) Creates an item state updated event.- Parameters:
itemName- the name of the item to report the state update forstate- the new statelastStateUpdate- the time of the last state updatesource- the name of the source identifying the sender (can be null)- Returns:
- the created item state update event
- Throws:
IllegalArgumentException- if itemName or state is null
-
createTimeSeriesEvent
public static ItemTimeSeriesEvent createTimeSeriesEvent(String itemName, TimeSeries timeSeries, @Nullable String source) -
createTimeSeriesUpdatedEvent
public static ItemTimeSeriesUpdatedEvent createTimeSeriesUpdatedEvent(String itemName, TimeSeries timeSeries, @Nullable String source) -
createGroupStateUpdatedEvent
public static GroupStateUpdatedEvent createGroupStateUpdatedEvent(String groupName, String member, State state, @Nullable ZonedDateTime lastStateUpdate, @Nullable String source) Creates a group item state updated event.- Parameters:
groupName- the name of the group to report the state update formember- the name of the item that updated the group statestate- the new statelastStateUpdate- the time of the last state updatesource- the name of the source identifying the sender (can be null)- Returns:
- the created group item state update event
- Throws:
IllegalArgumentException- if groupName or state is null
-
createStatePredictedEvent
public static ItemStatePredictedEvent createStatePredictedEvent(String itemName, State state, boolean isConfirmation) Creates an item state predicted event.- Parameters:
itemName- the name of the item to send the state update forstate- the predicted state to sendisConfirmation- whether this is a confirmation of a previous state- Returns:
- the created item state predicted event
- Throws:
IllegalArgumentException- if itemName or state is null
-
createStateChangedEvent
public static ItemStateChangedEvent createStateChangedEvent(String itemName, State newState, State oldState, @Nullable ZonedDateTime lastStateUpdate, @Nullable ZonedDateTime lastStateChange, @Nullable String source) Creates an item state changed event.- Parameters:
itemName- the name of the item to send the state changed event fornewState- the new state to sendoldState- the old state of the itemlastStateChange- the time of the last state changesource- the name of the source identifying the sender (can be null)- Returns:
- the created item state changed event
- Throws:
IllegalArgumentException- if itemName or state is null
-
createStateChangedEvent
public static ItemStateChangedEvent createStateChangedEvent(String itemName, State newState, State oldState, @Nullable ZonedDateTime lastStateUpdate, @Nullable ZonedDateTime lastStateChange) Creates an item state changed event.- Parameters:
itemName- the name of the item to send the state changed event fornewState- the new state to sendoldState- the old state of the itemlastStateChange- the time of the last state change- Returns:
- the created item state changed event
- Throws:
IllegalArgumentException- if itemName or state is null
-
createGroupStateChangedEvent
public static GroupItemStateChangedEvent createGroupStateChangedEvent(String itemName, String memberName, State newState, State oldState, @Nullable ZonedDateTime lastStateUpdate, @Nullable ZonedDateTime lastStateChange) Creates a group item state changed event.- Parameters:
itemName- the name of the group item to send the state changed event formemberName- the name of the member causing the group item state changenewState- the new state to sendoldState- the old state of the group itemlastStateUpdate- the time of the last state updatelastStateChange- the time of the last state change- Returns:
- the created group item state changed event
- Throws:
IllegalArgumentException- if itemName or state is null
-
createAddedEvent
Creates an item added event.- Parameters:
item- the item- Returns:
- the created item added event
- Throws:
IllegalArgumentException- if item is null
-
createRemovedEvent
Creates an item removed event.- Parameters:
item- the item- Returns:
- the created item removed event
- Throws:
IllegalArgumentException- if item is null
-
createUpdateEvent
Creates an item updated event.- Parameters:
item- the itemoldItem- the old item- Returns:
- the created item updated event
- Throws:
IllegalArgumentException- if item or oldItem is null
-