forked from openhab/openhab-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ItemStateUpdatedEvent and enable group channel-links (openhab#3141)
* Add (Group)ItemStateUpdatedEvent Signed-off-by: Jan N. Klug <[email protected]> GitOrigin-RevId: 4182980
- Loading branch information
Showing
14 changed files
with
374 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...rthouse.core.item/src/main/java/org/openhab/core/items/events/GroupStateUpdatedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) 2010-2023 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.core.items.events; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.core.types.State; | ||
|
||
/** | ||
* {@link GroupStateUpdatedEvent}s can be used to deliver group item state updates through the openHAB event bus. | ||
* In contrast to the {@link GroupItemStateChangedEvent} it is always sent. | ||
* State events must be created with the {@link ItemEventFactory}. | ||
* | ||
* @author Jan N. Klug - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class GroupStateUpdatedEvent extends ItemStateUpdatedEvent { | ||
|
||
/** | ||
* The group item state changed event type. | ||
*/ | ||
public static final String TYPE = GroupStateUpdatedEvent.class.getSimpleName(); | ||
|
||
private final String memberName; | ||
|
||
protected GroupStateUpdatedEvent(String topic, String payload, String itemName, String memberName, | ||
State newItemState, @Nullable String source) { | ||
super(topic, payload, itemName, newItemState, source); | ||
this.memberName = memberName; | ||
} | ||
|
||
/** | ||
* @return the name of the changed group member | ||
*/ | ||
public String getMemberName() { | ||
return this.memberName; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return TYPE; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("Group '%s' updated to %s through %s", itemName, itemState, memberName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...arthouse.core.item/src/main/java/org/openhab/core/items/events/ItemStateUpdatedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) 2010-2023 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.core.items.events; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.core.types.State; | ||
|
||
/** | ||
* {@link ItemStateUpdatedEvent}s can be used to report item status updates through the openHAB event bus. | ||
* State update events must be created with the {@link ItemEventFactory}. | ||
* | ||
* @author Jan N. Klug - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class ItemStateUpdatedEvent extends ItemEvent { | ||
|
||
/** | ||
* The item state event type. | ||
*/ | ||
public static final String TYPE = ItemStateUpdatedEvent.class.getSimpleName(); | ||
|
||
protected final State itemState; | ||
|
||
/** | ||
* Constructs a new item state event. | ||
* | ||
* @param topic the topic | ||
* @param payload the payload | ||
* @param itemName the item name | ||
* @param itemState the item state | ||
* @param source the source, can be null | ||
*/ | ||
protected ItemStateUpdatedEvent(String topic, String payload, String itemName, State itemState, | ||
@Nullable String source) { | ||
super(topic, payload, itemName, source); | ||
this.itemState = itemState; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return TYPE; | ||
} | ||
|
||
/** | ||
* Gets the item state. | ||
* | ||
* @return the item state | ||
*/ | ||
public State getItemState() { | ||
return itemState; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("Item '%s' updated to %s", itemName, itemState); | ||
} | ||
} |
Oops, something went wrong.