]> git.basschouten.com Git - openhab-addons.git/blob
68fae75c010295f5ee62b5fcb6bf8f63cf3b1026
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.lutron.internal.radiora.protocol;
14
15 /**
16  * Feedback that gives the state of all zones
17  * <p>
18  * <b>Syntax:</b>
19  *
20  * <pre>
21  * {@code
22  * ZMP,<Zone States>
23  * }
24  * </pre>
25  *
26  * <b>Example:</b>
27  * <p>
28  * Zones 2 and 9 are ON, all others are OFF, and Zones 31 and 32 are unassigned.
29  *
30  * <pre>
31  * ZMP,010000001000000000000000000000XX
32  * </pre>
33  *
34  * @author Jeff Lauterbach - Initial Contribution
35  *
36  */
37 public class ZoneMapFeedback extends RadioRAFeedback {
38
39     private String zoneStates; // 32 bit String of (0,1,X)
40
41     public ZoneMapFeedback(String msg) {
42         String[] params = parse(msg, 1);
43
44         zoneStates = params[1];
45     }
46
47     public String getZoneStates() {
48         return zoneStates;
49     }
50
51     public char getZoneValue(int zone) {
52         if (zone < 1 || zone > zoneStates.length()) {
53             return 'X';
54         }
55
56         return zoneStates.charAt(zone - 1);
57     }
58 }