added migrated 2.x add-ons

Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
Kai Kreuzer
2020-09-21 01:58:32 +02:00
parent bbf1a7fd29
commit 6df6783b60
11662 changed files with 1302875 additions and 11 deletions

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.lgtvserial</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.
* Project home: https://www.openhab.org
== Declared Project Licenses
This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.
== Source Code
https://github.com/openhab/openhab-addons

View File

@@ -0,0 +1,142 @@
# LG TV control using serial protocol
This binding can send some commands typically used by LG LCD TVs (and some used by projectors).
See below for a list of supported channels.
## Supported Things
Supports one TV or projector per thing, also corresponding to a unique serial port.
The protocol supports daisy-chaining of serial devices.
The LG serial command set appears to be similar on many models ([1], [5]), but not all commands will work on all models.
Some TVs may have an alternative port type instead of a standard DB9 connector, and may thus require an adapter.
The serial port may be marked "Service only".
Tested and developed with :
- LG 55UF772V (with [this cable adapter](https://www.ebay.com/itm/DB9-9-Pin-Female-To-TRS-3-5mm-Male-Stereo-Serial-Data-Converter-Cable-1-8M-6Ft-/291541959764?)).
- LG 47LK520 with a [serial hat](https://www.buyapi.ca/product/serial-hat-rs232/) on a Raspberry Pi
## Discovery
No discovery supported, manual configuration is required.
The things may be configured through the Paper UI.
## Thing Configuration
It is necessary to specify the serial port device used for communication.
On Linux systems, this will usually be either `/dev/ttyS0`, `/dev/ttyUSB0` or `/dev/ttyACM0` (or a higher number than `0` if multiple devices are present).
On Windows it will be `COM1`, `COM2`, etc.
The set id can also be specified when using daisy-chaining.
That allows you to have a thing that will handle a particular device (with set id other than 0), and another to send command on all devices (with set id equals 0).
However, the item values for the thing with set id 0 will never display the right values as it receives responses from many devices.
## Channels
The following channels are common to most TV through the serial or service port, taken from [4].
| Channel type id | Command | Item type | Description |
|-----------------|---------|-----------|--------------------------------------------------|
| aspect-ratio | k c | String | Adjust screen format, at least 4:3, 16:9 formats |
| power | k a | Switch | Turns the device on or off |
| volume | k f | Dimmer | Sets the volume, values are from 0 to 100 |
| volume-mute | k e | Switch | Set mute on or off |
As for others, please refer to the documentation of your device in the section named "Controlling the multiple product", "External control" or any section that refers to RS-232, the names of the channels map the command names.
If your device documentation doesn't give such information, you can look at the "LG protocol references" below and use the "Generic LG TV" thing which should contain all the different possible channels/commands.
Note: Devices might not respond or return an error to some command when the device is powered off which will make your items look in a wrong state until the TV turns on.
For instance, getting the volume status when the device is off makes no sense.
## All channel type ids
Here's a list of all the LG TV commands added to the binding, in channel type id alphabetic order
| Channel type id | Command | Item type | Description |
|--------------------|---------|-----------|-----------------------------------------------------|
| 3d | x t | String | To change 3D mode for tv |
| 2d-extended | x v | String | To change 3D options for tv |
| aspect-ratio | k c | String | To adjust the screen format |
| auto-sleep | f g | Switch | Set Auto Sleep |
| auto-volume | d u | Switch | Automatically adjust the volume level |
| speaker | d v | Switch | Turn the speaker on or off |
| backlight | m g | Dimmer | To adjust screen backlight |
| balance | k t | Dimmer | To adjust balance, from 0 to 100 |
| bass | k s | Dimmer | To adjust bass, from 0 to 100 |
| brightness | k h | Dimmer | To adjust screen brightness, from 0 to 100 |
| color | k i | Dimmer | To adjust screen color, from 0 to 100 |
| color-temperature | k u | String | To adjust the screen color temperature |
| color-temperature2 | x u | Dimmer | To adjust color temperature, from 0 to 100 |
| contrast | k g | Dimmer | To adjust screen contrast, from 0 to 100 |
| dpm | f j | Switch | Set the DPM (Display Power Management) function |
| energy-saving | j q | String | To control the energy saving function |
| fan-fault-check | d w | Switch | To check the Fan fault of the TV |
| elapsed-time | d l | String | To read the elapsed time |
| h-position | f q | Dimmer | To set the Horizontal position, from 0 to 100 |
| h-size | f s | Dimmer | To set the Horizontal size, from 0 to 100 |
| input | k b | String | To select input source for the Set |
| input2 | x b | String | To select input source for set |
| ism-method | j p | String | To avoid having a fixed image remain on screen |
| ir-key-code | m c | String | To send IR remote key code |
| lamp-fault-check | d p | Switch | To check lamp fault |
| power | k a | Switch | To control Power On/Off of the set |
| osd-select | k l | Switch | To select OSD (On Screen Display) on/off |
| osd-language | f i | String | Set the OSD language |
| natural-mode | d j | Switch | To assign the Tile Natural mode for Tiling function |
| picture-mode | d x | String | To adjust the picture mode |
| power-indicator | f o | Switch | To set the LED for Power Indicator |
| power-saving | f l | Switch | To set the Power saving mode |
| screen-mute | k d | String | To select screen mute on/off |
| serial-number | f y | String | To read the serial numbers |
| software-version | f z | String | Check the software version |
| sharpness | k k | Dimmer | To adjust screen sharpness, from 0 to 100 |
| sleep-time | f f | String | Set sleep time |
| sound-mode | d y | String | To adjust the Sound mode |
| speaker | d v | Switch | Turn the speaker on or off |
| temperature-value | d n | String | To read the inside temperature value |
| tile-mode | d d | String | Change a Tile mode |
| tile-h-position | d e | Dimmer | To set the Horizontal position, from 0 to 100 |
| tile-h-size | d g | Dimmer | To set the Horizontal size, from 0 to 100 |
| tile-id-set | d i | Dimmer | To assign the Tile ID for Tiling function, 0 to 25 |
| tile-v-position | d f | Dimmer | To set the Vertical position, from 0 to 100 |
| tile-v-size | d h | Dimmer | To set the Vertical size, from 0 to 100 |
| tint | k j | Dimmer | To adjust screen tint, from 0 to 100 |
| treble | k r | Dimmer | To adjust treble, from 0 to 100 |
| volume | k f | Dimmer | To adjust volume, from 0 to 100 |
| volume-mute | k e | Switch | Set mute on or off |
| v-position | f r | Dimmer | To set the Vertical position, from 0 to 100 |
| v-size | f t | Dimmer | To set the Vertical size, from 0 to 100 |
## Not added or linked command
| Channel type id | Command | Description
|--------------------|---------|------------------------------------------------------------------------------------------------------------|
| abnormal-state | k z | Used to Read the power off status when Stand-by mode |
| auto-configuration | j u | To adjust picture position and minimize image shaking automatically. it works only in RGB(PC) mode. |
| power-on-delay | f h | Set the schedule delay when the power is turned on (Unit: second) |
| remote-lock | k m | To control Remote Lock on/off to the set. Locks the remote control and the local keys. |
| reset | f k | Execute the Picture, Screen and Factory Reset functions |
| scheduled-input | f u | To select input source for TV depending on day |
| time | f a | Set the current time |
| on-timer-on-off | f b | Set days for On Timer |
| off-timer-on-off | f c | Set days for Off Timer |
| on-timer-time | f d | Set On Timer |
| off-timer-time | f e | Set Off Timer |
## LG protocol references
[1] <https://www.lg.com/us/commercial/documents/m6503ccba-owner-manual.pdf>
[2] <https://sites.google.com/site/brendanrobert/projects/bits-and-pieces/lg-tv-hacks>
[3] <https://code.google.com/archive/p/lg-tv-command/source/default/source>
[4] <https://github.com/suan/libLGTV_serial>
[5] Manual LV series, LK series, PW series and PZ series <http://gscs-b2c.lge.com/downloadFile?fileId=ujpO8yH69djwNZzwuavqpQ>
[6] Manual for LD series, LE series, LX series and PK series <http://gscs-b2c.lge.com/downloadFile?fileId=76If0tKDLOUizuoXikllgQ>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.binding.lgtvserial</artifactId>
<name>openHAB Add-ons :: Bundles :: LG TV Serial Binding</name>
</project>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.lgtvserial-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
<feature name="openhab-binding-lgtvserial" description="LG TV Serial Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-serial</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.lgtvserial/${project.version}</bundle>
</feature>
</features>

View File

@@ -0,0 +1,37 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;
/**
* The {@link LgTvSerialBinding} class defines common constants, which are
* used across the whole binding.
*
* @author Marius Bjoernstad - Initial contribution
* @author Richard Lavoie - Moved channels id to a factory class
*/
@NonNullByDefault
public class LgTvSerialBindingConstants {
public static final String BINDING_ID = "lgtvserial";
// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_LGTV_GENERIC = new ThingTypeUID(BINDING_ID, "lgtv");
public static final ThingTypeUID THING_TYPE_LGTV_LK_SERIES = new ThingTypeUID(BINDING_ID, "lgtv-LK-series");
public static final ThingTypeUID THING_TYPE_LGTV_LV_SERIES = new ThingTypeUID(BINDING_ID, "lgtv-LV-series");
public static final ThingTypeUID THING_TYPE_LGTV_LVX55_SERIES = new ThingTypeUID(BINDING_ID, "lgtv-LVx55-series");
public static final ThingTypeUID THING_TYPE_LGTV_M6503C = new ThingTypeUID(BINDING_ID, "lgtv-M6503C");
public static final ThingTypeUID THING_TYPE_LGTV_PW_SERIES = new ThingTypeUID(BINDING_ID, "lgtv-PW-series");
}

View File

@@ -0,0 +1,76 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal;
import static org.openhab.binding.lgtvserial.internal.LgTvSerialBindingConstants.*;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.lgtvserial.internal.handler.LgTvSerialHandler;
import org.openhab.binding.lgtvserial.internal.protocol.serial.SerialCommunicatorFactory;
import org.openhab.core.io.transport.serial.SerialPortManager;
import org.openhab.core.thing.Thing;
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;
/**
* The {@link LgTvSerialHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Marius Bjoernstad - Initial contribution
* @author Richard Lavoie - Added communicator to support daisy chained TV
*/
@NonNullByDefault
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.lgtvserial")
public class LgTvSerialHandlerFactory extends BaseThingHandlerFactory {
private static final SerialCommunicatorFactory FACTORY = new SerialCommunicatorFactory();
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(Stream
.of(THING_TYPE_LGTV_GENERIC, THING_TYPE_LGTV_LV_SERIES, THING_TYPE_LGTV_LVX55_SERIES,
THING_TYPE_LGTV_LK_SERIES, THING_TYPE_LGTV_M6503C, THING_TYPE_LGTV_PW_SERIES)
.collect(Collectors.toSet()));
private final SerialPortManager serialPortManager;
@Activate
public LgTvSerialHandlerFactory(final @Reference SerialPortManager serialPortManager) {
this.serialPortManager = serialPortManager;
}
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (supportsThingType(thingTypeUID)) {
return new LgTvSerialHandler(thing, FACTORY, serialPortManager);
}
return null;
}
}

View File

@@ -0,0 +1,235 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.handler;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialCommand;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialCommunicator;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponseListener;
import org.openhab.binding.lgtvserial.internal.protocol.serial.SerialCommunicatorFactory;
import org.openhab.binding.lgtvserial.internal.protocol.serial.commands.CommandFactory;
import org.openhab.core.io.transport.serial.PortInUseException;
import org.openhab.core.io.transport.serial.SerialPortIdentifier;
import org.openhab.core.io.transport.serial.SerialPortManager;
import org.openhab.core.io.transport.serial.UnsupportedCommOperationException;
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.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link LgTvSerialHandler} contains all the logic of this simple binding. It
* is responsible for handling commands and sending them to the serial port.
*
* @author Marius Bjoernstad - Initial contribution
* @author Richard Lavoie - Major rework to add many more channels and support daisy chaining
*/
public class LgTvSerialHandler extends BaseThingHandler {
/**
* Interval at which to send update refresh commands.
*/
private static final int EVENT_REFRESH_INTERVAL = 120;
/**
* Logger.
*/
private final Logger logger = LoggerFactory.getLogger(LgTvSerialHandler.class);
/**
* Serial communicator factory used to retrieve the communicator for a given port.
*/
private final SerialCommunicatorFactory factory;
/**
* Serial port manager used to get serial port identifiers.
*/
private final SerialPortManager serialPortManager;
/**
* Communicator used to send commands to the TV(s).
*/
private LGSerialCommunicator communicator;
/**
* List of linked items used for the refresh polling.
*/
private Map<ChannelUID, LGSerialCommand> channelCommands = Collections.synchronizedMap(new HashMap<>());
/**
* Set ID of this TV.
*/
private LGSerialResponseListener responseListener;
/**
* Polling updater job.
*/
private ScheduledFuture<?> updateJob;
/**
* Create the LG TV hander.
*
* @param thing Thing associated to this handler
* @param factory Factory to retrieve a communicator for a given port
*/
public LgTvSerialHandler(Thing thing, SerialCommunicatorFactory factory, SerialPortManager serialPortManager) {
super(thing);
this.factory = factory;
this.serialPortManager = serialPortManager;
}
@Override
public synchronized void initialize() {
String portName = (String) getThing().getConfiguration().get("port");
BigDecimal setIdParam = (BigDecimal) getThing().getConfiguration().get("setId");
int setId = 1;
if (setIdParam != null) {
setId = setIdParam.intValue();
}
final int set = setId;
responseListener = new LGSerialResponseListener() {
@Override
public int getSetID() {
return set;
}
@Override
public void onSuccess(ChannelUID channel, LGSerialResponse response) {
State state = response.getState();
logger.debug("Updating channel {} with value {}", channel, state);
updateState(channel, state);
}
@Override
public void onFailure(ChannelUID channel, LGSerialResponse response) {
logger.debug("Received error response for channel {}: {}", channel, response.getState());
}
};
if (portName != null) {
SerialPortIdentifier serialPortIdentifier = serialPortManager.getIdentifier(portName);
if (serialPortIdentifier == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Serial port does not exist: " + portName);
return;
}
try {
communicator = factory.getInstance(serialPortIdentifier);
} catch (IOException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
return;
} catch (PortInUseException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Serial port already used: " + portName);
return;
} catch (UnsupportedCommOperationException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Unsupported operation on '" + portName + "': " + e.getMessage());
return;
}
if (communicator != null) {
communicator.register(responseListener);
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Failed to connect to serial port " + portName);
logger.debug("Failed to connect to serial port {}", portName);
return;
}
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Serial port name not configured");
logger.debug("Serial port name not configured");
return;
}
if (updateJob == null || updateJob.isCancelled()) {
updateJob = scheduler.scheduleWithFixedDelay(eventRunnable, 0, EVENT_REFRESH_INTERVAL, TimeUnit.SECONDS);
}
updateStatus(ThingStatus.ONLINE);
}
@Override
public synchronized void dispose() {
if (updateJob != null && !updateJob.isCancelled()) {
updateJob.cancel(true);
updateJob = null;
}
if (communicator != null) {
communicator.unregister(responseListener);
}
}
@Override
public void channelLinked(ChannelUID channelUID) {
LGSerialCommand command = CommandFactory.createCommandFor(channelUID, responseListener);
if (command == null) {
logger.warn(
"A command could not be found for channel name '{}'. Please create an issue on the openhab project for the lgtvserial binding. ",
channelUID.getId());
return;
}
this.channelCommands.put(channelUID, command);
handleCommand(channelUID, RefreshType.REFRESH);
}
@Override
public void channelUnlinked(ChannelUID channelUID) {
this.channelCommands.remove(channelUID);
}
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
try {
if (command instanceof RefreshType) {
channelCommands.get(channelUID).execute(channelUID, communicator, null);
} else {
channelCommands.get(channelUID).execute(channelUID, communicator, command);
}
} catch (IOException e) {
logger.warn("Serial port write error", e);
}
}
private Runnable eventRunnable = () -> {
synchronized (channelCommands) {
for (Map.Entry<ChannelUID, LGSerialCommand> entry : channelCommands.entrySet()) {
if (Thread.currentThread().isInterrupted()) {
logger.debug("Thread interrupted, stopping");
break;
}
try {
entry.getValue().execute(entry.getKey(), communicator, null);
} catch (IOException e) {
logger.warn("An error occured while sending an update command for {}: {}", entry.getKey(),
e.getMessage());
}
}
}
};
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial;
import java.io.IOException;
import org.openhab.core.thing.ChannelUID;
/**
* This interface represents an LG serial command.
*
* @author Richard Lavoie - Initial contribution
*/
public interface LGSerialCommand {
/**
* Parse the response string into a response object. If null is returned, it means the result cannot be used to
* update a linked item state. This is useful to have one way commands.
*
* @param response Response to parse
* @return Response object
*/
LGSerialResponse parseResponse(String response);
/**
* This method is used to send the serial protocol command to the communicator.
*
* @param channel Channel related to the command
* @param comm Communicator linked to the serial port
* @param data Data related to this command to send over the wire. If null, this means we should send an FF state
* read command.
* @throws IOException
*/
void execute(ChannelUID channel, LGSerialCommunicator comm, Object data) throws IOException;
}

View File

@@ -0,0 +1,156 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.openhab.core.io.transport.serial.PortInUseException;
import org.openhab.core.io.transport.serial.SerialPort;
import org.openhab.core.io.transport.serial.SerialPortIdentifier;
import org.openhab.core.io.transport.serial.UnsupportedCommOperationException;
import org.openhab.core.thing.ChannelUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class handles the communication (read/writes) between the COM port and the things.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class LGSerialCommunicator {
private OutputStream output;
private InputStream input;
private SerialPort port;
private Map<Integer, LGSerialResponseListener> handlers = new HashMap<>();
private RegistrationCallback callback;
private byte[] buffer = new byte[1024];
/**
* Logger.
*/
private final Logger logger = LoggerFactory.getLogger(LGSerialCommunicator.class);
private static final int BAUD_RATE = 9600;
public LGSerialCommunicator(SerialPortIdentifier serialPortIdentifier, RegistrationCallback callback)
throws IOException, PortInUseException, UnsupportedCommOperationException {
SerialPort port = serialPortIdentifier.open(LGSerialCommunicator.class.getCanonicalName(), 2000);
port.setSerialPortParams(BAUD_RATE, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
this.port = port;
this.output = port.getOutputStream();
this.input = port.getInputStream();
this.callback = callback;
}
public synchronized void write(LGSerialCommand command, String rawCommand, ChannelUID channel) throws IOException {
logger.debug("Sending command : {}", rawCommand);
output.write(rawCommand.getBytes());
output.write('\r');
output.flush();
// Let's wait not to spam the TV too much
try {
Thread.sleep(500);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException(e);
}
int data;
int len = 0;
int offset = 0;
while ((data = input.read()) > -1) {
if (data == 'x') {
String result = new String(buffer, offset, len);
if (logger.isDebugEnabled()) {
logger.debug("Buffer : {} offset={} len={}", Arrays.toString(buffer), offset, len);
logger.debug("Received response : {}", result);
}
LGSerialResponse response = command.parseResponse(result);
updateHandler(response, channel);
offset += len;
len = 0;
} else {
if (offset + len == buffer.length) {
byte[] newBuffer = new byte[1024];
System.arraycopy(buffer, offset, newBuffer, 0, len);
buffer = newBuffer;
}
buffer[offset + len++] = (byte) data;
}
}
}
/**
* Forward the response to the proper response handler, if a response was given.
*
* @param response Serial response
* @param channel Channel to update
*/
private void updateHandler(LGSerialResponse response, ChannelUID channel) {
if (response != null) {
LGSerialResponseListener listener = handlers.get(response.getSetID());
if (listener != null) {
if (response.isSuccess()) {
listener.onSuccess(channel, response);
} else {
listener.onFailure(channel, response);
}
}
}
}
public synchronized void register(LGSerialResponseListener listener) {
handlers.put(listener.getSetID(), listener);
}
public synchronized void unregister(LGSerialResponseListener listener) {
handlers.remove(listener.getSetID());
if (handlers.isEmpty()) {
callback.onUnregister();
}
}
public void close() {
try {
input.close();
} catch (IOException e) {
logger.debug("An error occured while closing the serial input stream", e);
}
try {
output.close();
} catch (IOException e) {
logger.debug("An error occured while closing the serial output stream", e);
}
port.close();
// For some reason, there needs some delay after close so we don't fail to open back the serial device
// TODO : investigate if this is still a real issue with the serial transport
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.debug("Thread interrupted while closing the communicator");
}
}
}

View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial;
import org.openhab.core.types.State;
/**
* This interface represents the information from a response received and parsed to a State object from the device.
*
* @author Richard Lavoie - Initial contribution
*
*/
public interface LGSerialResponse {
int getSetID();
State getState();
boolean isSuccess();
}

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial;
import org.openhab.core.thing.ChannelUID;
/**
* This interface represents a listener that will handle the transition after the response
* from the device is received to update the items.
*
* @author Richard Lavoie - Initial contribution
*
*/
public interface LGSerialResponseListener {
int getSetID();
void onSuccess(ChannelUID channel, LGSerialResponse response);
void onFailure(ChannelUID channel, LGSerialResponse response);
}

View File

@@ -0,0 +1,23 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial;
/**
*
* @author Richard Lavoie - Initial contribution
*
*/
public interface RegistrationCallback {
void onUnregister();
}

View File

@@ -0,0 +1,63 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.openhab.core.io.transport.serial.PortInUseException;
import org.openhab.core.io.transport.serial.SerialPortIdentifier;
import org.openhab.core.io.transport.serial.UnsupportedCommOperationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class is used to create and reuse singleton objects associated to a given COM port.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class SerialCommunicatorFactory {
private final Logger logger = LoggerFactory.getLogger(SerialCommunicatorFactory.class);
private Map<SerialPortIdentifier, LGSerialCommunicator> instances = new HashMap<>();
public synchronized LGSerialCommunicator getInstance(SerialPortIdentifier serialPortIdentifier)
throws IOException, PortInUseException, UnsupportedCommOperationException {
LGSerialCommunicator comm = instances.get(serialPortIdentifier);
if (comm == null) {
comm = createCommunicator(serialPortIdentifier);
if (comm != null) {
instances.put(serialPortIdentifier, comm);
}
}
return comm;
}
private LGSerialCommunicator createCommunicator(final SerialPortIdentifier serialPortIdentifier)
throws IOException, PortInUseException, UnsupportedCommOperationException {
return new LGSerialCommunicator(serialPortIdentifier, new RegistrationCallback() {
@Override
public void onUnregister() {
logger.debug("Unregistered last handler, closing");
deleteInstance(serialPortIdentifier);
}
});
}
protected synchronized void deleteInstance(SerialPortIdentifier serialPortIdentifier) {
instances.remove(serialPortIdentifier).close();
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the aspect ratio K/C command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class AspectRatioCommand extends BaseStringCommand {
protected AspectRatioCommand(int setId) {
super('k', 'c', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command represents the auto sleep F/G command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class AutoSleepCommand extends BaseDecimalCommand {
protected AutoSleepCommand(int setId) {
super('f', 'g', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the auto volume D/U command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class AutoVolumeCommand extends BaseOnOffCommand {
protected AutoVolumeCommand(int setId) {
super('d', 'u', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the screen backlight M/G command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class BacklightCommand extends BasePercentCommand {
protected BacklightCommand(int setId) {
super('m', 'g', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the balance K/T command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class BalanceCommand extends BasePercentCommand {
protected BalanceCommand(int setId) {
super('k', 't', setId);
}
}

View File

@@ -0,0 +1,61 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.binding.lgtvserial.internal.protocol.serial.responses.DecimalResponse;
import org.openhab.core.library.types.DecimalType;
/**
* This command is the base command to handle decimal type commands in hex format on the wire.
*
* @author Richard Lavoie - Initial contribution
*
*/
public abstract class BaseDecimalCommand extends BaseLGSerialCommand {
/**
* Create a command.
*
* @param command1 Command category
* @param command2 Command key
* @param setId TV Set id this command is tied to
* @param updatable Define if this command is one that can update the TV or can only ever be a read status command.
*/
protected BaseDecimalCommand(char command1, char command2, int setId, boolean updatable) {
super(command1, command2, setId, updatable);
}
/**
* Create a command that can update the TV.
*
* @param command1 Command category
* @param command2 Command key
* @param setId TV Set id this command is tied to
*/
protected BaseDecimalCommand(char command1, char command2, int setId) {
super(command1, command2, setId, true);
}
@Override
protected String computeSerialDataFrom(Object data) {
return String.format("%02x", ((DecimalType) data).intValue());
}
@Override
protected LGSerialResponse createResponse(int set, boolean success, String data) {
String decimalValue = Integer.toString(Integer.parseInt(data, 16));
return new DecimalResponse(set, success, DecimalType.valueOf(decimalValue));
}
}

View File

@@ -0,0 +1,81 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import java.io.IOException;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialCommand;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialCommunicator;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.binding.lgtvserial.internal.protocol.serial.responses.StringResponse;
import org.openhab.core.thing.ChannelUID;
/**
* This class represents the base for most, if not all, LG commands.
*
* It consists of :
* - the command1 character which represents the command group
* - the command2 character which represents the command in the group
* - the setid which represents the device to target defined by the protocol, 0 means it will target all devices
* - updatable which represents if this command can actually change the device state, or can only retrieve it's state
* from the device.
*
* @author Richard Lavoie - Initial contribution
*
*/
public abstract class BaseLGSerialCommand implements LGSerialCommand {
private char command1;
private char command2;
private int setId;
private boolean updatable;
public BaseLGSerialCommand(char command1, char command2, int setId, boolean updatable) {
this.command1 = command1;
this.command2 = command2;
this.setId = setId;
this.updatable = true;
}
@Override
public void execute(ChannelUID channel, LGSerialCommunicator comm, Object data) throws IOException {
if (!updatable && data != null) {
throw new IllegalArgumentException("This command cannot set any data on the TV, " //
+ "the only allowed value is null, got : " + data);
}
comm.write(this, getCommand(data), channel);
}
@Override
public LGSerialResponse parseResponse(String response) {
int set = Integer.parseInt(response.substring(2, 4), 16);
boolean success = 'O' == response.charAt(5) && 'K' == response.charAt(6);
String data = response.substring(7);
if (!success) {
return new StringResponse(set, success, data);
}
return createResponse(set, success, data);
}
protected abstract LGSerialResponse createResponse(int set, boolean success, String data);
protected String getCommand(Object data) {
return command1 + "" + command2 + " " + String.format("%02x", setId) + " "
+ (data == null ? "FF" : computeSerialDataFrom(data));
}
protected abstract String computeSerialDataFrom(Object data);
}

View File

@@ -0,0 +1,40 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.binding.lgtvserial.internal.protocol.serial.responses.OnOffResponse;
import org.openhab.core.library.types.OnOffType;
/**
* This command is the base command for the On/Off type command which translates to 00/01 on the wire.
*
* @author Richard Lavoie - Initial contribution
*
*/
public abstract class BaseOnOffCommand extends BaseLGSerialCommand {
protected BaseOnOffCommand(char command1, char command2, int setId) {
super(command1, command2, setId, true);
}
@Override
protected String computeSerialDataFrom(Object data) {
return data == OnOffType.ON ? "01" : "00";
}
@Override
protected LGSerialResponse createResponse(int set, boolean success, String data) {
return new OnOffResponse(set, success, data);
}
}

View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.binding.lgtvserial.internal.protocol.serial.responses.PercentResponse;
import org.openhab.core.library.types.PercentType;
/**
* This command is the base command to handle percent type commands (0-100) in hex format on the wire.
*
* @author Richard Lavoie - Initial contribution
*
*/
public abstract class BasePercentCommand extends BaseLGSerialCommand {
protected BasePercentCommand(char command1, char command2, int setId) {
super(command1, command2, setId, true);
}
@Override
protected String computeSerialDataFrom(Object data) {
return Integer.toHexString(((PercentType) data).intValue());
}
@Override
protected LGSerialResponse createResponse(int set, boolean success, String data) {
String decimalValue = Integer.toString(Integer.parseInt(data, 16));
return new PercentResponse(set, success, PercentType.valueOf(decimalValue));
}
}

View File

@@ -0,0 +1,51 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.binding.lgtvserial.internal.protocol.serial.responses.StringResponse;
/**
* This command is the base command for the On/Off type command which translates to 00/01 on the wire.
*
* @author Richard Lavoie - Initial contribution
*
*/
public abstract class BaseStringCommand extends BaseLGSerialCommand {
protected BaseStringCommand(char command1, char command2, int setId) {
super(command1, command2, setId, true);
}
public BaseStringCommand(char command1, char command2, int setId, boolean updatable) {
super(command1, command2, setId, updatable);
}
@Override
public LGSerialResponse parseResponse(String response) {
int set = Integer.parseInt(response.substring(2, 4), 16);
boolean success = 'O' == response.charAt(5) && 'K' == response.charAt(6);
return new StringResponse(set, success, response.substring(7));
}
@Override
protected String computeSerialDataFrom(Object data) {
return data.toString();
}
@Override
protected LGSerialResponse createResponse(int set, boolean success, String data) {
return new StringResponse(set, success, data);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the bass K/S command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class BassCommand extends BasePercentCommand {
protected BassCommand(int setId) {
super('k', 's', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the brightness K/H command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class BrightnessCommand extends BasePercentCommand {
protected BrightnessCommand(int setId) {
super('k', 'h', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the color K/I command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class ColorCommand extends BasePercentCommand {
protected ColorCommand(int setId) {
super('k', 'i', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the color temperature X/U command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class ColorTemperature2Command extends BasePercentCommand {
protected ColorTemperature2Command(int setId) {
super('x', 'u', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the color temperature K/U command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class ColorTemperatureCommand extends BaseStringCommand {
protected ColorTemperatureCommand(int setId) {
super('k', 'u', setId);
}
}

View File

@@ -0,0 +1,140 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialCommand;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponseListener;
import org.openhab.core.thing.ChannelUID;
/**
* This class is used to convert a channel id to it's corresponding class command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class CommandFactory {
public static LGSerialCommand createCommandFor(ChannelUID channel, LGSerialResponseListener listener) {
int setId = listener.getSetID();
String name = channel.getId();
switch (name) {
case "3d":
return new LG3DCommand(setId);
case "3d-extended":
return new LG3DExtendedCommand(setId);
case "aspect-ratio":
return new AspectRatioCommand(setId);
case "auto-sleep":
return new AutoSleepCommand(setId);
case "auto-volume":
return new AutoVolumeCommand(setId);
case "backlight":
return new BacklightCommand(setId);
case "balance":
return new BalanceCommand(setId);
case "bass":
return new BassCommand(setId);
case "brightness":
return new BrightnessCommand(setId);
case "color":
return new ColorCommand(setId);
case "color-temperature":
return new ColorTemperatureCommand(setId);
case "color-temperature2":
return new ColorTemperature2Command(setId);
case "contrast":
return new ContrastCommand(setId);
case "dpm":
return new DPMCommand(setId);
case "elapsed-time":
return new ElapsedTimeCommand(setId);
case "energy-saving":
return new EnergySavingCommand(setId);
case "fan-fault-check":
return new FanFaultCheckCommand(setId);
case "h-position":
return new HPositionCommand(setId);
case "h-size":
return new HSizeCommand(setId);
case "input":
return new InputSelectCommand(setId);
case "input2":
return new InputSelect2Command(setId);
case "ir-key-code":
return new IRKeyCodeCommand(setId);
case "ism-method":
return new ISMMethodCommand(setId);
case "lamp-fault-check":
return new LampFaultCheckCommand(setId);
case "natural-mode":
return new NaturalModeCommand(setId);
case "osd-language":
return new OSDLanguageCommand(setId);
case "osd-select":
return new OSDSelectCommand(setId);
case "picture-mode":
return new PictureModeCommand(setId);
case "power":
return new PowerCommand(setId);
case "power-indicator":
return new PowerIndicatorCommand(setId);
case "power-saving":
return new PowerSavingCommand(setId);
case "raw":
return new RawCommand();
case "screen-mute":
return new ScreenMuteCommand(setId);
case "serial-number":
return new SerialNoCommand(setId);
case "sharpness":
return new SharpnessCommand(setId);
case "sleep-time":
return new SleepTimeCommand(setId);
case "software-version":
return new SoftwareVersionCommand(setId);
case "sound-mode":
return new SoundModeCommand(setId);
case "speaker":
return new SpeakerCommand(setId);
case "temperature-value":
return new TemperatureValueCommand(setId);
case "tile":
return new TileCommand(setId);
case "tile-h-position":
return new TileHPositionCommand(setId);
case "tile-h-size":
return new TileHSizeCommand(setId);
case "tile-id-set":
return new TileIdSetCommand(setId);
case "tile-v-position":
return new TileVPositionCommand(setId);
case "tile-v-size":
return new TileVSizeCommand(setId);
case "time":
return new TimeCommand(setId);
case "tint":
return new TintCommand(setId);
case "treble":
return new TrebleCommand(setId);
case "volume":
return new VolumeCommand(setId);
case "volume-mute":
return new VolumeMuteCommand(setId);
case "v-position":
return new VPositionCommand(setId);
case "v-size":
return new VSizeCommand(setId);
}
return null;
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the contrast K/G command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class ContrastCommand extends BasePercentCommand {
protected ContrastCommand(int setId) {
super('k', 'g', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the DPM F/J command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class DPMCommand extends BaseOnOffCommand {
protected DPMCommand(int setId) {
super('f', 'j', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the elapsed time D/L command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class ElapsedTimeCommand extends BaseDecimalCommand {
protected ElapsedTimeCommand(int setId) {
super('d', 'l', setId, false);
}
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialCommand;
/**
* This class handles the energy saving J/Q command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class EnergySavingCommand extends BaseStringCommand implements LGSerialCommand {
protected EnergySavingCommand(int setId) {
super('j', 'q', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the fan fault check command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class FanFaultCheckCommand extends BaseStringCommand {
protected FanFaultCheckCommand(int setId) {
super('d', 'w', setId, false);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the h-position F/Q command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class HPositionCommand extends BasePercentCommand {
protected HPositionCommand(int setId) {
super('f', 'q', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the h-size command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class HSizeCommand extends BasePercentCommand {
protected HSizeCommand(int setId) {
super('f', 's', setId);
}
}

View File

@@ -0,0 +1,44 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import java.io.IOException;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialCommunicator;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.core.thing.ChannelUID;
/**
* This command handles the IR key code M/C command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class IRKeyCodeCommand extends BaseStringCommand {
protected IRKeyCodeCommand(int setId) {
super('m', 'c', setId);
}
@Override
public void execute(ChannelUID channel, LGSerialCommunicator comm, Object data) throws IOException {
if (data != null) {
super.execute(channel, comm, data);
}
}
@Override
public LGSerialResponse parseResponse(String response) {
return null;
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the ISM method command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class ISMMethodCommand extends BaseStringCommand {
protected ISMMethodCommand(int setId) {
super('j', 'p', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the input select X/B command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class InputSelect2Command extends BaseStringCommand {
protected InputSelect2Command(int setId) {
super('x', 'b', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the input select K/B command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class InputSelectCommand extends BaseStringCommand {
protected InputSelectCommand(int setId) {
super('k', 'b', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the X/T command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class LG3DCommand extends BaseStringCommand {
protected LG3DCommand(int setId) {
super('x', 't', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the extended 3D X/V command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class LG3DExtendedCommand extends BaseStringCommand {
protected LG3DExtendedCommand(int setId) {
super('x', 'v', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the lamp fault check D/P command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class LampFaultCheckCommand extends BaseStringCommand {
protected LampFaultCheckCommand(int setId) {
super('d', 'p', setId, false);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the natural mode D/J command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class NaturalModeCommand extends BaseOnOffCommand {
protected NaturalModeCommand(int setId) {
super('d', 'j', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the OSD language F/I command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class OSDLanguageCommand extends BaseStringCommand {
protected OSDLanguageCommand(int setId) {
super('f', 'i', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the osd select K/L command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class OSDSelectCommand extends BaseOnOffCommand {
protected OSDSelectCommand(int setId) {
super('k', 'l', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the picture mode D/X command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class PictureModeCommand extends BaseStringCommand {
protected PictureModeCommand(int setId) {
super('d', 'x', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the power K/A command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class PowerCommand extends BaseOnOffCommand {
protected PowerCommand(int setId) {
super('k', 'a', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the power indicator F/O command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class PowerIndicatorCommand extends BaseOnOffCommand {
protected PowerIndicatorCommand(int setId) {
super('f', 'o', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the power saving F/L command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class PowerSavingCommand extends BaseStringCommand {
protected PowerSavingCommand(int setId) {
super('f', 'l', setId);
}
}

View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import java.io.IOException;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialCommand;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialCommunicator;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.core.thing.ChannelUID;
/**
* This command handles a raw command to be sent to the device.
*
* This proves useful when a command is not implemented yet to be able to send commands yourselves with the proper
* format.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class RawCommand implements LGSerialCommand {
@Override
public LGSerialResponse parseResponse(String response) {
return null;
}
@Override
public void execute(ChannelUID channel, LGSerialCommunicator comm, Object data) throws IOException {
// No read request possible
if (data != null) {
comm.write(this, data.toString(), channel);
}
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the screen mute K/D command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class ScreenMuteCommand extends BaseStringCommand {
protected ScreenMuteCommand(int setId) {
super('k', 'd', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the serial number F/Y command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class SerialNoCommand extends BaseStringCommand {
protected SerialNoCommand(int setId) {
super('f', 'y', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the sharpness K/K command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class SharpnessCommand extends BasePercentCommand {
protected SharpnessCommand(int setId) {
super('k', 'k', setId);
}
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the sleep time F/F command.
*
* TODO : Yet to be fully implemented
*
* @author Richard Lavoie - Initial contribution
*
*/
public class SleepTimeCommand extends BaseDecimalCommand {
protected SleepTimeCommand(int setId) {
super('f', 'f', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the software version F/Z command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class SoftwareVersionCommand extends BaseStringCommand {
protected SoftwareVersionCommand(int setId) {
super('f', 'z', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the sound mode D/Y command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class SoundModeCommand extends BaseStringCommand {
protected SoundModeCommand(int setId) {
super('d', 'y', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the speaker D/V command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class SpeakerCommand extends BaseOnOffCommand {
protected SpeakerCommand(int setId) {
super('d', 'v', setId);
}
}

View File

@@ -0,0 +1,36 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.binding.lgtvserial.internal.protocol.serial.responses.QuantityResponse;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.SIUnits;
/**
* This class handles the temperature value D/N command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TemperatureValueCommand extends BaseDecimalCommand {
protected TemperatureValueCommand(int setId) {
super('d', 'n', setId, false);
}
@Override
protected LGSerialResponse createResponse(int set, boolean success, String data) {
return new QuantityResponse(set, success, new QuantityType<>(Integer.parseInt(data, 16), SIUnits.CELSIUS));
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the tile D/D command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TileCommand extends BaseStringCommand {
protected TileCommand(int setId) {
super('d', 'd', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the tile-h-position D/E command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TileHPositionCommand extends BasePercentCommand {
protected TileHPositionCommand(int setId) {
super('d', 'e', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the tile-h-size D/G command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TileHSizeCommand extends BasePercentCommand {
protected TileHSizeCommand(int setId) {
super('d', 'g', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the tile-id-set command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TileIdSetCommand extends BaseStringCommand {
protected TileIdSetCommand(int setId) {
super('d', 'i', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the tile-v-position D/V command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TileVPositionCommand extends BasePercentCommand {
protected TileVPositionCommand(int setId) {
super('d', 'v', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the tile-v-size D/H command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TileVSizeCommand extends BasePercentCommand {
protected TileVSizeCommand(int setId) {
super('d', 'h', setId);
}
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the time F/A command.
*
* TODO Have no clue yet how to implement this.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TimeCommand extends BaseStringCommand {
protected TimeCommand(int setId) {
super('f', 'a', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles tint K/J command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TintCommand extends BasePercentCommand {
protected TintCommand(int setId) {
super('k', 'j', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the treble K/R command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class TrebleCommand extends BasePercentCommand {
protected TrebleCommand(int setId) {
super('k', 'r', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the v-position F/R command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class VPositionCommand extends BasePercentCommand {
protected VPositionCommand(int setId) {
super('f', 'r', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This command handles the v-size F/T command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class VSizeCommand extends BasePercentCommand {
protected VSizeCommand(int setId) {
super('f', 't', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the volume K/F command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class VolumeCommand extends BasePercentCommand {
protected VolumeCommand(int setId) {
super('k', 'f', setId);
}
}

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.commands;
/**
* This class handles the volume mute K/E command.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class VolumeMuteCommand extends BaseOnOffCommand {
protected VolumeMuteCommand(int setId) {
super('k', 'e', setId);
}
}

View File

@@ -0,0 +1,53 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.responses;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.types.State;
/**
* This class represents a decimal response.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class DecimalResponse implements LGSerialResponse {
private int setId;
private boolean success;
private State state;
public DecimalResponse(int setId, boolean success, DecimalType state) {
this.setId = setId;
this.success = success;
this.state = state;
}
@Override
public int getSetID() {
return setId;
}
@Override
public State getState() {
return state;
}
@Override
public boolean isSuccess() {
return success;
}
}

View File

@@ -0,0 +1,59 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.responses;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.types.State;
/**
* This class represents an ON/OFF response.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class OnOffResponse implements LGSerialResponse {
private int setId;
private boolean success;
private State state;
public OnOffResponse(int setId, boolean success, String data) {
this.setId = setId;
this.success = success;
if (success) {
state = data.equals("01") ? OnOffType.ON : OnOffType.OFF;
} else {
state = new StringType(data);
}
}
@Override
public int getSetID() {
return setId;
}
@Override
public State getState() {
return state;
}
@Override
public boolean isSuccess() {
return success;
}
}

View File

@@ -0,0 +1,53 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.responses;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.types.State;
/**
* This class represents a percentage response.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class PercentResponse implements LGSerialResponse {
private int setId;
private boolean success;
private State state;
public PercentResponse(int setId, boolean success, PercentType state) {
this.setId = setId;
this.success = success;
this.state = state;
}
@Override
public int getSetID() {
return setId;
}
@Override
public State getState() {
return state;
}
@Override
public boolean isSuccess() {
return success;
}
}

View File

@@ -0,0 +1,53 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.responses;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.types.State;
/**
* This class represents a percentage response.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class QuantityResponse implements LGSerialResponse {
private int setId;
private boolean success;
private State state;
public QuantityResponse(int setId, boolean success, QuantityType<?> state) {
this.setId = setId;
this.success = success;
this.state = state;
}
@Override
public int getSetID() {
return setId;
}
@Override
public State getState() {
return state;
}
@Override
public boolean isSuccess() {
return success;
}
}

View File

@@ -0,0 +1,53 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.lgtvserial.internal.protocol.serial.responses;
import org.openhab.binding.lgtvserial.internal.protocol.serial.LGSerialResponse;
import org.openhab.core.library.types.StringType;
import org.openhab.core.types.State;
/**
* This class represents a STRING state response.
*
* @author Richard Lavoie - Initial contribution
*
*/
public class StringResponse implements LGSerialResponse {
private int setId;
private boolean success;
private State state;
public StringResponse(int setId, boolean success, String data) {
this.setId = setId;
this.success = success;
state = new StringType(data);
}
@Override
public int getSetID() {
return setId;
}
@Override
public State getState() {
return state;
}
@Override
public boolean isSuccess() {
return success;
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="lgtvserial" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">
<name>LG TV Serial Binding</name>
<description>Controlling LG TVs using serial (RS232C) protocol</description>
<author>Marius Bjoernstad</author>
</binding:binding>

View File

@@ -0,0 +1,21 @@
<config-description:config-descriptions
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:config-description="https://openhab.org/schemas/config-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0
https://openhab.org/schemas/config-description-1.0.0.xsd">
<config-description uri="thing-type:lgtvserial:serial">
<parameter name="port" type="text">
<context>serial-port</context>
<limitToOptions>false</limitToOptions>
<label>Serial Port</label>
<description>Select serial port (COM1, /dev/ttyS0, ...)</description>
<required>true</required>
</parameter>
<parameter name="setId" type="integer">
<label>Set ID</label>
<description>Set ID configured in the TV. If 0, this will send a command to every chained TV.</description>
<required>true</required>
<default>1</default>
</parameter>
</config-description>
</config-description:config-descriptions>

View File

@@ -0,0 +1,568 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="lgtvserial"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<channel-type id="3d">
<item-type>String</item-type>
<label>3d</label>
<description>Change the 3d mode, if your TV supports it</description>
</channel-type>
<channel-type id="3d-extended">
<item-type>String</item-type>
<label>3d Extended</label>
<description>Change the 3d option, if your TV supports it</description>
</channel-type>
<channel-type id="aspect-ratio">
<item-type>String</item-type>
<label>Aspect Ratio</label>
<description>Adjust the screen format</description>
<state>
<options>
<option value="01">4:3</option>
<option value="02">16:9</option>
<option value="04">Zoom</option>
<option value="06">Set by program</option>
<option value="09">Just scan</option>
<option value="10">Cinema Zoom 1</option>
<option value="11">Cinema Zoom 2</option>
<option value="12">Cinema Zoom 3</option>
<option value="13">Cinema Zoom 4</option>
<option value="14">Cinema Zoom 5</option>
<option value="15">Cinema Zoom 6</option>
<option value="16">Cinema Zoom 7</option>
<option value="17">Cinema Zoom 8</option>
<option value="18">Cinema Zoom 9</option>
<option value="19">Cinema Zoom 10</option>
<option value="1A">Cinema Zoom 11</option>
<option value="1B">Cinema Zoom 12</option>
<option value="1C">Cinema Zoom 13</option>
<option value="1D">Cinema Zoom 14</option>
<option value="1E">Cinema Zoom 15</option>
<option value="1F">Cinema Zoom 16</option>
</options>
</state>
</channel-type>
<channel-type id="auto-sleep">
<item-type>Switch</item-type>
<label>Auto Sleep</label>
<description>Set Auto Sleep</description>
</channel-type>
<channel-type id="auto-volume">
<item-type>Switch</item-type>
<label>Auto Volume</label>
<description>Automatically adjust the volume level</description>
</channel-type>
<channel-type id="backlight">
<item-type>Dimmer</item-type>
<label>Backlight</label>
<description>Display backlight brightness</description>
</channel-type>
<channel-type id="balance">
<item-type>Dimmer</item-type>
<label>Balance</label>
<description>Adjust balance</description>
</channel-type>
<channel-type id="bass">
<item-type>Dimmer</item-type>
<label>Bass</label>
<description>Adjust bass</description>
</channel-type>
<channel-type id="brightness">
<item-type>Dimmer</item-type>
<label>Brightness</label>
<description>Adjust screen brightness</description>
</channel-type>
<channel-type id="contrast">
<item-type>Dimmer</item-type>
<label>Contrast</label>
<description>Contrast</description>
</channel-type>
<channel-type id="color">
<item-type>Dimmer</item-type>
<label>Color</label>
<description>Adjust screen color</description>
</channel-type>
<channel-type id="color-temperature">
<item-type>String</item-type>
<label>Color Temperature</label>
<description>Color temperature of the display</description>
<state>
<options>
<option value="0">Cool</option>
<option value="1">Normal</option>
<option value="2">Warm</option>
</options>
</state>
</channel-type>
<channel-type id="color-temperature2">
<item-type>Dimmer</item-type>
<label>Color Temperature</label>
<description>Color temperature of the display (between 0 and 100)</description>
</channel-type>
<channel-type id="dpm">
<item-type>Switch</item-type>
<label>DPM Select</label>
<description>Set the DPM (Display Power Management) function</description>
</channel-type>
<channel-type id="elapsed-time">
<item-type>String</item-type>
<label>Elapsed Time</label>
<description>Read the elapsed time</description>
</channel-type>
<channel-type id="energy-saving">
<item-type>String</item-type>
<label>Energy Saving</label>
<description>Control the energy saving function</description>
<state>
<options>
<option value="00">Off</option>
<option value="01">Minimum</option>
<option value="02">Medium</option>
<option value="03">Maximum</option>
<option value="04">Auto/Intelligent sensor (depending on model)</option>
<option value="05">Screen off</option>
</options>
</state>
</channel-type>
<channel-type id="fan-fault-check">
<item-type>String</item-type>
<label>Fan Fault</label>
<description>Check the fan fault of the TV</description>
<state readOnly="true">
<options>
<option value="0">Fan fault</option>
<option value="1">Fan OK</option>
<option value="2">N/A(Not Available)</option>
</options>
</state>
</channel-type>
<channel-type id="h-position">
<item-type>Dimmer</item-type>
<label>H Position</label>
<description>Set the horizontal position</description>
</channel-type>
<channel-type id="input">
<item-type>String</item-type>
<label>Input</label>
<description>Input select</description>
<state>
<options>
<option value="00">DTV (Antenna)</option>
<option value="01">DTV (cable)</option>
<option value="02">AV</option> <!-- Found in M6503C -->
<option value="04">Component</option> <!-- Found in M6503C -->
<option value="07">RGB (PC)</option> <!-- Found in M6503C -->
<option value="08">HDMI (DTV)</option> <!-- Found in M6503C -->
<option value="09">HDMI (PC)</option> <!-- Found in M6503C -->
<option value="10">Analog (Antenna)</option>
<option value="11">Analog (Cable)</option>
<option value="20">AV or AV1</option>
<option value="21">AV2</option>
<option value="40">Component or Component1</option>
<option value="41">Component2</option>
<option value="60">RGB-PC</option>
<option value="90">HDMI1</option>
<option value="91">HDMI2</option>
<option value="92">HDMI3</option>
<option value="93">HDMI4</option>
</options>
</state>
</channel-type>
<channel-type id="ir-key-code">
<item-type>String</item-type>
<label>IR Code</label>
<description>Send IR remote key code</description>
<state>
<options>
<option value="00">Channel up</option>
<option value="01">Channel down</option>
<option value="02">Volume up</option>
<option value="03">Volume down</option>
<option value="06">Right</option>
<option value="07">Left</option>
<option value="08">Power toggle</option>
<option value="09">Mute/Delete</option>
<option value="0B">Input</option>
<option value="0C">Portal</option>
<option value="0E">Sleep</option>
<option value="0F">TV</option>
<option value="10">Number 0</option>
<option value="11">Number 1</option>
<option value="12">Number 2</option>
<option value="13">Number 3</option>
<option value="14">Number 4</option>
<option value="15">Number 5</option>
<option value="16">Number 6</option>
<option value="17">Number 7</option>
<option value="18">Number 8</option>
<option value="19">Number 9</option>
<option value="1A">Flashbk or Q.VIEW</option>
<option value="1E">FAV/MARK</option>
<option value="28">Back or Return</option>
<option value="30">AV mode</option>
<option value="40">Up</option>
<option value="41">Down</option>
<option value="43">Home or Menu</option>
<option value="44">SET/Enter</option>
<option value="45">Q.Menu</option>
<option value="4C">- (Dash)/List</option>
<option value="5A">AV Discrete</option>
<option value="5B">Exit</option>
<option value="61">Blue</option>
<option value="63">Yellow</option>
<option value="6E">PSM</option>
<option value="71">Green</option>
<option value="72">Red</option>
<option value="76">ARC (4:3) Discrete</option>
<option value="77">ARC (16:9) Discrete</option>
<option value="79">ARC Discrete/Ratio</option>
<option value="7E">SIMPLINK</option>
<option value="8E">&#x25B6;&#x25B6; Fast forward</option>
<option value="8F">&#x25C0;&#x25C0; Rewind</option>
<option value="95">Energy saving</option>
<option value="98">AV</option>
<option value="99">Auto config Discrete</option>
<option value="AA">Info</option>
<option value="AB">Guide</option>
<option value="AF">ARC (Zoom) Discrete</option>
<option value="B0">&#x25B6; Play</option>
<option value="B1">&#x25A0; Stop</option>
<option value="BA">&#x23F8; Freeze/Pause</option> <!-- Found in SAC34134216 for plasma TVs -->
<option value="BF">Component Discrete</option>
<option value="C0">Green</option> <!-- Found in SAC34134216 for LV255C, LV355B, LV355C series -->
<option value="C1">Red</option> <!-- Found in SAC34134216 for LV255C, LV355B, LV355C series -->
<option value="C2">Yellow</option> <!-- Found in SAC34134216 for LV255C, LV355B, LV355C series -->
<option value="C3">Blue</option> <!-- Found in SAC34134216 for LV255C, LV355B, LV355C series -->
<option value="C4">Power on</option>
<option value="C5">Power off</option>
<option value="C6">HDMI/DVI Discrete</option>
<option value="CC">HDMI2 Discrete</option>
<option value="CE">HDMI1 Discrete</option>
<option value="D0">AV2 Discrete</option>
<option value="D4">Component2 Discrete</option>
<option value="D5">RGB PC Discrete</option>
<option value="D6">TV Discrete</option>
<option value="DA">HDMI4 Discrete</option>
<option value="DC">3D</option>
<option value="E9">HDMI3 Discrete</option>
</options>
</state>
</channel-type>
<channel-type id="ism-method">
<item-type>String</item-type>
<label>ISM Method</label>
<description>Avoid having a fixed image remain on screen</description>
<state>
<options>
<option value="01">Inversion</option>
<option value="02">Orbiter</option>
<option value="04">White Wash</option>
<option value="08">Normal</option>
<option value="10">Dot Wash</option>
<option value="20">Color Wash</option>
</options>
</state>
</channel-type>
<channel-type id="lamp-fault-check">
<item-type>String</item-type>
<label>Lamp Fault</label>
<description>Check the lamp fault of the TV</description>
<state readOnly="true">
<options>
<option value="0">Fan fault</option>
<option value="1">Fan OK</option>
</options>
</state>
</channel-type>
<channel-type id="natural-mode">
<item-type>Switch</item-type>
<label>Natural Mode</label>
<description>To assign the Tile Natural mode for Tiling function</description>
</channel-type>
<channel-type id="osd-language">
<item-type>String</item-type>
<label>OSD Language</label>
<description>Set the OSD language</description>
<state>
<options>
<option value="00">English</option>
<option value="01">French</option>
<option value="02">German</option>
<option value="03">Spanish</option>
<option value="04">Italian</option>
<option value="05">Portuguese</option>
<option value="06">Chinese</option>
<option value="07">Japanese</option>
<option value="08">Korean</option>
<option value="09">Russian</option>
</options>
</state>
</channel-type>
<channel-type id="osd-select">
<item-type>Switch</item-type>
<label>OSD</label>
<description>To select OSD (On Screen Display) on/off</description>
</channel-type>
<channel-type id="picture-mode">
<item-type>String</item-type>
<label>Picture Mode</label>
<description>To adjust picture mode</description>
<state>
<options>
<option value="00">Vivid</option>
<option value="01">Standard</option>
<option value="02">Cinema</option>
<option value="03">Sport</option>
<option value="04">Game</option>
<option value="05">User1</option>
<option value="06">User2</option>
</options>
</state>
</channel-type>
<channel-type id="power">
<item-type>Switch</item-type>
<label>Power</label>
<description>Power on/off</description>
</channel-type>
<channel-type id="power-indicator">
<item-type>Switch</item-type>
<label>Power Indicator</label>
<description>To set the LED for Power Indicator</description>
</channel-type>
<channel-type id="power-saving">
<item-type>String</item-type>
<label>Power Saving</label>
<description>Set the Power saving mode</description>
<state>
<options>
<option value="00">Off</option>
<option value="01">Static level 1</option>
<option value="02">Static level 2</option>
<option value="03">Static level 3</option>
</options>
</state>
</channel-type>
<channel-type id="raw" advanced="true">
<item-type>String</item-type>
<label>Raw</label>
<description>Send raw command over the serial power directly to TV(s)</description>
</channel-type>
<channel-type id="screen-mute">
<item-type>String</item-type>
<label>Screen Mute</label>
<description>Select screen mute on/off</description>
<state>
<options>
<option value="00">Screen mute off (Picture on), Video-out Mute off</option>
<option value="01">Screen mute on (Picture off)</option>
<option value="10">Video-out Mute on</option>
</options>
</state>
</channel-type>
<channel-type id="serial-number">
<item-type>String</item-type>
<label>Serial Number</label>
<description>Read the serial numbers</description>
<state readOnly="true"/>
</channel-type>
<channel-type id="sharpness">
<item-type>Dimmer</item-type>
<label>Sharpness</label>
<description>Adjust screen sharpness</description>
</channel-type>
<!-- Definition of the M6503C definition as this is the only one we've seen so far -->
<channel-type id="sleep-time">
<item-type>String</item-type>
<label>Sleep Time</label>
<description>Set sleep time</description>
<state>
<options>
<option value="00">Off</option>
<option value="01">10</option>
<option value="02">20</option>
<option value="03">30</option>
<option value="04">60</option>
<option value="05">90</option>
<option value="06">120</option>
<option value="07">180</option>
<option value="08">240</option>
</options>
</state>
</channel-type>
<!-- Definition of the M6503C definition as this is the only one we've seen so far -->
<channel-type id="sound-mode">
<item-type>String</item-type>
<label>Sound Mode</label>
<description>To adjust sound mode</description>
<state>
<options>
<option value="00">Clear Voice</option>
<option value="01">Standard</option>
<option value="02">Music</option>
<option value="03">Cinema</option>
<option value="04">Sport</option>
<option value="05">Game</option>
<option value="06">User</option>
</options>
</state>
</channel-type>
<channel-type id="software-version">
<item-type>String</item-type>
<label>Software Version</label>
<description>Check the software version</description>
<state readOnly="true"/>
</channel-type>
<channel-type id="speaker">
<item-type>Switch</item-type>
<label>Speaker</label>
<description>Turn the speaker on or off</description>
</channel-type>
<!-- Definition of the M6503C definition as this is the only one we've seen so far -->
<channel-type id="temperature-value">
<item-type>Number:Temperature</item-type>
<label>Temperature Value</label>
<description>Read the inside temperature value</description>
<state readOnly="true" pattern="%.1f %unit%"/>
</channel-type>
<!-- Definition of the M6503C definition as this is the only one we've seen so far -->
<channel-type id="tile">
<item-type>String</item-type>
<label>Tile Mode</label>
<description>Change a tile mode</description>
<state>
<options>
<option value="00">Tile mode off</option>
<option value="11">1 x 1 mode (same as off)</option>
<option value="12">1 x 2 mode</option>
<option value="13">1 x 3 mode</option>
<option value="14">1 x 4 mode</option>
<option value="15">1 x 5 mode</option>
<option value="21">2 x 1 mode</option>
<option value="22">2 x 2 mode</option>
<option value="23">2 x 3 mode</option>
<option value="24">2 x 4 mode</option>
<option value="25">2 x 5 mode</option>
<option value="31">3 x 1 mode</option>
<option value="32">3 x 2 mode</option>
<option value="33">3 x 3 mode</option>
<option value="34">3 x 4 mode</option>
<option value="35">3 x 5 mode</option>
<option value="41">4 x 1 mode</option>
<option value="42">4 x 2 mode</option>
<option value="43">4 x 3 mode</option>
<option value="44">4 x 4 mode</option>
<option value="45">4 x 5 mode</option>
<option value="51">5 x 1 mode</option>
<option value="52">5 x 2 mode</option>
<option value="53">5 x 3 mode</option>
<option value="54">5 x 4 mode</option>
<option value="55">5 x 5 mode</option>
</options>
</state>
</channel-type>
<channel-type id="tile-h-position">
<item-type>Dimmer</item-type>
<label>Horizontal Position</label>
<description>Set the horizontal position</description>
</channel-type>
<channel-type id="tile-h-size">
<item-type>Dimmer</item-type>
<label>Horizontal Size</label>
<description>Set the horizontal size</description>
</channel-type>
<!-- Definition of the M6503C definition as this is the only one we've seen so far -->
<channel-type id="tile-id-set">
<item-type>Dimmer</item-type>
<label>Tile ID Set</label>
<description>To assign the Tile ID for Tiling function</description>
<state min="0" max="25"/>
</channel-type>
<channel-type id="tile-v-position">
<item-type>Dimmer</item-type>
<label>Vertical Position</label>
<description>Set the vertical position</description>
</channel-type>
<channel-type id="tile-v-size">
<item-type>Dimmer</item-type>
<label>Vertical Size</label>
<description>Set the vertical size</description>
</channel-type>
<channel-type id="tint">
<item-type>Dimmer</item-type>
<label>Tint</label>
<description>Tint control (%)</description>
</channel-type>
<channel-type id="treble">
<item-type>Dimmer</item-type>
<label>Treble</label>
<description>Treble control (%)</description>
</channel-type>
<channel-type id="v-position">
<item-type>Dimmer</item-type>
<label>V Position</label>
<description>Set the vertical position</description>
</channel-type>
<channel-type id="volume">
<item-type>Dimmer</item-type>
<label>Volume</label>
<description>Volume control (%)</description>
<category>SoundVolume</category>
</channel-type>
<channel-type id="volume-mute">
<item-type>Switch</item-type>
<label>Mute</label>
<description>Mute on/off</description>
<category>Mute</category>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="lgtvserial"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<!-- Unimplemented so far : Abnormal state, Remote lock, Auto configure, command 36,37,38,39,42 (timers), reset, 52 scheduling
input select -->
<thing-type id="lgtv-M6503C">
<label>M6503C Model</label>
<description><![CDATA[This thing supports the M6503C LG TV]]></description>
<channels>
<channel id="aspect-ratio" typeId="aspect-ratio-M6503C"/>
<channel id="auto-sleep" typeId="auto-sleep"/>
<channel id="auto-volume" typeId="auto-volume"/>
<channel id="balance" typeId="balance"/>
<channel id="brightness" typeId="brightness"/>
<channel id="contrast" typeId="contrast"/>
<channel id="color" typeId="color"/>
<channel id="color-temperature" typeId="color-temperature"/>
<channel id="elapsed-time" typeId="elapsed-time"/>
<channel id="fan-fault-check" typeId="fan-fault-check"/>
<channel id="h-position" typeId="h-position"/>
<!-- Not yet implemented
<channel id="h-size" typeId="h-size" />
-->
<channel id="input" typeId="input-M6503C"/>
<channel id="input2" typeId="input2-M6503C"/>
<channel id="ir-key-code" typeId="ir-key-code-M6503C"/>
<channel id="ism-method" typeId="ism-M6503C"/>
<channel id="lamp-fault-check" typeId="lamp-fault-check"/>
<channel id="natural-mode" typeId="natural-mode"/>
<channel id="osd-language" typeId="osd-language"/>
<channel id="osd-select" typeId="osd-select"/>
<channel id="picture-mode" typeId="picture-mode"/>
<channel id="power" typeId="power"/>
<channel id="power-indicator" typeId="power-indicator"/>
<channel id="power-saving" typeId="power-saving"/>
<channel id="raw" typeId="raw"/>
<channel id="screen-mute" typeId="screen-mute"/>
<channel id="serial-number" typeId="serial-number"/>
<channel id="sharpness" typeId="sharpness"/>
<channel id="sleep-time" typeId="sleep-time"/>
<channel id="software-version" typeId="software-version"/>
<channel id="sound-mode" typeId="sound-mode"/>
<channel id="speaker" typeId="speaker"/>
<channel id="temperature-value" typeId="temperature-value"/>
<channel id="tile" typeId="tile"/>
<channel id="tile-h-position" typeId="tile-h-position"/>
<channel id="tile-h-size" typeId="tile-h-size"/>
<channel id="tile-id-set" typeId="tile-id-set"/>
<channel id="tile-v-position" typeId="tile-v-position"/>
<channel id="tile-v-size" typeId="tile-v-size"/>
<channel id="tint" typeId="tint"/>
<!-- Used to set the time on the TV, but have no clue yet how to handle this...
<channel id="time" typeId="time"/>
-->
<channel id="v-position" typeId="v-position"/>
<!-- Not yet implemented
<channel id="v-size" typeId="v-size"/>
-->
<channel id="volume" typeId="volume"/>
<channel id="volume-mute" typeId="volume-mute"/>
</channels>
<config-description-ref uri="thing-type:lgtvserial:serial"/>
</thing-type>
<channel-type id="aspect-ratio-M6503C">
<item-type>String</item-type>
<label>Aspect Ratio</label>
<description>Adjust the screen format</description>
<state>
<options>
<option value="01">Normal Screen (4:3)</option>
<option value="02">Wide Screen (16:9)</option>
<option value="04">Zoom1 (AV)</option>
<option value="05">Zoom2 (AV)</option>
<option value="06">Original (AV)</option>
<option value="07">14:9 (AV)</option>
<option value="09">Just scan(HD DTV), 1:1 (RGB PC, HDMI/DVI PC)</option>
</options>
</state>
</channel-type>
<channel-type id="input-M6503C">
<item-type>String</item-type>
<label>Input</label>
<description>Input select</description>
<state>
<options>
<option value="02">AV</option>
<option value="04">Component</option>
<option value="07">RGB (PC)</option>
<option value="08">HDMI (DTV)</option>
<option value="09">HDMI (PC)</option>
</options>
</state>
</channel-type>
<channel-type id="input2-M6503C">
<item-type>String</item-type>
<label>Input</label>
<description>Input select</description>
<state>
<options>
<option value="20">AV</option>
<option value="40">Component</option>
<option value="60">RGB (PC)</option>
<option value="90">HDMI (DTV)</option>
<option value="A0">HDMI (PC)</option>
</options>
</state>
</channel-type>
<channel-type id="ir-key-code-M6503C">
<item-type>String</item-type>
<label>IR Code</label>
<description>Send IR remote key code</description>
<state>
<options>
<option value="00">Channel up</option>
<option value="01">Channel down</option>
<option value="02">Volume up</option>
<option value="03">Volume down</option>
<option value="08">Power toggle</option>
<option value="09">Mute</option>
<option value="0B">Input</option>
<option value="0E">Sleep</option>
<option value="10">Number 0</option>
<option value="11">Number 1</option>
<option value="12">Number 2</option>
<option value="13">Number 3</option>
<option value="14">Number 4</option>
<option value="15">Number 5</option>
<option value="16">Number 6</option>
<option value="17">Number 7</option>
<option value="18">Number 8</option>
<option value="19">Number 9</option>
<option value="43">Menu</option>
<option value="44">SET</option>
<option value="5A">AV Discrete</option>
<option value="5B">Exit</option>
<option value="6E">PSM</option>
<option value="76">ARC (4:3) Discrete</option>
<option value="77">ARC (16:9) Discrete</option>
<option value="79">ARC Discrete</option>
<option value="AF">ARC (Zoom) Discrete</option>
<option value="BF">Component Discrete</option>
<option value="C4">Power on</option>
<option value="C5">Power off</option>
<option value="C6">HDMI/DVI Discrete</option>
<option value="D5">RGB PC Discrete</option>
<option value="98">AV</option>
<option value="99">Auto config Discrete</option>
</options>
</state>
</channel-type>
<channel-type id="ism-M6503C">
<item-type>String</item-type>
<label>ISM Method</label>
<description>Avoid having a fixed image remain on screen</description>
<state>
<options>
<option value="01">Inversion</option>
<option value="02">Orbiter</option>
<option value="04">White Wash</option>
<option value="08">Normal</option>
<option value="10">Dot Wash</option>
</options>
</state>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,357 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="lgtvserial"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<!-- TODO : auto configuration, channel tuning, channel add/del -->
<!-- Left not implemented on purpose : Remote control lock mode, so they don't lock themselves out -->
<!-- These things supports the LG TV models from the document with P/NO : SAC34134216 -->
<thing-type id="lgtv-LV-series">
<label>LV/LW Series</label>
<description><![CDATA[This thing supports the LED LCD TV models <size>LV<type> and <size>LW<type> except *LV255C, *LV355B, *LV355C models]]></description>
<channels>
<channel id="3d" typeId="3d"/>
<channel id="3d-extended" typeId="3d-extended"/>
<channel id="aspect-ratio" typeId="aspect-ratio-SAC34134216"/>
<channel id="backlight" typeId="backlight"/>
<channel id="balance" typeId="balance"/>
<channel id="bass" typeId="bass"/>
<channel id="brightness" typeId="brightness"/>
<channel id="color" typeId="color"/>
<channel id="color-temperature2" typeId="color-temperature2"/>
<channel id="contrast" typeId="contrast"/>
<channel id="energy-saving" typeId="energy-saving"/>
<channel id="input2" typeId="input-SAC34134216"/>
<channel id="ir-key-code" typeId="ir-key-code-SAC34134216"/>
<channel id="osd-select" typeId="osd-select"/>
<channel id="power" typeId="power"/>
<channel id="raw" typeId="raw"/>
<channel id="screen-mute" typeId="screen-mute"/>
<channel id="sharpness" typeId="sharpness"/>
<channel id="tint" typeId="tint"/>
<channel id="treble" typeId="treble"/>
<channel id="volume" typeId="volume"/>
<channel id="volume-mute" typeId="volume-mute"/>
</channels>
<!-- remote lock, auto conf, channel del, key, tuning -->
<config-description-ref uri="thing-type:lgtvserial:serial"/>
</thing-type>
<thing-type id="lgtv-LVx55-series">
<label>LV/LW Series</label>
<description><![CDATA[This thing supports the *LV255C, *LV355B, *LV355C models.]]></description>
<channels>
<channel id="3d" typeId="3d"/>
<channel id="3d-extended" typeId="3d-extended"/>
<channel id="aspect-ratio" typeId="aspect-ratio-SAC34134216"/>
<channel id="backlight" typeId="backlight"/>
<channel id="balance" typeId="balance"/>
<channel id="bass" typeId="bass"/>
<channel id="brightness" typeId="brightness"/>
<channel id="color" typeId="color"/>
<channel id="color-temperature2" typeId="color-temperature2"/>
<channel id="contrast" typeId="contrast"/>
<channel id="energy-saving" typeId="energy-saving"/>
<channel id="input2" typeId="input-SAC34134216"/>
<channel id="ir-key-code" typeId="ir-key-code-SAC34134216-LV255C-LV355B-LV355C"/>
<channel id="osd-select" typeId="osd-select"/>
<channel id="power" typeId="power"/>
<channel id="raw" typeId="raw"/>
<channel id="screen-mute" typeId="screen-mute"/>
<channel id="sharpness" typeId="sharpness"/>
<channel id="tint" typeId="tint"/>
<channel id="treble" typeId="treble"/>
<channel id="volume" typeId="volume"/>
<channel id="volume-mute" typeId="volume-mute"/>
</channels>
<!-- remote lock, auto conf, channel del, key, tuning -->
<config-description-ref uri="thing-type:lgtvserial:serial"/>
</thing-type>
<thing-type id="lgtv-LK-series">
<label>LK Series</label>
<description><![CDATA[This thing supports the LCD TV models <size>LK<type>]]></description>
<channels>
<channel id="3d" typeId="3d"/>
<channel id="3d-extended" typeId="3d-extended"/>
<channel id="aspect-ratio" typeId="aspect-ratio-SAC34134216"/>
<channel id="backlight" typeId="backlight"/>
<channel id="balance" typeId="balance"/>
<channel id="bass" typeId="bass"/>
<channel id="brightness" typeId="brightness"/>
<channel id="color" typeId="color"/>
<channel id="color-temperature2" typeId="color-temperature2"/>
<channel id="contrast" typeId="contrast"/>
<channel id="energy-saving" typeId="energy-saving"/>
<channel id="input2" typeId="input-SAC34134216"/>
<channel id="ir-key-code" typeId="ir-key-code-SAC34134216"/>
<channel id="osd-select" typeId="osd-select"/>
<channel id="power" typeId="power"/>
<channel id="raw" typeId="raw"/>
<channel id="screen-mute" typeId="screen-mute"/>
<channel id="sharpness" typeId="sharpness"/>
<channel id="tint" typeId="tint"/>
<channel id="treble" typeId="treble"/>
<channel id="volume" typeId="volume"/>
<channel id="volume-mute" typeId="volume-mute"/>
</channels>
<config-description-ref uri="thing-type:lgtvserial:serial"/>
</thing-type>
<thing-type id="lgtv-PW-series">
<label>PW Series</label>
<description><![CDATA[This thing supports the PLASMA TV models <size>PW<type>]]></description>
<channels>
<channel id="3d" typeId="3d"/>
<channel id="3d-extended" typeId="3d-extended"/>
<channel id="aspect-ratio" typeId="aspect-ratio-SAC34134216"/>
<channel id="balance" typeId="balance"/>
<channel id="bass" typeId="bass"/>
<channel id="brightness" typeId="brightness"/>
<channel id="color" typeId="color"/>
<channel id="color-temperature2" typeId="color-temperature2"/>
<channel id="contrast" typeId="contrast"/>
<channel id="energy-saving" typeId="energy-saving"/>
<channel id="input2" typeId="input-SAC34134216"/>
<channel id="ir-key-code" typeId="ir-key-code-SAC34134216"/>
<channel id="ism-method" typeId="ism-SAC34134216"/> <!-- only for plasma TVs -->
<channel id="osd-select" typeId="osd-select"/>
<channel id="power" typeId="power"/>
<channel id="raw" typeId="raw"/>
<channel id="screen-mute" typeId="screen-mute"/>
<channel id="sharpness" typeId="sharpness"/>
<channel id="tint" typeId="tint"/>
<channel id="treble" typeId="treble"/>
<channel id="volume" typeId="volume"/>
<channel id="volume-mute" typeId="volume-mute"/>
</channels>
<config-description-ref uri="thing-type:lgtvserial:serial"/>
</thing-type>
<channel-type id="aspect-ratio-SAC34134216">
<item-type>String</item-type>
<label>Aspect Ratio</label>
<description>Adjust the screen format</description>
<state>
<options>
<option value="01">4:3</option>
<option value="02">16:9</option>
<option value="04">Zoom</option>
<option value="06">Set by program</option>
<option value="09">Just scan</option>
<option value="10">Cinema Zoom 1</option>
<option value="11">Cinema Zoom 2</option>
<option value="12">Cinema Zoom 3</option>
<option value="13">Cinema Zoom 4</option>
<option value="14">Cinema Zoom 5</option>
<option value="15">Cinema Zoom 6</option>
<option value="16">Cinema Zoom 7</option>
<option value="17">Cinema Zoom 8</option>
<option value="18">Cinema Zoom 9</option>
<option value="19">Cinema Zoom 10</option>
<option value="1A">Cinema Zoom 11</option>
<option value="1B">Cinema Zoom 12</option>
<option value="1C">Cinema Zoom 13</option>
<option value="1D">Cinema Zoom 14</option>
<option value="1E">Cinema Zoom 15</option>
<option value="1F">Cinema Zoom 16</option>
</options>
</state>
</channel-type>
<channel-type id="input-SAC34134216">
<item-type>String</item-type>
<label>Input</label>
<description>Input select</description>
<state>
<options>
<option value="00">DTV (Antenna)</option>
<option value="01">DTV (cable)</option>
<option value="10">Analog (Antenna)</option>
<option value="11">Analog (Cable)</option>
<option value="20">AV or AV1</option>
<option value="21">AV2</option>
<option value="40">Component or Component1</option>
<option value="41">Component2</option>
<option value="60">RGB-PC</option>
<option value="90">HDMI1</option>
<option value="91">HDMI2</option>
<option value="92">HDMI3</option>
<option value="93">HDMI4</option>
</options>
</state>
</channel-type>
<channel-type id="ir-key-code-SAC34134216">
<item-type>String</item-type>
<label>IR Code</label>
<description>Send IR remote key code</description>
<state>
<options>
<option value="08">Power toggle</option>
<option value="45">Q.Menu</option>
<option value="43">Home or Menu</option>
<option value="0B">Input</option>
<option value="10">Number 0</option>
<option value="11">Number 1</option>
<option value="12">Number 2</option>
<option value="13">Number 3</option>
<option value="14">Number 4</option>
<option value="15">Number 5</option>
<option value="16">Number 6</option>
<option value="17">Number 7</option>
<option value="18">Number 8</option>
<option value="19">Number 9</option>
<option value="4C">- (Dash)/List</option>
<option value="1A">Flashbk or Q.VIEW</option>
<option value="09">Mute/Delete</option>
<option value="02">Volume up</option>
<option value="03">Volume down</option>
<option value="00">Channel up</option>
<option value="01">Channel down</option>
<option value="1E">FAV/MARK</option>
<option value="40">&#x02C4; Up</option>
<option value="41">&#x02C5; Down</option>
<option value="07">&#x02C2; Left</option>
<option value="06">&#x02C3; Right</option>
<option value="44">Enter</option>
<option value="28">Back or Return</option>
<option value="79">Ratio</option>
<option value="BA">Freeze</option> <!-- Found in SAC34134216 for plasma TVs -->
<option value="95">Energy saving</option>
<option value="7E">SIMPLINK</option>
<option value="AA">Info</option>
<option value="30">AV mode</option>
<option value="B1">&#x25A0; Stop</option>
<option value="B0">&#x25B6; Play</option>
<option value="BA">&#x23F8; Pause</option>
<option value="8E">&#x25B6;&#x25B6; Fast forward</option>
<option value="8F">&#x25C0;&#x25C0; Rewind</option>
<option value="72">Red</option>
<option value="71">Green</option>
<option value="63">Yellow</option>
<option value="61">Blue</option>
<option value="0F">TV</option>
<option value="DC">3D</option>
<option value="5B">Exit</option>
<option value="0C">Portal</option>
<option value="AB">Guide</option>
<option value="D6">TV Discrete</option>
<option value="C4">Power on</option>
<option value="C5">Power off</option>
<option value="5A">AV1 Discrete</option>
<option value="D0">AV2 Discrete</option>
<option value="BF">Component1 Discrete</option>
<option value="D4">Component2 Discrete</option>
<option value="D5">RGB PC Discrete</option>
<option value="CE">HDMI1 Discrete</option>
<option value="CC">HDMI2 Discrete</option>
<option value="E9">HDMI3 Discrete</option>
<option value="DA">HDMI4 Discrete</option>
<option value="76">Ratio 4:3 Discrete</option>
<option value="77">Ratio 16:9 Discrete</option>
<option value="AF">Ratio Zoom Discrete</option>
</options>
</state>
</channel-type>
<channel-type id="ir-key-code-SAC34134216-LV255C-LV355B-LV355C">
<item-type>String</item-type>
<label>IR Code</label>
<description>Send IR remote key code</description>
<state>
<options>
<option value="08">Power toggle</option>
<option value="45">Q.Menu</option>
<option value="43">Home or Menu</option>
<option value="0B">Input</option>
<option value="10">Number 0</option>
<option value="11">Number 1</option>
<option value="12">Number 2</option>
<option value="13">Number 3</option>
<option value="14">Number 4</option>
<option value="15">Number 5</option>
<option value="16">Number 6</option>
<option value="17">Number 7</option>
<option value="18">Number 8</option>
<option value="19">Number 9</option>
<option value="4C">- (Dash)/List</option>
<option value="1A">Flashbk or Q.VIEW</option>
<option value="09">Mute/Delete</option>
<option value="02">Volume up</option>
<option value="03">Volume down</option>
<option value="00">Channel up</option>
<option value="01">Channel down</option>
<option value="1E">FAV/MARK</option>
<option value="40">&#x02C4; Up</option>
<option value="41">&#x02C5; Down</option>
<option value="07">&#x02C2; Left</option>
<option value="06">&#x02C3; Right</option>
<option value="44">Enter</option>
<option value="28">Back or Return</option>
<option value="79">Ratio</option>
<option value="BA">Freeze</option> <!-- Found in SAC34134216 for plasma TVs -->
<option value="95">Energy saving</option>
<option value="7E">SIMPLINK</option>
<option value="AA">Info</option>
<option value="30">AV mode</option>
<option value="B1">&#x25A0; Stop</option>
<option value="B0">&#x25B6; Play</option>
<option value="BA">&#x23F8; Pause</option>
<option value="8E">&#x25B6;&#x25B6; Fast forward</option>
<option value="8F">&#x25C0;&#x25C0; Rewind</option>
<!-- The next 4 values are different for the LV255C, LV355B, LV355C series -->
<option value="C1">Red</option>
<option value="C0">Green</option>
<option value="C2">Yellow</option>
<option value="C3">Blue</option>
<option value="0F">TV</option>
<option value="DC">3D</option>
<option value="5B">Exit</option>
<option value="0C">Portal</option>
<option value="AB">Guide</option>
<option value="D6">TV Discrete</option>
<option value="C4">Power on</option>
<option value="C5">Power off</option>
<option value="5A">AV1 Discrete</option>
<option value="D0">AV2 Discrete</option>
<option value="BF">Component1 Discrete</option>
<option value="D4">Component2 Discrete</option>
<option value="D5">RGB PC Discrete</option>
<option value="CE">HDMI1 Discrete</option>
<option value="CC">HDMI2 Discrete</option>
<option value="E9">HDMI3 Discrete</option>
<option value="DA">HDMI4 Discrete</option>
<option value="76">Ratio 4:3 Discrete</option>
<option value="77">Ratio 16:9 Discrete</option>
<option value="AF">Ratio Zoom Discrete</option>
</options>
</state>
</channel-type>
<channel-type id="ism-SAC34134216">
<item-type>String</item-type>
<label>ISM Method</label>
<description>Avoid having a fixed image remain on screen</description>
<state>
<options>
<option value="02">Orbiter</option>
<option value="04">White Wash</option>
<option value="08">Normal</option>
<option value="20">Color Wash</option>
</options>
</state>
</channel-type>
</thing:thing-descriptions>

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="lgtvserial"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<!-- This thing should know just about every commands any LG TV could support.
This would be the thing to use if we haven't yet defined a proper thing limiting the supported
channels. -->
<thing-type id="lgtv">
<label>Generic LG TV</label>
<description>Generic LG television connected through a serial interface. This thing should be used only when there is
no proper thing defined for your TV model as it has most existing channels for most known commands.</description>
<channels>
<channel id="3d" typeId="3d"/>
<channel id="3d-extended" typeId="3d-extended"/>
<channel id="aspect-ratio" typeId="aspect-ratio"/>
<channel id="auto-sleep" typeId="auto-sleep"/>
<channel id="auto-volume" typeId="auto-volume"/>
<channel id="backlight" typeId="backlight"/>
<channel id="bass" typeId="bass"/>
<channel id="brightness" typeId="brightness"/>
<channel id="color" typeId="color"/>
<channel id="color-temperature" typeId="color-temperature"/>
<channel id="color-temperature2" typeId="color-temperature2"/>
<channel id="contrast" typeId="contrast"/>
<channel id="dpm" typeId="dpm"/>
<channel id="elapsed-time" typeId="elapsed-time"/>
<channel id="energy-saving" typeId="energy-saving"/>
<channel id="fan-fault-check" typeId="fan-fault-check"/>
<channel id="h-position" typeId="h-position"/>
<channel id="input" typeId="input"/>
<channel id="input2" typeId="input"/>
<channel id="ir-key-code" typeId="ir-key-code"/>
<channel id="ism-method" typeId="ism-method"/>
<channel id="lamp-fault-check" typeId="lamp-fault-check"/>
<channel id="natural-mode" typeId="natural-mode"/>
<channel id="osd-language" typeId="osd-language"/>
<channel id="osd-select" typeId="osd-select"/>
<channel id="picture-mode" typeId="picture-mode"/>
<channel id="power" typeId="power"/>
<channel id="power-indicator" typeId="power-indicator"/>
<channel id="power-saving" typeId="power-saving"/>
<channel id="raw" typeId="raw"/>
<channel id="screen-mute" typeId="screen-mute"/>
<channel id="serial-number" typeId="serial-number"/>
<channel id="sharpness" typeId="sharpness"/>
<channel id="sleep-time" typeId="sleep-time"/>
<channel id="software-version" typeId="software-version"/>
<channel id="sound-mode" typeId="sound-mode"/>
<channel id="speaker" typeId="speaker"/>
<channel id="temperature-value" typeId="temperature-value"/>
<channel id="tile" typeId="tile"/>
<channel id="tile-h-position" typeId="tile-h-position"/>
<channel id="tile-h-size" typeId="tile-h-size"/>
<channel id="tile-id-set" typeId="tile-id-set"/>
<channel id="tile-v-position" typeId="tile-v-position"/>
<channel id="tile-v-size" typeId="tile-v-size"/>
<!-- Used to set the time on the TV, but have no clue yet how to handle this...
<channel id="time" typeId="time"/>
-->
<channel id="tint" typeId="tint"/>
<channel id="treble" typeId="treble"/>
<channel id="volume" typeId="volume"/>
<channel id="volume-mute" typeId="volume-mute"/>
<channel id="v-position" typeId="v-position"/>
</channels>
<config-description-ref uri="thing-type:lgtvserial:serial"/>
</thing-type>
</thing:thing-descriptions>