]> git.basschouten.com Git - openhab-addons.git/blob
35d461954cf872f1316b277aa3a2bbebbf70529b
[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.yamahareceiver.internal.protocol.xml;
14
15 import java.util.function.Supplier;
16
17 import org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone;
18 import org.openhab.binding.yamahareceiver.internal.config.YamahaZoneConfig;
19 import org.openhab.binding.yamahareceiver.internal.protocol.AbstractConnection;
20 import org.openhab.binding.yamahareceiver.internal.protocol.InputConverter;
21 import org.openhab.binding.yamahareceiver.internal.state.DeviceInformationState;
22 import org.openhab.binding.yamahareceiver.internal.state.ZoneControlStateListener;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * Special case of {@link ZoneControlXML} that emulates Zone_2 for Yamaha HTR-xxx using Zone_B features.
27  *
28  * @author Tomasz Maruszak - Initial contribution.
29  */
30 public class ZoneBControlXML extends ZoneControlXML {
31
32     public ZoneBControlXML(AbstractConnection con, YamahaZoneConfig zoneSettings, ZoneControlStateListener observer,
33             DeviceInformationState deviceInformationState, Supplier<InputConverter> inputConverterSupplier) {
34         // Commands will need to be send to Main_Zone
35         super(con, Zone.Main_Zone, zoneSettings, observer, deviceInformationState, inputConverterSupplier);
36
37         this.logger = LoggerFactory.getLogger(ZoneBControlXML.class);
38     }
39
40     @Override
41     public Zone getZone() {
42         return Zone.Zone_2;
43     }
44
45     @Override
46     protected void applyModelVariations() {
47         super.applyModelVariations();
48
49         // Apply custom templates for HTR-xxx
50         this.power = new CommandTemplate("<Power_Control><Zone_B_Power>%s</Zone_B_Power></Power_Control>",
51                 "Power_Control/Zone_B_Power_Info");
52         this.mute = new CommandTemplate("<Volume><Zone_B><Mute>%s</Mute></Zone_B></Volume>", "Volume/Zone_B/Mute");
53         this.volume = new CommandTemplate(
54                 "<Volume><Zone_B><Lvl><Val>%d</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Zone_B></Volume>",
55                 "Volume/Zone_B/Lvl/Val");
56     }
57 }