From 73b9cb7650e21b4fe7200444c17084cb9fde3b8e Mon Sep 17 00:00:00 2001 From: "H. William Welliver III" Date: Tue, 8 Mar 2022 19:52:11 -0500 Subject: [PATCH] sync with current binding --- pom.xml | 9 +- src/main/history/dependencies.xml | 1 + .../NadReceiverBindingConstants.java | 33 -- .../handler/CommunicationException.java | 14 - .../handler/NadReceiverHandler.java | 449 ------------------ .../internal/NadReceiverHandlerFactory.java | 1 - .../NadReceiverSourcesConfiguration.java | 2 +- .../internal/NadSourcesOptionProvider.java | 4 +- .../resources/ESH-INF/binding/binding.xml | 10 - .../resources/ESH-INF/thing/thing-types.xml | 115 ----- src/main/resources/OH-INF/binding/binding.xml | 10 + src/main/resources/OH-INF/config/config.xml | 40 ++ .../OH-INF/i18n/nadreceiver_en_US.properties | 13 + .../resources/OH-INF/thing/channel_types.xml | 78 +++ .../resources/OH-INF/thing/thing-types.xml | 28 ++ 15 files changed, 178 insertions(+), 629 deletions(-) delete mode 100644 src/main/java/org/openhab/binding/nadreceiver/NadReceiverBindingConstants.java delete mode 100644 src/main/java/org/openhab/binding/nadreceiver/handler/CommunicationException.java delete mode 100644 src/main/java/org/openhab/binding/nadreceiver/handler/NadReceiverHandler.java delete mode 100644 src/main/resources/ESH-INF/binding/binding.xml delete mode 100644 src/main/resources/ESH-INF/thing/thing-types.xml create mode 100644 src/main/resources/OH-INF/binding/binding.xml create mode 100644 src/main/resources/OH-INF/config/config.xml create mode 100644 src/main/resources/OH-INF/i18n/nadreceiver_en_US.properties create mode 100644 src/main/resources/OH-INF/thing/channel_types.xml create mode 100644 src/main/resources/OH-INF/thing/thing-types.xml diff --git a/pom.xml b/pom.xml index c2bf9a3..5ee2a5b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,13 @@ - - + + + 4.0.0 org.openhab.addons.bundles org.openhab.addons.reactor.bundles - 3.2.0 + 3.3.0-SNAPSHOT org.openhab.binding.nadreceiver diff --git a/src/main/history/dependencies.xml b/src/main/history/dependencies.xml index 60c183b..edba1a1 100644 --- a/src/main/history/dependencies.xml +++ b/src/main/history/dependencies.xml @@ -2,6 +2,7 @@ wrap + mvn:commons-net/commons-net/3.7.2 wrap:mvn:org.lastnpe.eea/eea-all/2.2.1 diff --git a/src/main/java/org/openhab/binding/nadreceiver/NadReceiverBindingConstants.java b/src/main/java/org/openhab/binding/nadreceiver/NadReceiverBindingConstants.java deleted file mode 100644 index 8757b79..0000000 --- a/src/main/java/org/openhab/binding/nadreceiver/NadReceiverBindingConstants.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2014 openHAB UG (haftungsbeschraenkt) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.nadreceiver; - -import org.openhab.core.thing.ThingTypeUID; - -/** - * The {@link NadReceiverBinding} class defines common constants, which are - * used across the whole binding. - * - * @author Mikael Aasen - Initial contribution - */ -public class NadReceiverBindingConstants { - - public static final String BINDING_ID = "nadreceiver"; - - // List of all Thing Type UIDs - public final static ThingTypeUID THING_TYPE_RECEIVER = new ThingTypeUID(BINDING_ID, "receiver"); - - // List of all Channel ids - public final static String CHANNEL_POWER = "power"; - public final static String CHANNEL_MUTE = "mute"; - public final static String CHANNEL_VOLUME = "volume"; - public final static String CHANNEL_SOURCE = "source"; - public final static String CHANNEL_TUNER_BAND = "tuner_band"; - public final static String CHANNEL_AM_FREQUENCY = "am_frequency"; - public final static String CHANNEL_FM_FREQUENCY = "fm_frequency"; -} diff --git a/src/main/java/org/openhab/binding/nadreceiver/handler/CommunicationException.java b/src/main/java/org/openhab/binding/nadreceiver/handler/CommunicationException.java deleted file mode 100644 index ecb58e7..0000000 --- a/src/main/java/org/openhab/binding/nadreceiver/handler/CommunicationException.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.openhab.binding.nadreceiver.handler; - -public class CommunicationException extends Exception { - - public CommunicationException(String message) { - super(message); - } - - public CommunicationException(String message, Exception e) { - super(message, e); - } - - private static final long serialVersionUID = 1L; -} diff --git a/src/main/java/org/openhab/binding/nadreceiver/handler/NadReceiverHandler.java b/src/main/java/org/openhab/binding/nadreceiver/handler/NadReceiverHandler.java deleted file mode 100644 index 7e19b24..0000000 --- a/src/main/java/org/openhab/binding/nadreceiver/handler/NadReceiverHandler.java +++ /dev/null @@ -1,449 +0,0 @@ -/** - * Copyright (c) 2014 openHAB UG (haftungsbeschraenkt) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.nadreceiver.handler; - -import static javax.measure.MetricPrefix.KILO; -import static javax.measure.MetricPrefix.MEGA; -import static org.openhab.binding.nadreceiver.NadReceiverBindingConstants.*; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import javax.measure.quantity.Frequency; - -import org.openhab.binding.nadreceiver.internal.NadReceiverDynamicStateDescriptionProvider; -import org.openhab.binding.nadreceiver.internal.PortServer; -import org.openhab.core.library.types.*; -import org.openhab.core.library.unit.Units; -import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingStatus; -import org.openhab.core.thing.ThingStatusDetail; -import org.openhab.core.thing.binding.BaseThingHandler; -import org.openhab.core.types.Command; -import org.openhab.core.types.RefreshType; -import org.openhab.core.types.StateOption; -import org.openhab.core.types.UnDefType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The {@link NadReceiverHandler} is responsible for handling commands, which are - * sent to one of the channels. - * - * @author Mikael Aasen - Initial contribution - * @author William Welliver - TCP mode suppot - */ -public class NadReceiverHandler extends BaseThingHandler implements Runnable { - - private Logger logger = LoggerFactory.getLogger(NadReceiverHandler.class); - - private boolean on = false; - private PortServer port; - private OutputStreamWriter output; - private InputStream input; - - private NadReceiverDynamicStateDescriptionProvider stateDescriptionProvider; - - public NadReceiverHandler(Thing thing, NadReceiverDynamicStateDescriptionProvider stateDescriptionProvider) { - super(thing); - this.stateDescriptionProvider = stateDescriptionProvider; - } - - private void configureSourceStateOptions(String sources) { - ChannelUID channelId = new ChannelUID(getThing().getUID(), CHANNEL_SOURCE); - List options = new ArrayList<>(); - int i = 1; - for (String source : sources.split(",")) { - logger.warn("Adding state option " + i + " for " + channelId + ": " + source.trim()); - options.add(new StateOption("" + i, source.trim())); - i++; - } - - stateDescriptionProvider.setStateOptions(channelId, options); - } - - @Override - public synchronized void initialize() { - try { - logger.warn("thing: " + getThing()); - logger.warn("channel: " + getThing().getChannel(CHANNEL_POWER)); - - configureSourceStateOptions((String) getThing().getConfiguration().get("sources")); - - ChannelUID channelUID = getUidForChannel(CHANNEL_POWER); - boolean powerOn = isOn(); - updateState(channelUID, powerOn ? OnOffType.ON : OnOffType.OFF); - if (powerOn) { - refreshAll(); - } else { - channelUID = getUidForChannel(CHANNEL_VOLUME); - updateState(channelUID, UnDefType.UNDEF); - channelUID = getUidForChannel(CHANNEL_MUTE); - updateState(channelUID, UnDefType.UNDEF); - channelUID = getUidForChannel(CHANNEL_SOURCE); - updateState(channelUID, UnDefType.UNDEF); - channelUID = getUidForChannel(CHANNEL_TUNER_BAND); - updateState(channelUID, UnDefType.UNDEF); - channelUID = getUidForChannel(CHANNEL_AM_FREQUENCY); - updateState(channelUID, UnDefType.UNDEF); - channelUID = getUidForChannel(CHANNEL_FM_FREQUENCY); - updateState(channelUID, UnDefType.UNDEF); - updateStatus(ThingStatus.ONLINE); - } - } catch (IOException e) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); - } - BigDecimal pollingInterval = (BigDecimal) getThing().getConfiguration().get("polling-interval"); - if (pollingInterval != null && pollingInterval.longValue() != 0) { - scheduler.scheduleAtFixedRate(this, pollingInterval.longValue(), pollingInterval.longValue(), - TimeUnit.SECONDS); - } - } - - private void refreshAll() throws IOException { - ChannelUID channelUID; - try { - channelUID = getUidForChannel(CHANNEL_VOLUME); - updateState(channelUID, PercentType.valueOf(Double.toString(toPercent(askInt("Main.Volume"))))); - boolean isMute = "On".equals(askString("Main.Mute", false)); - channelUID = getUidForChannel(CHANNEL_MUTE); - updateState(channelUID, isMute ? OnOffType.ON : OnOffType.OFF); - channelUID = getUidForChannel(CHANNEL_SOURCE); - updateState(channelUID, new StringType(Integer.toString(askInt("Main.Source")))); - channelUID = getUidForChannel(CHANNEL_SOURCE); - updateState(channelUID, new StringType(Integer.toString(askInt("Main.Source")))); - channelUID = getUidForChannel(CHANNEL_TUNER_BAND); - updateState(channelUID, new StringType(askString("Tuner.Band", false))); - channelUID = getUidForChannel(CHANNEL_AM_FREQUENCY); - updateState(channelUID, - new QuantityType(BigDecimal.valueOf(askInt("Tuner.AM.Frequency")), KILO(Units.HERTZ))); - channelUID = getUidForChannel(CHANNEL_FM_FREQUENCY); - updateState(channelUID, - new QuantityType(BigDecimal.valueOf(askFloat("Tuner.FM.Frequency")), MEGA(Units.HERTZ))); - - } catch (CommunicationException e) { - logger.warn("Error communicating with receiver.", e); - port.disconnect(); - } - } - - private ChannelUID getUidForChannel(String channelName) { - return getThing().getChannel(channelName).getUID(); - } - - @Override - public void dispose() { - try { - port.disconnect(); - } catch (NullPointerException e) { - } - } - - private synchronized void connect() { - if (port == null || !port.isConnected()) { - logger.warn("connecting"); - - String hostName = (String) getThing().getConfiguration().get("hostName"); - BigDecimal portNumber = (BigDecimal) getThing().getConfiguration().get("tcpPort"); - - if (hostName == null || hostName.isEmpty()) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "No host name specified."); - return; - } - - if (portNumber == null || portNumber.toBigInteger().intValue() == 0) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "No TCP port specified."); - return; - } - - port = new PortServer(); - port.setTcpMode(hostName, portNumber.toBigInteger().intValue()); - - try { - port.connect(); - OutputStream outStream = port.getOutputStream(); - output = new OutputStreamWriter(outStream); - input = port.getInputStream(); - } catch (IOException e) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); - logger.warn("Error connecting to receiver.", e); - - } - } - } - - private double toPercent(double decibel) { - return (decibel + 92) * 0.9; - } - - private double toDecibel(double percent) { - return (percent / 0.9) - 92; - } - - @Override - public void handleCommand(ChannelUID channelUID, Command command) { - try { - // logger.warn("configuration: " + this.getThing().getChannel(CHANNEL_SOURCE).getConfiguration()); - if (channelUID.getId().equals(CHANNEL_POWER)) { - handlePower(channelUID, command); - } else if (channelUID.getId().equals(CHANNEL_VOLUME)) { - handleVolume(channelUID, command); - } else if (channelUID.getId().equals(CHANNEL_MUTE)) { - handleMute(channelUID, command); - } else if (channelUID.getId().equals(CHANNEL_SOURCE)) { - handleSource(channelUID, command); - } else if (channelUID.getId().equals(CHANNEL_TUNER_BAND)) { - handleTunerBand(channelUID, command); - } else if (channelUID.getId().equals(CHANNEL_AM_FREQUENCY)) { - handleAMFrequency(channelUID, command); - } else if (channelUID.getId().equals(CHANNEL_FM_FREQUENCY)) { - handleFMFrequency(channelUID, command); - } - } catch (IOException | CommunicationException e) { - port.disconnect(); - port = null; - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); - logger.error("Port port error: " + e.getMessage()); - on = false; - } - } - - private void handleMute(ChannelUID channelUID, Command command) throws CommunicationException, IOException { - if (command != null) { - if (command instanceof OnOffType) { - if (command.equals(OnOffType.ON)) { - setValue("Main.Mute", "On"); - } else if (command.equals(OnOffType.OFF)) { - setValue("Main.Mute", "Off"); - } - } else if (command instanceof RefreshType) { - boolean isMute = "On".equals(askString("Main.Mute", false)); - updateState(channelUID, isMute ? OnOffType.ON : OnOffType.OFF); - } - } - } - - private void handleSource(ChannelUID channelUID, Command command) throws CommunicationException, IOException { - if (command != null) { - if (command instanceof RefreshType) { - updateState(channelUID, new StringType(Integer.toString(askInt("Main.Source")))); - } else if (command instanceof StringType) { - setValue("Main.Source", command.toString()); - } - } - } - - private void handleTunerBand(ChannelUID channelUID, Command command) throws CommunicationException, IOException { - if (command != null) { - if (command instanceof RefreshType) { - updateState(channelUID, new StringType(askString("Tuner.Band", false))); - } else if (command instanceof StringType) { - setValue("Tuner.Band", command.toString()); - } - } - } - - private void handleAMFrequency(ChannelUID channelUID, Command command) throws CommunicationException, IOException { - if (command != null) { - if (command instanceof RefreshType) { - updateState(channelUID, new QuantityType(BigDecimal.valueOf(askInt("Tuner.AM.Frequency")), - KILO(Units.HERTZ))); - } else if (command instanceof QuantityType) { - QuantityType t = (QuantityType) command; - t = t.toUnit(KILO(Units.HERTZ)); - setValue("Tuner.AM.Frequency", "" + t.intValue()); - } - } - } - - private void handleFMFrequency(ChannelUID channelUID, Command command) throws CommunicationException, IOException { - if (command != null) { - if (command instanceof RefreshType) { - updateState(channelUID, new QuantityType(BigDecimal.valueOf(askInt("Tuner.AM.Frequency")), - KILO(Units.HERTZ))); - } else if (command instanceof QuantityType) { - QuantityType t = (QuantityType) command; - t = t.toUnit(MEGA(Units.HERTZ)); - t.toBigDecimal().setScale(1).toPlainString(); - setValue("Tuner.AM.Frequency", t.toBigDecimal().setScale(1).toPlainString()); - } - } - } - - private void handlePower(ChannelUID channelUID, Command command) throws IOException, CommunicationException { - logger.info("Setting power to: " + command.toString()); - if (command != null) { - if (command instanceof OnOffType) { - if (command.equals(OnOffType.ON)) { - on(); - } else if (command.equals(OnOffType.OFF)) { - off(); - } - } else if (command instanceof RefreshType) { - updateState(channelUID, isOn() ? OnOffType.ON : OnOffType.OFF); - } - } - } - - private void handleVolume(ChannelUID channelUID, Command command) throws CommunicationException, IOException { - if (command != null) { - if (command instanceof IncreaseDecreaseType && command == IncreaseDecreaseType.INCREASE) { - adjustValue("Main.Volume", "+"); - } else if (command instanceof IncreaseDecreaseType && command == IncreaseDecreaseType.DECREASE) { - adjustValue("Main.Volume", "-"); - } else if (command instanceof DecimalType) { - setValue("Main.Volume", Integer.toString((int) toDecibel(Double.parseDouble(command.toString())))); - } else if (command instanceof RefreshType) { - updateState(channelUID, PercentType.valueOf(Integer.toString((int) toPercent(askInt("Main.Volume"))))); - } - } - } - - public void off() throws IOException, CommunicationException { - connect(); - setValue("Main.Power", "Off"); - } - - public synchronized void on() throws IOException { - connect(); - int attempts = 0; - do { - output.write("\rMain.Power=On\r"); - output.flush(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - return; - } - } while (!isOn() && attempts++ < 3); - if (isOn()) { - refreshAll(); - } - } - - public boolean isOn() throws IOException { - String power; - try { - power = askString("Main.Power", true); - } catch (CommunicationException e) { - power = ""; - } - on = "On".equals(power); - return on; - } - - private String askString(String key, boolean ignorePowerState) throws CommunicationException, IOException { - String answer = requestResponse(key + "?", ignorePowerState); - String[] parts = answer.split("="); - if (parts.length == 2) { - updateStatus(ThingStatus.ONLINE); - return parts[1]; - } - throw new CommunicationException("Invalid response from receiver"); - } - - private int askInt(String key) throws CommunicationException, IOException { - try { - return Integer.parseInt(askString(key, false)); - } catch (NumberFormatException e) { - throw new CommunicationException("Not a number received", e); - } - } - - private float askFloat(String key) throws CommunicationException, IOException { - try { - return Float.parseFloat(askString(key, false)); - } catch (NumberFormatException e) { - throw new CommunicationException("Not a number received", e); - } - } - - private void setValue(String key, String value) throws CommunicationException, IOException { - String answer = requestResponse(key + "=" + value, false); - String[] parts = answer.split("="); - if (parts.length != 2) { - throw new CommunicationException("Invalid response from receiver: (length=" + Integer.toString(parts.length) - + ") key \"" + parts[0] + "\" answer " + answer + " expected \"" + key + "\""); - } - } - - private String adjustValue(String key, String operator) throws CommunicationException, IOException { - String answer = requestResponse(key + operator, false); - String[] parts = answer.split("="); - if (parts.length == 2 && key.equals(parts[0])) { - return parts[1]; - } else { - throw new CommunicationException("Got the wrong answer: " + answer); - } - } - - private synchronized String requestResponse(String request, boolean ignorePowerState) - throws IOException, CommunicationException { - if (!on && !ignorePowerState && !isOn()) { - throw new CommunicationException("Receiver is off"); - } - connect(); - - while (input != null && input.available() > 0) { - input.read(); - } - logger.debug("sending to receiver: " + request); - output.write("\r" + request + "\r"); - output.flush(); - int data = input.read(); - - if (data != -1) { - // logger.warn("got response from receiver: " + data); - - boolean end = false; - String answer = ""; - - if (data != '\r') { - answer += (char) data; - } - - while (!end) { - data = input.read(); - if (data == '\r' || data == '\n') { - end = true; - } else if (data == -1) { - throw new CommunicationException("Unexpected end of input"); - } else { - answer += (char) data; - } - } - logger.debug("got response from receiver: " + answer); - return answer; - } - throw new CommunicationException("Invalid response from receiver"); - } - - @Override - public void run() { - ChannelUID channelUID = getUidForChannel(CHANNEL_POWER); - try { - boolean power = isOn(); - updateStatus(ThingStatus.ONLINE); - updateState(channelUID, power ? OnOffType.ON : OnOffType.OFF); - if (power) { - refreshAll(); - } - } catch (IOException e) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage()); - logger.warn("Error communicating with receiver.", e); - port.disconnect(); - } - } -} diff --git a/src/main/java/org/openhab/binding/nadreceiver/internal/NadReceiverHandlerFactory.java b/src/main/java/org/openhab/binding/nadreceiver/internal/NadReceiverHandlerFactory.java index 312ac82..d29628a 100644 --- a/src/main/java/org/openhab/binding/nadreceiver/internal/NadReceiverHandlerFactory.java +++ b/src/main/java/org/openhab/binding/nadreceiver/internal/NadReceiverHandlerFactory.java @@ -22,7 +22,6 @@ import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.binding.BaseThingHandlerFactory; import org.openhab.core.thing.binding.ThingHandler; import org.openhab.core.thing.binding.ThingHandlerFactory; -import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; diff --git a/src/main/java/org/openhab/binding/nadreceiver/internal/NadReceiverSourcesConfiguration.java b/src/main/java/org/openhab/binding/nadreceiver/internal/NadReceiverSourcesConfiguration.java index b0e9230..25d71f2 100644 --- a/src/main/java/org/openhab/binding/nadreceiver/internal/NadReceiverSourcesConfiguration.java +++ b/src/main/java/org/openhab/binding/nadreceiver/internal/NadReceiverSourcesConfiguration.java @@ -72,7 +72,7 @@ public class NadReceiverSourcesConfiguration { } List options = new ArrayList(); for (NadReceiverSourceConfiguration config : configurations.values()) { - logger.info("config: " + config); + logger.trace("config: " + config); if (config != null && config.getEnabled()) { options.add(new StateOption(config.getNumber(), config.getName())); } diff --git a/src/main/java/org/openhab/binding/nadreceiver/internal/NadSourcesOptionProvider.java b/src/main/java/org/openhab/binding/nadreceiver/internal/NadSourcesOptionProvider.java index 37a9c65..b46e581 100644 --- a/src/main/java/org/openhab/binding/nadreceiver/internal/NadSourcesOptionProvider.java +++ b/src/main/java/org/openhab/binding/nadreceiver/internal/NadSourcesOptionProvider.java @@ -49,7 +49,7 @@ public class NadSourcesOptionProvider implements DynamicStateDescriptionProvider @Override public @Nullable StateDescription getStateDescription(Channel channel, @Nullable StateDescription original, @Nullable Locale locale) { - logger.info("getStateDescription for " + channel.getUID() + " "); + logger.trace("getStateDescription for " + channel.getUID() + " "); List options = channelOptionsMap.get(channel.getUID()); @@ -57,7 +57,7 @@ public class NadSourcesOptionProvider implements DynamicStateDescriptionProvider return null; } - logger.info("getStateDescription for " + channel + " " + options); + logger.trace("getStateDescription for " + channel + " " + options); if (original != null) { return StateDescriptionFragmentBuilder.create(original).withOptions(options).build().toStateDescription(); } diff --git a/src/main/resources/ESH-INF/binding/binding.xml b/src/main/resources/ESH-INF/binding/binding.xml deleted file mode 100644 index 9965510..0000000 --- a/src/main/resources/ESH-INF/binding/binding.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - NAD Receiver - Binding for RS232/TCP connection to NAD receiver. - Mikael Aasen - - diff --git a/src/main/resources/ESH-INF/thing/thing-types.xml b/src/main/resources/ESH-INF/thing/thing-types.xml deleted file mode 100644 index 6a8f1c8..0000000 --- a/src/main/resources/ESH-INF/thing/thing-types.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - Receiver control - - - - - - - - - - - - Is receiver connected via TCP? - false - - - - Select serial port - COM1 - serial-port - - - - Host name of receiver - localhost - network-address - - - - Network port number of receiver - 1234 - - - - Select polling Interval - 60 - - - - Comma separated list of descriptions for input sources - Source 1, Source 2, Source 3, Source 4, Source 5, Source 6, Source 7, Source 8, Source 9 - network-address - - - - - - - Switch - - Turn it on or off. - Power - - - - Switch - - Mute on/off. - Mute - - - - Dimmer - - Volume control - SoundVolume - - - - String - - Select input - Source - - - - - String - - Select Band - Source - - - - - - - - - - Number:Frequency - - Select Frequency - Source - - - - - Number:Frequency - - Select Frequency - Source - - - diff --git a/src/main/resources/OH-INF/binding/binding.xml b/src/main/resources/OH-INF/binding/binding.xml new file mode 100644 index 0000000..1024057 --- /dev/null +++ b/src/main/resources/OH-INF/binding/binding.xml @@ -0,0 +1,10 @@ + + + + NAD Receiver Binding + This is the binding for NAD Receivers (e.g. T758v3) + Marc Chételat + + diff --git a/src/main/resources/OH-INF/config/config.xml b/src/main/resources/OH-INF/config/config.xml new file mode 100644 index 0000000..dc49406 --- /dev/null +++ b/src/main/resources/OH-INF/config/config.xml @@ -0,0 +1,40 @@ + + + + + + + The IP or host name of the NAD Receiver + network-address + + + + Port for the NAD Receiver device to control. It uses telnet and therefore by default use port 23. + 23 + + + + The period in minutes that the handler will wait between connection attempts + minutes + 5 + true + + + + The period in minutes between connection heartbeat checks + minutes + 5 + true + + + + The binding will iterate from 1 to max. number of sources to detect them + sources + 9 + true + + + diff --git a/src/main/resources/OH-INF/i18n/nadreceiver_en_US.properties b/src/main/resources/OH-INF/i18n/nadreceiver_en_US.properties new file mode 100644 index 0000000..c0eaeba --- /dev/null +++ b/src/main/resources/OH-INF/i18n/nadreceiver_en_US.properties @@ -0,0 +1,13 @@ +# FIXME: please substitute the xx_XX with a proper locale, ie. de_DE +# FIXME: please do not add the file to the repo if you add or change no content +# binding +binding.nadreceiver.name = NAD Receiver +binding.nadreceiver.description = Support for NAD T series amplifiers and processors + +# thing types +thing-type.nadreceiver.sample.label = +thing-type.nadreceiver.sample.description = + +# channel types +channel-type.nadreceiver.sample-channel.label = +channel-type.nadreceiver.sample-channel.description = diff --git a/src/main/resources/OH-INF/thing/channel_types.xml b/src/main/resources/OH-INF/thing/channel_types.xml new file mode 100644 index 0000000..10585a8 --- /dev/null +++ b/src/main/resources/OH-INF/thing/channel_types.xml @@ -0,0 +1,78 @@ + + + + + + String + + Model name of the device + Information + + + Switch + + Power on/off your device + Switch + + + Dimmer + + Volume level of the TV. + SoundVolume + + + Switch + + Mute state of the TV. + Switch + + + String + + Selected Tuner Band + Options + + + + + + + + + + Switch + + AM Tuner Mute + Options + + + Switch + + FM Tuner Mute + Options + + + Number:Frequency + + FM Tuner Frequency + Options + + + + Number:Frequency + + AM Tuner Frequency + Options + + + + + String + + Select the input source of the receiver + Options + + diff --git a/src/main/resources/OH-INF/thing/thing-types.xml b/src/main/resources/OH-INF/thing/thing-types.xml new file mode 100644 index 0000000..f729f4a --- /dev/null +++ b/src/main/resources/OH-INF/thing/thing-types.xml @@ -0,0 +1,28 @@ + + + + + + Thing for NadReceiver Binding + + + + + + + + + + + + + + + + + + + -- 2.45.2