]> git.basschouten.com Git - openhab-addons.git/blob
d088853d2426d1cf06518d0adb7f5cb10b7a979e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.netatmo.internal.api.data;
14
15 import java.util.EnumSet;
16 import java.util.Set;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 import com.google.gson.annotations.SerializedName;
21
22 /**
23  * This enum describes events generated by webhooks and the type of
24  * module they are related to according to API documentation
25  *
26  * @author GaĆ«l L'hopital - Initial contribution
27  */
28 @NonNullByDefault
29 public enum EventType {
30     UNKNOWN(),
31     @SerializedName("webhook_activation") // Ack of a 'webhook set' Api Call
32     WEBHOOK_ACTIVATION(ModuleType.ACCOUNT),
33
34     @SerializedName("person") // When the Indoor Camera detects a face
35     PERSON(ModuleType.PERSON, ModuleType.WELCOME),
36
37     @SerializedName("person_away") // When geofencing indicates that the person has left the home
38     PERSON_AWAY(ModuleType.PERSON, ModuleType.HOME),
39
40     @SerializedName("person_home") // When the person is declared at home
41     PERSON_HOME(ModuleType.PERSON, ModuleType.HOME),
42
43     @SerializedName("outdoor") // When the Outdoor Camera detects a human, a car or an animal
44     OUTDOOR(ModuleType.PRESENCE, ModuleType.DOORBELL),
45
46     @SerializedName("daily_summary") // When the Outdoor Camera video summary of the last 24 hours is available
47     DAILY_SUMMARY(ModuleType.PRESENCE),
48
49     @SerializedName("vehicle") // When the Outdoor Camera detects a car
50     VEHICLE(ModuleType.PRESENCE),
51
52     @SerializedName("movement") // When the Indoor Camera detects motion
53     MOVEMENT(ModuleType.WELCOME),
54
55     @SerializedName("alarm_started") // When the Indoor Camera triggers alarm
56     ALARM_STARTED(ModuleType.WELCOME),
57
58     @SerializedName("human") // When the camera detects human motion
59     HUMAN(ModuleType.WELCOME, ModuleType.PRESENCE, ModuleType.DOORBELL),
60
61     @SerializedName("animal") // When the camera detects animal motion
62     ANIMAL(ModuleType.WELCOME, ModuleType.PRESENCE),
63
64     @SerializedName("new_module") // A new Module has been paired with the Indoor Camera
65     NEW_MODULE(ModuleType.WELCOME),
66
67     @SerializedName("module_connect") // Module is connected with the Indoor Camera
68     MODULE_CONNECT(ModuleType.WELCOME),
69
70     @SerializedName("module_disconnect") // Module lost its connection with the Indoor Camera
71     MODULE_DISCONNECT(ModuleType.WELCOME),
72
73     @SerializedName("module_low_battery") // Module's battery is low
74     MODULE_LOW_BATTERY(ModuleType.WELCOME),
75
76     @SerializedName("module_end_update") // Module's firmware update is over
77     MODULE_END_UPDATE(ModuleType.WELCOME),
78
79     @SerializedName("tag_big_move") // Module's firmware update is over
80     TAG_BIG_MOVE(ModuleType.WELCOME),
81
82     @SerializedName("tag_open") // Module's firmware update is over
83     TAG_OPEN(ModuleType.WELCOME),
84
85     @SerializedName("tag_small_move") // Module's firmware update is over
86     TAG_SMALL_MOVE(ModuleType.WELCOME),
87
88     @SerializedName("connection") // When the camera connects to Netatmo servers
89     CONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
90
91     @SerializedName("disconnection") // When the camera loses connection with Netatmo servers
92     DISCONNECTION(ModuleType.WELCOME, ModuleType.PRESENCE),
93
94     @SerializedName("on") // When Camera Monitoring is resumed
95     ON(ModuleType.WELCOME, ModuleType.PRESENCE),
96
97     @SerializedName("off") // When Camera Monitoring is turned off
98     OFF(ModuleType.WELCOME, ModuleType.PRESENCE),
99
100     @SerializedName("boot") // When the Camera is booting
101     BOOT(ModuleType.WELCOME, ModuleType.PRESENCE),
102
103     @SerializedName("sd") // When Camera SD Card status changes
104     SD(ModuleType.WELCOME, ModuleType.PRESENCE),
105
106     @SerializedName("alim") // When Camera power supply status changes
107     ALIM(ModuleType.WELCOME, ModuleType.PRESENCE),
108
109     @SerializedName("siren_tampered") // When the siren has been tampered
110     SIREN_TAMPERED(ModuleType.WELCOME),
111
112     @SerializedName("accepted_call") // When a call is incoming
113     ACCEPTED_CALL(ModuleType.DOORBELL),
114
115     @SerializedName("incoming_call") // When a call as been answered by a user
116     INCOMING_CALL(ModuleType.DOORBELL),
117
118     @SerializedName("rtc") // Button pressed
119     RTC(ModuleType.DOORBELL),
120
121     @SerializedName("missed_call") // When a call has not been answered by anyone
122     MISSED_CALL(ModuleType.DOORBELL),
123
124     @SerializedName("hush") // When the smoke detection is activated or deactivated
125     HUSH(ModuleType.SMOKE_DETECTOR),
126
127     @SerializedName("smoke") // When smoke is detected or smoke is cleared
128     SMOKE(ModuleType.SMOKE_DETECTOR),
129
130     @SerializedName("tampered") // When smoke detector is ready or tampered
131     TAMPERED(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
132
133     @SerializedName("wifi_status") // When wifi status is updated
134     WIFI_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
135
136     @SerializedName("battery_status") // When battery status is too low
137     BATTERY_STATUS(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
138
139     @SerializedName("detection_chamber_status") // When the detection chamber is dusty or clean
140     DETECTION_CHAMBER_STATUS(ModuleType.SMOKE_DETECTOR),
141
142     @SerializedName("sound_test") // Sound test result
143     SOUND_TEST(ModuleType.SMOKE_DETECTOR, ModuleType.CO_DETECTOR),
144
145     @SerializedName("new_device")
146     NEW_DEVICE(ModuleType.HOME),
147
148     @SerializedName("co_detected")
149     CO_DETECTED(ModuleType.CO_DETECTOR),
150
151     @SerializedName("alarm_event") // an alarm event arrived on a weather station module
152     ALARM_EVENT(ModuleType.WEATHER_STATION),
153
154     @SerializedName("entered") // the alarm was raised
155     ALARM_ENTERED(ModuleType.WEATHER_STATION),
156
157     @SerializedName("exited") // the alarm is stopped
158     ALARM_EXITED(ModuleType.WEATHER_STATION),
159
160     @SerializedName("display_change") // a manual action has been done on the thermostat
161     DISPLAY_CHANGE(ModuleType.THERMOSTAT),
162
163     @SerializedName("set_point") // a setpoint has been set
164     SET_POINT(ModuleType.THERMOSTAT),
165
166     @SerializedName("cancel_set_point") // manual setpoint ended
167     CANCEL_SET_POINT(ModuleType.THERMOSTAT);
168
169     public static final EnumSet<EventType> AS_SET = EnumSet.allOf(EventType.class);
170
171     private final Set<ModuleType> appliesTo;
172
173     EventType(ModuleType... appliesTo) {
174         this.appliesTo = Set.of(appliesTo);
175     }
176
177     @Override
178     public String toString() {
179         return name().toLowerCase();
180     }
181
182     public boolean validFor(ModuleType searched) {
183         return appliesTo.contains(searched);
184     }
185
186     public ModuleType getFirstModule() {
187         return appliesTo.iterator().next();
188     }
189 }