import com.google.gson.annotations.SerializedName;
/**
- * This enum describes events generated by webhooks and the type of
- * module they are related to according to API documentation
+ * This enum describes events generated by webhooks and the type of module they are related to according to
+ * API documentation
*
* @author Gaël L'hopital - Initial contribution
*/
@NonNullByDefault
public enum EventType {
- UNKNOWN(),
+ UNKNOWN(ModuleType.UNKNOWN),
+
+ @SerializedName("topology_changed") // Module configuration changed
+ TOPOLOGY_CHANGED(ModuleType.ACCOUNT),
+
@SerializedName("webhook_activation") // Ack of a 'webhook set' Api Call
WEBHOOK_ACTIVATION(ModuleType.ACCOUNT),
private final Set<ModuleType> appliesTo;
EventType(ModuleType... appliesTo) {
+ if (appliesTo.length == 0) {
+ throw new IllegalArgumentException(
+ "Event type must be associated to at least a module type, please file a bug report.");
+ }
this.appliesTo = Set.of(appliesTo);
}
: WIFI_SIGNAL_LEVELS;
}
throw new IllegalArgumentException(
- "getSignalLevels should not be called for module type : '%s', please file a bug report."
+ "getSignalLevels should not be called for module type: '%s', please file a bug report."
.formatted(name()));
}
UNKNOWN
}
+ // Topology Changes
+ public enum TopologyChange {
+ @SerializedName("home_owner_added")
+ HOME_OWNER_ADDED,
+ @SerializedName("device_associated_to_user")
+ DEVICE_ASSOCIATED_TO_USER,
+ @SerializedName("device_associated_to_home")
+ DEVICE_ASSOCIATED_TO_HOME,
+ @SerializedName("device_updated")
+ DEVICE_UPDATED,
+ @SerializedName("device_associated_to_room")
+ DEVICE_ASSOCIATED_TO_ROOM,
+ @SerializedName("room_created")
+ ROOM_CREATED,
+ UNKNOWN
+ }
+
private static final Scope[] SMOKE_SCOPES = { Scope.READ_SMOKEDETECTOR };
private static final Scope[] CARBON_MONOXIDE_SCOPES = { Scope.READ_CARBONMONOXIDEDETECTOR };
private static final Scope[] AIR_CARE_SCOPES = { Scope.READ_HOMECOACH };
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.netatmo.internal.api.data.EventType;
+import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.TopologyChange;
import org.openhab.binding.netatmo.internal.deserialization.NAObjectMap;
import org.openhab.binding.netatmo.internal.deserialization.NAPushType;
private String deviceId = "";
private @Nullable String snapshotUrl;
private @Nullable String vignetteUrl;
+ private TopologyChange change = TopologyChange.UNKNOWN;
private NAObjectMap<Person> persons = new NAObjectMap<>();
// Webhook does not provide the event generation time, so we'll use the event reception time
private ZonedDateTime time = ZonedDateTime.now();
collection.add(value);
}
}
+
+ public TopologyChange getChange() {
+ return change;
+ }
}