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
24 * module they are related to according to API documentation
26 * @author Gaƫl L'hopital - Initial contribution
29 public enum EventType {
31 @SerializedName("webhook_activation") // Ack of a 'webhook set' Api Call
32 WEBHOOK_ACTIVATION(ModuleType.ACCOUNT),
34 @SerializedName("person") // When the Indoor Camera detects a face
35 PERSON(ModuleType.PERSON, ModuleType.WELCOME),
37 @SerializedName("person_away") // When geofencing indicates that the person has left the home
38 PERSON_AWAY(ModuleType.PERSON, ModuleType.HOME),
40 @SerializedName("person_home") // When the person is declared at home
41 PERSON_HOME(ModuleType.PERSON, ModuleType.HOME),
43 @SerializedName("outdoor") // When the Outdoor Camera detects a human, a car or an animal
44 OUTDOOR(ModuleType.PRESENCE, ModuleType.DOORBELL),
46 @SerializedName("daily_summary") // When the Outdoor Camera video summary of the last 24 hours is available
47 DAILY_SUMMARY(ModuleType.PRESENCE),
49 @SerializedName("vehicle") // When the Outdoor Camera detects a car
50 VEHICLE(ModuleType.PRESENCE),
52 @SerializedName("movement") // When the Indoor Camera detects motion
53 MOVEMENT(ModuleType.WELCOME),
55 @SerializedName("alarm_started") // When the Indoor Camera triggers alarm
56 ALARM_STARTED(ModuleType.WELCOME),
58 @SerializedName("human") // When the camera detects human motion
59 HUMAN(ModuleType.WELCOME, ModuleType.PRESENCE, ModuleType.DOORBELL),
61 @SerializedName("animal") // When the camera detects animal motion
62 ANIMAL(ModuleType.WELCOME, ModuleType.PRESENCE),
64 @SerializedName("new_module") // A new Module has been paired with the Indoor Camera
65 NEW_MODULE(ModuleType.WELCOME),
67 @SerializedName("module_connect") // Module is connected with the Indoor Camera
68 MODULE_CONNECT(ModuleType.WELCOME),
70 @SerializedName("module_disconnect") // Module lost its connection with the Indoor Camera
71 MODULE_DISCONNECT(ModuleType.WELCOME),
73 @SerializedName("module_low_battery") // Module's battery is low
74 MODULE_LOW_BATTERY(ModuleType.WELCOME),
76 @SerializedName("module_end_update") // Module's firmware update is over
77 MODULE_END_UPDATE(ModuleType.WELCOME),
79 @SerializedName("tag_big_move") // Module's firmware update is over
80 TAG_BIG_MOVE(ModuleType.WELCOME),
82 @SerializedName("tag_open") // Module's firmware update is over
83 TAG_OPEN(ModuleType.WELCOME),
85 @SerializedName("tag_small_move") // Module's firmware update is over
86 TAG_SMALL_MOVE(ModuleType.WELCOME),
88 @SerializedName("connection") // When the camera connects to Netatmo servers
89 CONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
91 @SerializedName("disconnection") // When the camera loses connection with Netatmo servers
92 DISCONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
94 @SerializedName("on") // When Camera Monitoring is resumed
95 ON(ModuleType.WELCOME, ModuleType.PRESENCE),
97 @SerializedName("off") // When Camera Monitoring is turned off
98 OFF(ModuleType.WELCOME, ModuleType.PRESENCE),
100 @SerializedName("boot") // When the Camera is booting
101 BOOT(ModuleType.WELCOME, ModuleType.PRESENCE),
103 @SerializedName("sd") // When Camera SD Card status changes
104 SD(ModuleType.WELCOME, ModuleType.PRESENCE),
106 @SerializedName("alim") // When Camera power supply status changes
107 ALIM(ModuleType.WELCOME, ModuleType.PRESENCE),
109 @SerializedName("siren_tampered") // When the siren has been tampered
110 SIREN_TAMPERED(ModuleType.WELCOME),
112 @SerializedName("accepted_call") // When a call is incoming
113 ACCEPTED_CALL(ModuleType.DOORBELL),
115 @SerializedName("incoming_call") // When a call as been answered by a user
116 INCOMING_CALL(ModuleType.DOORBELL),
118 @SerializedName("rtc") // Button pressed
119 RTC(ModuleType.DOORBELL),
121 @SerializedName("missed_call") // When a call has not been answered by anyone
122 MISSED_CALL(ModuleType.DOORBELL),
124 @SerializedName("hush") // When the smoke detection is activated or deactivated
125 HUSH(ModuleType.SMOKE_DETECTOR),
127 @SerializedName("smoke") // When smoke is detected or smoke is cleared
128 SMOKE(ModuleType.SMOKE_DETECTOR),
130 @SerializedName("tampered") // When smoke detector is ready or tampered
131 TAMPERED(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
133 @SerializedName("wifi_status") // When wifi status is updated
134 WIFI_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
136 @SerializedName("battery_status") // When battery status is too low
137 BATTERY_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
139 @SerializedName("detection_chamber_status") // When the detection chamber is dusty or clean
140 DETECTION_CHAMBER_STATUS(ModuleType.SMOKE_DETECTOR),
142 @SerializedName("sound_test") // Sound test result
143 SOUND_TEST(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
145 @SerializedName("new_device")
146 NEW_DEVICE(ModuleType.HOME),
148 @SerializedName("co_detected")
149 CO_DETECTED(ModuleType.CO_DETECTOR),
151 @SerializedName("alarm_event") // an alarm event arrived on a weather station module
152 ALARM_EVENT(ModuleType.WEATHER_STATION),
154 @SerializedName("entered") // the alarm was raised
155 ALARM_ENTERED(ModuleType.WEATHER_STATION),
157 @SerializedName("exited") // the alarm is stopped
158 ALARM_EXITED(ModuleType.WEATHER_STATION),
160 @SerializedName("display_change") // a manual action has been done on the thermostat
161 DISPLAY_CHANGE(ModuleType.THERMOSTAT),
163 @SerializedName("set_point") // a setpoint has been set
164 SET_POINT(ModuleType.THERMOSTAT),
166 @SerializedName("cancel_set_point") // manual setpoint ended
167 CANCEL_SET_POINT(ModuleType.THERMOSTAT);
169 public static final EnumSet<EventType> AS_SET = EnumSet.allOf(EventType.class);
171 private final Set<ModuleType> appliesTo;
173 EventType(ModuleType... appliesTo) {
174 this.appliesTo = Set.of(appliesTo);
178 public String toString() {
179 return name().toLowerCase();
182 public boolean validFor(ModuleType searched) {
183 return appliesTo.contains(searched);
186 public ModuleType getFirstModule() {
187 return appliesTo.iterator().next();