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("movement") // When the Indoor Camera detects motion
50 MOVEMENT(ModuleType.WELCOME),
52 @SerializedName("human") // When the camera detects human motion
53 HUMAN(ModuleType.WELCOME, ModuleType.OUTDOOR, ModuleType.DOORBELL),
55 @SerializedName("animal") // When the camera detects animal motion
56 ANIMAL(ModuleType.WELCOME, ModuleType.OUTDOOR),
58 @SerializedName("vehicle") // When the Outdoor Camera detects a car
59 VEHICLE(ModuleType.OUTDOOR),
61 @SerializedName("new_module") // A new Module has been paired with the Indoor Camera
62 NEW_MODULE(ModuleType.WELCOME),
64 @SerializedName("module_connect") // Module is connected with the Indoor Camera
65 MODULE_CONNECT(ModuleType.WELCOME),
67 @SerializedName("module_disconnect") // Module lost its connection with the Indoor Camera
68 MODULE_DISCONNECT(ModuleType.WELCOME),
70 @SerializedName("module_low_battery") // Module's battery is low
71 MODULE_LOW_BATTERY(ModuleType.WELCOME),
73 @SerializedName("module_end_update") // Module's firmware update is over
74 MODULE_END_UPDATE(ModuleType.WELCOME),
76 @SerializedName("tag_big_move") // Module's firmware update is over
77 TAG_BIG_MOVE(ModuleType.WELCOME),
79 @SerializedName("tag_open") // Module's firmware update is over
80 TAG_OPEN(ModuleType.WELCOME),
82 @SerializedName("tag_small_move") // Module's firmware update is over
83 TAG_SMALL_MOVE(ModuleType.WELCOME),
85 @SerializedName("connection") // When the camera connects to Netatmo servers
86 CONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
88 @SerializedName("disconnection") // When the camera loses connection with Netatmo servers
89 DISCONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
91 @SerializedName("on") // When Camera Monitoring is resumed
92 ON(ModuleType.WELCOME, ModuleType.PRESENCE),
94 @SerializedName("off") // When Camera Monitoring is turned off
95 OFF(ModuleType.WELCOME, ModuleType.PRESENCE),
97 @SerializedName("boot") // When the Camera is booting
98 BOOT(ModuleType.WELCOME, ModuleType.PRESENCE),
100 @SerializedName("sd") // When Camera SD Card status changes
101 SD(ModuleType.WELCOME, ModuleType.PRESENCE),
103 @SerializedName("alim") // When Camera power supply status changes
104 ALIM(ModuleType.WELCOME, ModuleType.PRESENCE),
106 @SerializedName("siren_tampered") // When the siren has been tampered
107 SIREN_TAMPERED(ModuleType.WELCOME),
109 @SerializedName("accepted_call") // When a call is incoming
110 ACCEPTED_CALL(ModuleType.DOORBELL),
112 @SerializedName("incoming_call") // When a call as been answered by a user
113 INCOMING_CALL(ModuleType.DOORBELL),
115 @SerializedName("rtc") // Button pressed
116 RTC(ModuleType.DOORBELL),
118 @SerializedName("missed_call") // When a call has not been answered by anyone
119 MISSED_CALL(ModuleType.DOORBELL),
121 @SerializedName("hush") // When the smoke detection is activated or deactivated
122 HUSH(ModuleType.SMOKE_DETECTOR),
124 @SerializedName("smoke") // When smoke is detected or smoke is cleared
125 SMOKE(ModuleType.SMOKE_DETECTOR),
127 @SerializedName("tampered") // When smoke detector is ready or tampered
128 TAMPERED(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
130 @SerializedName("wifi_status") // When wifi status is updated
131 WIFI_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
133 @SerializedName("battery_status") // When battery status is too low
134 BATTERY_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
136 @SerializedName("detection_chamber_status") // When the detection chamber is dusty or clean
137 DETECTION_CHAMBER_STATUS(ModuleType.SMOKE_DETECTOR),
139 @SerializedName("sound_test") // Sound test result
140 SOUND_TEST(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
142 @SerializedName("new_device")
143 NEW_DEVICE(ModuleType.HOME),
145 @SerializedName("co_detected")
146 CO_DETECTED(ModuleType.CO_DETECTOR);
148 public static final EnumSet<EventType> AS_SET = EnumSet.allOf(EventType.class);
150 private final Set<ModuleType> appliesTo;
152 EventType(ModuleType... appliesTo) {
153 this.appliesTo = Set.of(appliesTo);
157 public String toString() {
158 return name().toLowerCase();
161 public boolean validFor(ModuleType searched) {
162 return appliesTo.contains(searched);