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