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