2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.yamahareceiver.internal.protocol.xml;
15 import java.util.function.Supplier;
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;
26 * Special case of {@link ZoneControlXML} that emulates Zone_2 for Yamaha HTR-xxx using Zone_B features.
28 * @author Tomasz Maruszak - Initial contribution.
30 public class ZoneBControlXML extends ZoneControlXML {
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);
37 this.logger = LoggerFactory.getLogger(ZoneBControlXML.class);
41 public Zone getZone() {
46 protected void applyModelVariations() {
47 super.applyModelVariations();
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");