Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][panasonictv] Initial contribution #9024

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
/bundles/org.openhab.binding.openwebnet/ @mvalla
/bundles/org.openhab.binding.oppo/ @mlobstein
/bundles/org.openhab.binding.orvibo/ @tavalin
/bundles/org.openhab.binding.panasonictv/ @J-N-K
/bundles/org.openhab.binding.paradoxalarm/ @theater
/bundles/org.openhab.binding.pentair/ @jsjames
/bundles/org.openhab.binding.phc/ @gnlpfjh
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,11 @@
<artifactId>org.openhab.binding.orvibo</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.panasonictv</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.paradoxalarm</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.panasonictv/NOTICE
Original file line number Diff line number Diff line change
@@ -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
61 changes: 61 additions & 0 deletions bundles/org.openhab.binding.panasonictv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Panasonic TV Binding

This binding integrates the [Panasonic TV's](http://www.panasonic.com).

## Supported Things

Panasonic Viera TV (E6), models should be supported.
Panasonic TVs does not support full UPNP standard functionalities
Volume and Mute status are updated in real time
Most of the control is provided by sending Key Code to RemoteControl API

Source Name (read only) is updated when a Key Code to change the source is sent to tv, otherwise it is Undefined


Tested TV models:

| Model | State | Notes |
|-----------|---------|--------------------------------------------------------------------------------------|
| Viera E6 | OK | Initial contribution is done by this model |



## Discovery

The TV's are discovered through UPnP protocol in the local network and all devices are put in the Inbox.

## Binding Configuration

The binding does not require any special configuration.

## Thing Configuration

The Panasonic TV Thing requires the host name and port address as a configuration value in order for the binding to know how to access it. Panasonic TV publish several UPnP devices and hostname is used to recognize those UPnP devices.
Port address is used for remote control emulation protocol.
Additionally, a refresh interval can be configured in milliseconds to specify how often TV resources are polled.

E.g.

```
Thing panasonictv:tv:livingroom [ hostName="192.168.1.10", port=55000, refreshInterval=1000 ]
```

## Channels

TVs support the following channels:

| Channel Type ID | Item Type | Description |
|------------------|-----------|---------------------------------------------------------------------------------------------------------|
| volume | Dimmer | Volume level of the TV. |
| mute | Switch | Mute state of the TV. |
| sourceName | String | Name of the current source. Readonly, updated blindly when keyCode to change input is sent |
| sourceId | Number | Id of the current source. |
| keyCode | String | The key code channel emulates the infrared remote controller and allows to send virtual button presses. |

E.g.

```
Dimmer TV_Volume { channel="panasonictv:tv:livingroom:volume" }
Switch TV_Mute { channel="panasonictv:tv:livingroom:mute" }
String TV_KeyCode { channel="panasonictv:tv:livingroom:keyCode" }
```
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.panasonictv/pom.xml
Original file line number Diff line number Diff line change
@@ -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.panasonictv</artifactId>

<name>openHAB Add-ons :: Bundles :: Panasonic TV Binding</name>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.panasonictv-${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-panasonictv" description="Panasonic TV Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-upnp</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.panasonictv/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -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.panasonictv.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link PanasonicTvBindingConstants} class defines common constants, which are used
* across the whole binding.
*
* @author Prakashbabu Sidaraddi - Initial contribution
*/
@NonNullByDefault
public class PanasonicTvBindingConstants {

public static final String BINDING_ID = "panasonictv";

public static final ThingTypeUID THING_TYPE_PANASONICTV = new ThingTypeUID(BINDING_ID, "tv");

public static final String CONFIG_REMOTECONTROLLER_UDN = "remoteControllerUdn";
public static final String CONFIG_MEDIARENDERER_UDN = "mediaRendererUdn";
public static final String PROPERTY_SERIAL = "serialNumber";

// List of all remote controller thing channel id's
public static final String KEY_CODE = "keyCode";
public static final String POWER = "power";
public static final String SOURCE_NAME = "sourceName";
public static final String SOURCE_ID = "sourceId";

// List of all media renderer thing channel id's
public static final String VOLUME = "volume";
public static final String MUTE = "mute";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* 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.panasonictv.internal;

import static org.openhab.binding.panasonictv.internal.PanasonicTvBindingConstants.THING_TYPE_PANASONICTV;

import java.util.Collection;
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.panasonictv.internal.handler.PanasonicTvHandler;
import org.openhab.core.io.transport.upnp.UpnpIOService;
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 PanasonicTvHandlerFactory} is responsible for creating things and
* thing handlers.
*
* @author Prakashbabu Sidaraddi - Initial contribution
*/
@NonNullByDefault
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.panasonictv")
public class PanasonicTvHandlerFactory extends BaseThingHandlerFactory {
private static final Collection<ThingTypeUID> SUPPORTED_THING_TYPE_UIDS = Set.of(THING_TYPE_PANASONICTV);

private final UpnpIOService upnpIOService;

@Activate
public PanasonicTvHandlerFactory(@Reference PanasonicUpnpIOService upnpIOService) {
this.upnpIOService = upnpIOService;
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPE_UIDS.contains(thingTypeUID);
}

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (thingTypeUID.equals(THING_TYPE_PANASONICTV)) {
return new PanasonicTvHandler(thing, upnpIOService);
}

return null;
}
}
Loading