Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong event subscription in GroupStateTrigger and ItemStateTrigger #3533

Merged
merged 1 commit into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.openhab.core.items.events.ItemAddedEvent;
import org.openhab.core.items.events.ItemRemovedEvent;
import org.openhab.core.items.events.ItemStateChangedEvent;
import org.openhab.core.items.events.ItemStateEvent;
import org.openhab.core.items.events.ItemStateUpdatedEvent;
import org.openhab.core.types.State;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
Expand Down Expand Up @@ -72,7 +72,7 @@ public GroupStateTriggerHandler(Trigger module, String ruleUID, BundleContext bu
this.state = (String) module.getConfiguration().get(CFG_STATE);
this.previousState = (String) module.getConfiguration().get(CFG_PREVIOUS_STATE);
if (UPDATE_MODULE_TYPE_ID.equals(module.getTypeUID())) {
this.types = Set.of(ItemStateEvent.TYPE, ItemAddedEvent.TYPE, ItemRemovedEvent.TYPE);
this.types = Set.of(ItemStateUpdatedEvent.TYPE, ItemAddedEvent.TYPE, ItemRemovedEvent.TYPE);
} else {
this.types = Set.of(ItemStateChangedEvent.TYPE, GroupItemStateChangedEvent.TYPE, ItemAddedEvent.TYPE,
ItemRemovedEvent.TYPE);
Expand Down Expand Up @@ -113,8 +113,8 @@ public void receive(Event event) {
TriggerHandlerCallback cb = (TriggerHandlerCallback) callback;
logger.trace("Received Event: Source: {} Topic: {} Type: {} Payload: {}", event.getSource(),
event.getTopic(), event.getType(), event.getPayload());
if (event instanceof ItemStateEvent && UPDATE_MODULE_TYPE_ID.equals(module.getTypeUID())) {
ItemStateEvent isEvent = (ItemStateEvent) event;
if (event instanceof ItemStateUpdatedEvent && UPDATE_MODULE_TYPE_ID.equals(module.getTypeUID())) {
ItemStateUpdatedEvent isEvent = (ItemStateUpdatedEvent) event;
String itemName = isEvent.getItemName();
Item item = itemRegistry.get(itemName);
if (item != null && item.getGroupNames().contains(groupName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.openhab.core.events.TopicPrefixEventFilter;
import org.openhab.core.items.ItemRegistry;
import org.openhab.core.items.events.GroupItemStateChangedEvent;
import org.openhab.core.items.events.GroupStateUpdatedEvent;
import org.openhab.core.items.events.ItemAddedEvent;
import org.openhab.core.items.events.ItemRemovedEvent;
import org.openhab.core.items.events.ItemStateChangedEvent;
Expand Down Expand Up @@ -77,7 +78,8 @@ public ItemStateTriggerHandler(Trigger module, String ruleUID, BundleContext bun
this.previousState = (String) module.getConfiguration().get(CFG_PREVIOUS_STATE);
this.ruleUID = ruleUID;
if (UPDATE_MODULE_TYPE_ID.equals(module.getTypeUID())) {
this.types = Set.of(ItemStateUpdatedEvent.TYPE, ItemAddedEvent.TYPE, ItemRemovedEvent.TYPE);
this.types = Set.of(ItemStateUpdatedEvent.TYPE, GroupStateUpdatedEvent.TYPE, ItemAddedEvent.TYPE,
ItemRemovedEvent.TYPE);
} else {
this.types = Set.of(ItemStateChangedEvent.TYPE, GroupItemStateChangedEvent.TYPE, ItemAddedEvent.TYPE,
ItemRemovedEvent.TYPE);
Expand Down