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.netatmo.internal.api.data;
15 import java.util.EnumSet;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import com.google.gson.annotations.SerializedName;
23 * This enum describes events generated by webhooks and the type of module they are related to according to
26 * @author Gaƫl L'hopital - Initial contribution
29 public enum EventType {
30 UNKNOWN(ModuleType.UNKNOWN),
32 @SerializedName("topology_changed") // Module configuration changed
33 TOPOLOGY_CHANGED(ModuleType.ACCOUNT),
35 @SerializedName("webhook_activation") // Ack of a 'webhook set' Api Call
36 WEBHOOK_ACTIVATION(ModuleType.ACCOUNT),
38 @SerializedName("person") // When the Indoor Camera detects a face
39 PERSON(ModuleType.PERSON, ModuleType.WELCOME),
41 @SerializedName("person_away") // When geofencing indicates that the person has left the home
42 PERSON_AWAY(ModuleType.PERSON, ModuleType.HOME),
44 @SerializedName("person_home") // When the person is declared at home
45 PERSON_HOME(ModuleType.PERSON, ModuleType.HOME),
47 @SerializedName("outdoor") // When the Outdoor Camera detects a human, a car or an animal
48 OUTDOOR(ModuleType.PRESENCE, ModuleType.DOORBELL),
50 @SerializedName("daily_summary") // When the Outdoor Camera video summary of the last 24 hours is available
51 DAILY_SUMMARY(ModuleType.PRESENCE),
53 @SerializedName("vehicle") // When the Outdoor Camera detects a car
54 VEHICLE(ModuleType.PRESENCE),
56 @SerializedName("movement") // When the Indoor Camera detects motion
57 MOVEMENT(ModuleType.WELCOME),
59 @SerializedName("alarm_started") // When the Indoor Camera triggers alarm
60 ALARM_STARTED(ModuleType.WELCOME),
62 @SerializedName("human") // When the camera detects human motion
63 HUMAN(ModuleType.WELCOME, ModuleType.PRESENCE, ModuleType.DOORBELL),
65 @SerializedName("animal") // When the camera detects animal motion
66 ANIMAL(ModuleType.WELCOME, ModuleType.PRESENCE),
68 @SerializedName("new_module") // A new Module has been paired with the Indoor Camera
69 NEW_MODULE(ModuleType.WELCOME),
71 @SerializedName("module_connect") // Module is connected with the Indoor Camera
72 MODULE_CONNECT(ModuleType.WELCOME),
74 @SerializedName("module_disconnect") // Module lost its connection with the Indoor Camera
75 MODULE_DISCONNECT(ModuleType.WELCOME),
77 @SerializedName("module_low_battery") // Module's battery is low
78 MODULE_LOW_BATTERY(ModuleType.WELCOME),
80 @SerializedName("module_end_update") // Module's firmware update is over
81 MODULE_END_UPDATE(ModuleType.WELCOME),
83 @SerializedName("tag_big_move") // Module's firmware update is over
84 TAG_BIG_MOVE(ModuleType.WELCOME),
86 @SerializedName("tag_open") // Module's firmware update is over
87 TAG_OPEN(ModuleType.WELCOME),
89 @SerializedName("tag_small_move") // Module's firmware update is over
90 TAG_SMALL_MOVE(ModuleType.WELCOME),
92 @SerializedName("connection") // When the camera connects to Netatmo servers
93 CONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
95 @SerializedName("disconnection") // When the camera loses connection with Netatmo servers
96 DISCONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
98 @SerializedName("on") // When Camera Monitoring is resumed
99 ON(ModuleType.WELCOME, ModuleType.PRESENCE),
101 @SerializedName("off") // When Camera Monitoring is turned off
102 OFF(ModuleType.WELCOME, ModuleType.PRESENCE),
104 @SerializedName("boot") // When the Camera is booting
105 BOOT(ModuleType.WELCOME, ModuleType.PRESENCE),
107 @SerializedName("sd") // When Camera SD Card status changes
108 SD(ModuleType.WELCOME, ModuleType.PRESENCE),
110 @SerializedName("alim") // When Camera power supply status changes
111 ALIM(ModuleType.WELCOME, ModuleType.PRESENCE),
113 @SerializedName("siren_tampered") // When the siren has been tampered
114 SIREN_TAMPERED(ModuleType.WELCOME),
116 @SerializedName("accepted_call") // When a call is incoming
117 ACCEPTED_CALL(ModuleType.DOORBELL),
119 @SerializedName("incoming_call") // When a call as been answered by a user
120 INCOMING_CALL(ModuleType.DOORBELL),
122 @SerializedName("rtc") // Button pressed
123 RTC(ModuleType.DOORBELL),
125 @SerializedName("missed_call") // When a call has not been answered by anyone
126 MISSED_CALL(ModuleType.DOORBELL),
128 @SerializedName("hush") // When the smoke detection is activated or deactivated
129 HUSH(ModuleType.SMOKE_DETECTOR),
131 @SerializedName("smoke") // When smoke is detected or smoke is cleared
132 SMOKE(ModuleType.SMOKE_DETECTOR),
134 @SerializedName("tampered") // When smoke detector is ready or tampered
135 TAMPERED(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
137 @SerializedName("wifi_status") // When wifi status is updated
138 WIFI_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
140 @SerializedName("battery_status") // When battery status is too low
141 BATTERY_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
143 @SerializedName("detection_chamber_status") // When the detection chamber is dusty or clean
144 DETECTION_CHAMBER_STATUS(ModuleType.SMOKE_DETECTOR),
146 @SerializedName("sound_test") // Sound test result
147 SOUND_TEST(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
149 @SerializedName("new_device")
150 NEW_DEVICE(ModuleType.HOME),
152 @SerializedName("co_detected")
153 CO_DETECTED(ModuleType.CO_DETECTOR),
155 @SerializedName("alarm_event") // an alarm event arrived on a weather station module
156 ALARM_EVENT(ModuleType.WEATHER_STATION),
158 @SerializedName("entered") // the alarm was raised
159 ALARM_ENTERED(ModuleType.WEATHER_STATION),
161 @SerializedName("exited") // the alarm is stopped
162 ALARM_EXITED(ModuleType.WEATHER_STATION),
164 @SerializedName("display_change") // a manual action has been done on the thermostat
165 DISPLAY_CHANGE(ModuleType.THERMOSTAT),
167 @SerializedName("set_point") // a setpoint has been set
168 SET_POINT(ModuleType.THERMOSTAT),
170 @SerializedName("cancel_set_point") // manual setpoint ended
171 CANCEL_SET_POINT(ModuleType.THERMOSTAT);
173 public static final EnumSet<EventType> AS_SET = EnumSet.allOf(EventType.class);
175 private final Set<ModuleType> appliesTo;
177 EventType(ModuleType... appliesTo) {
178 if (appliesTo.length == 0) {
179 throw new IllegalArgumentException(
180 "Event type must be associated to at least a module type, please file a bug report.");
182 this.appliesTo = Set.of(appliesTo);
186 public String toString() {
187 return name().toLowerCase();
190 public boolean validFor(ModuleType searched) {
191 return appliesTo.contains(searched);
194 public ModuleType getFirstModule() {
195 return appliesTo.iterator().next();