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 {
32 @SerializedName("person") // When the Indoor Camera detects a face
33 PERSON(ModuleType.PERSON, ModuleType.WELCOME),
35 @SerializedName("person_away") // When geofencing indicates that the person has left the home
36 PERSON_AWAY(ModuleType.PERSON, ModuleType.HOME),
38 @SerializedName("person_home") // When the person is declared at home
39 PERSON_HOME(ModuleType.PERSON, ModuleType.HOME),
41 @SerializedName("outdoor") // When the Outdoor Camera detects a human, a car or an animal
42 OUTDOOR(ModuleType.PRESENCE, ModuleType.DOORBELL),
44 @SerializedName("daily_summary") // When the Outdoor Camera video summary of the last 24 hours is available
45 DAILY_SUMMARY(ModuleType.PRESENCE),
47 @SerializedName("movement") // When the Indoor Camera detects motion
48 MOVEMENT(ModuleType.WELCOME),
50 @SerializedName("human") // When the camera detects human motion
51 HUMAN(ModuleType.WELCOME, ModuleType.OUTDOOR, ModuleType.DOORBELL),
53 @SerializedName("animal") // When the camera detects animal motion
54 ANIMAL(ModuleType.WELCOME, ModuleType.OUTDOOR),
56 @SerializedName("vehicle") // When the Outdoor Camera detects a car
57 VEHICLE(ModuleType.OUTDOOR),
59 @SerializedName("new_module") // A new Module has been paired with the Indoor Camera
60 NEW_MODULE(ModuleType.WELCOME),
62 @SerializedName("module_connect") // Module is connected with the Indoor Camera
63 MODULE_CONNECT(ModuleType.WELCOME),
65 @SerializedName("module_disconnect") // Module lost its connection with the Indoor Camera
66 MODULE_DISCONNECT(ModuleType.WELCOME),
68 @SerializedName("module_low_battery") // Module's battery is low
69 MODULE_LOW_BATTERY(ModuleType.WELCOME),
71 @SerializedName("module_end_update") // Module's firmware update is over
72 MODULE_END_UPDATE(ModuleType.WELCOME),
74 @SerializedName("connection") // When the camera connects to Netatmo servers
75 CONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
77 @SerializedName("disconnection") // When the camera loses connection with Netatmo servers
78 DISCONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
80 @SerializedName("on") // When Camera Monitoring is resumed
81 ON(ModuleType.WELCOME, ModuleType.PRESENCE),
83 @SerializedName("off") // When Camera Monitoring is turned off
84 OFF(ModuleType.WELCOME, ModuleType.PRESENCE),
86 @SerializedName("boot") // When the Camera is booting
87 BOOT(ModuleType.WELCOME, ModuleType.PRESENCE),
89 @SerializedName("sd") // When Camera SD Card status changes
90 SD(ModuleType.WELCOME, ModuleType.PRESENCE),
92 @SerializedName("alim") // When Camera power supply status changes
93 ALIM(ModuleType.WELCOME, ModuleType.PRESENCE),
95 @SerializedName("accepted_call") // When a call is incoming
96 ACCEPTED_CALL(ModuleType.DOORBELL),
98 @SerializedName("incoming_call") // When a call as been answered by a user
99 INCOMING_CALL(ModuleType.DOORBELL),
101 @SerializedName("rtc") // Button pressed
102 RTC(ModuleType.DOORBELL),
104 @SerializedName("missed_call") // When a call has not been answered by anyone
105 MISSED_CALL(ModuleType.DOORBELL),
107 @SerializedName("hush") // When the smoke detection is activated or deactivated
108 HUSH(ModuleType.SMOKE_DETECTOR),
110 @SerializedName("smoke") // When smoke is detected or smoke is cleared
111 SMOKE(ModuleType.SMOKE_DETECTOR),
113 @SerializedName("tampered") // When smoke detector is ready or tampered
114 TAMPERED(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
116 @SerializedName("wifi_status") // When wifi status is updated
117 WIFI_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
119 @SerializedName("battery_status") // When battery status is too low
120 BATTERY_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
122 @SerializedName("detection_chamber_status") // When the detection chamber is dusty or clean
123 DETECTION_CHAMBER_STATUS(ModuleType.SMOKE_DETECTOR),
125 @SerializedName("sound_test") // Sound test result
126 SOUND_TEST(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
128 @SerializedName("new_device")
129 NEW_DEVICE(ModuleType.HOME),
131 @SerializedName("co_detected")
132 CO_DETECTED(ModuleType.CO_DETECTOR);
134 public static final EnumSet<EventType> AS_SET = EnumSet.allOf(EventType.class);
136 private final Set<ModuleType> appliesTo;
138 EventType(ModuleType... appliesTo) {
139 this.appliesTo = Set.of(appliesTo);
143 public String toString() {
144 return name().toLowerCase();
147 public boolean validFor(ModuleType searched) {
148 return appliesTo.contains(searched);