]> git.basschouten.com Git - openhab-addons.git/blob
b2985c3a5dc2af68ff112cac558680f5dc2fa212
[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.amazonechocontrol.internal.jsons;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.amazonechocontrol.internal.Connection;
18
19 /**
20  * The {@link JsonAnnouncementContent} encapsulate the GSON data of the sequence command AlexaAnnouncement for sending
21  * announcements
22  *
23  * @author Michael Geramb - Initial contribution
24  */
25 @NonNullByDefault
26 public class JsonAnnouncementContent {
27     public String locale = "";
28     public Display display;
29     public Speak speak;
30
31     public JsonAnnouncementContent(Connection.AnnouncementWrapper announcement) {
32         display = new Display(announcement.bodyText, announcement.title);
33         speak = new Speak(announcement.speak);
34     }
35
36     public static class Display {
37         public String title;
38         public String body;
39
40         public Display(String body, @Nullable String title) {
41             this.body = body;
42             this.title = (title == null || title.isEmpty() ? "openHAB" : title);
43         }
44     }
45
46     public static class Speak {
47         public String type;
48         public String value;
49
50         public Speak(String speakText) {
51             type = (speakText.startsWith("<speak>") && speakText.endsWith("</speak>")) ? "ssml" : "text";
52             value = speakText;
53         }
54     }
55 }