]> git.basschouten.com Git - openhab-addons.git/blob
faed6211fb50c6d4d2d2ada35381c53ee69e6c56
[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.ecovacs.internal.api.impl.dto.response.deviceapi.json;
14
15 import org.openhab.binding.ecovacs.internal.api.model.CleanMode;
16
17 import com.google.gson.Gson;
18 import com.google.gson.annotations.SerializedName;
19
20 /**
21  * @author Danny Baumann - Initial contribution
22  */
23 public class CleanReport {
24     @SerializedName("trigger")
25     public String trigger; // app, workComplete, ...?
26     @SerializedName("state")
27     public String state;
28     @SerializedName("cleanState")
29     public CleanStateReport cleanState;
30
31     public static class CleanStateReport {
32         @SerializedName("router")
33         public String router; // plan, ...?
34         @SerializedName("type")
35         public String type;
36         @SerializedName("motionState")
37         public String motionState;
38         @SerializedName("content")
39         public String areaDefinition;
40     }
41
42     public CleanMode determineCleanMode(Gson gson) {
43         final String modeValue;
44         if (cleanState != null) {
45             if ("working".equals(cleanState.motionState)) {
46                 modeValue = cleanState.type;
47             } else {
48                 modeValue = cleanState.motionState;
49             }
50         } else {
51             modeValue = state;
52         }
53         return gson.fromJson(modeValue, CleanMode.class);
54     }
55 }