2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.innogysmarthome.internal.client.entity.event;
15 import org.openhab.binding.innogysmarthome.internal.client.entity.capability.Capability;
16 import org.openhab.binding.innogysmarthome.internal.client.entity.device.Device;
17 import org.openhab.binding.innogysmarthome.internal.client.entity.link.Link;
18 import org.openhab.binding.innogysmarthome.internal.client.entity.message.Message;
21 * Defines the {@link Event}, which is sent by the innogy websocket to inform the clients about changes.
23 * @author Oliver Kuhl - Initial contribution
25 public class MessageEvent extends BaseEvent {
27 public static final String EVENT_PROPERTY_CONFIGURATION_VERSION = "ConfigurationVersion";
28 public static final String EVENT_PROPERTY_IS_CONNECTED = "IsConnected";
31 * Reference to the associated entity (instance or metadata) for the given event. Always available.
33 private String source;
36 * The product (context) that generated the event.
38 private String namespace;
41 * Data for the event, The data container can contain any type of entity dependent on the event type. For example,
42 * the DeviceFound events contains the entire Device entity rather than selected properties.
48 * @return the link to the source
50 public String getSource() {
55 * @param source the link to the source to set
57 public void setSource(String source) {
62 * @return the namespace
64 public String getNamespace() {
69 * @param namespace the namespace to set
71 public void setNamespace(String namespace) {
72 this.namespace = namespace;
76 * @return the dataList
78 public Message getData() {
83 * @param message the message to set
85 public void setData(Message data) {
89 public Message getMessage() {
94 * Returns the id of the link or null, if there is no link or the link does not have an id.
96 * @return String the id of the link or null
98 public String getSourceId() {
99 final String linkType = getSourceLinkType();
100 if (linkType != null && !Link.LINK_TYPE_UNKNOWN.equals(linkType) && !Link.LINK_TYPE_SHC.equals(linkType)) {
101 if (source != null) {
102 return source.replace(linkType, "");
109 * Returns the Type of the {@link Link} in the {@link Event}.
113 public String getSourceLinkType() {
114 if (source != null) {
115 return Link.getLinkType(source);
121 * Returns true, if the {@link Link} points to a {@link Capability}.
125 public Boolean isLinkedtoCapability() {
126 return source == null ? false : Link.isTypeCapability(source);
130 * Returns true, if the {@link Link} points to a {@link Device}.
134 public Boolean isLinkedtoDevice() {
135 return source == null ? false : Link.isTypeDevice(source);
139 * Returns true, if the {@link Link} points to a {@link Message}.
143 public Boolean isLinkedtoMessage() {
144 return source == null ? false : Link.isTypeMessage(source);
148 * Returns true, if the {@link Link} points to the SHC {@link Device}.
152 public Boolean isLinkedtoSHC() {
153 return source == null ? false : Link.isTypeSHC(source);