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