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

[dreamscreen][WIP] Initial contribution #6984

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7354785
Initial checkin for DreamScreen binding on behalf of Bruce Brouwer
markus7017 Feb 9, 2020
6cc1a1f
Update POM definitions to include dreamscreen binding
markus7017 Feb 9, 2020
bca66b3
debug adjusted
markus7017 Feb 12, 2020
1789ca0
rebased + 2.5.9
markus7017 Sep 4, 2020
6a6ca3d
review changes applied
markus7017 Sep 6, 2020
7867191
README (draft)
markus7017 Sep 9, 2020
1bbc308
Adapter Bruce Brouwer's Initial Contribution to 2.5.9 - WIP!
markus7017 Sep 14, 2020
f1550e5
Adapter Bruce Brouwer's Initial Contribution to 2.5.9
markus7017 Sep 14, 2020
41979cb
minor changes
markus7017 Sep 14, 2020
0647784
item type for channels mode and scene changed to String
markus7017 Sep 16, 2020
5cee2c1
item type for channel input changed to String
markus7017 Sep 16, 2020
19c63a4
missing
markus7017 Sep 16, 2020
f0e643b
README updated
markus7017 Sep 16, 2020
dfba37e
new device type Connect, persist power on mode to thing properties; new
markus7017 Sep 17, 2020
e661a3a
Fix Connect device ID, add solo Device ID
d8ahazard Sep 17, 2020
9bda8fd
Add handler and thing definition for DS solo
d8ahazard Sep 17, 2020
959bbb0
Fix whitespace issues
d8ahazard Sep 17, 2020
96719e8
We really, really don't need this offset stuff.
d8ahazard Sep 17, 2020
c0b829f
Dynamically load byte offsets based on device type
d8ahazard Sep 17, 2020
60200ba
Add saturation, brightness, channels and methods.
d8ahazard Sep 17, 2020
cba5f10
Use product_id constants instead of hardcoding
d8ahazard Sep 17, 2020
58f2053
Refactor offset names, change access to static
d8ahazard Sep 17, 2020
cea989d
Maven/spotless cleanup
d8ahazard Sep 17, 2020
22dddec
Add constant for magic byte
d8ahazard Sep 17, 2020
5a10ad3
Add handler for solo, not sure if we need sidekick or connect in ther…
d8ahazard Sep 17, 2020
4dae9f8
Merge pull request #12 from d8ahazard/dreamscreen_snapshot
markus7017 Sep 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
/bundles/org.openhab.binding.dmx/ @J-N-K
/bundles/org.openhab.binding.doorbird/ @mhilbush
/bundles/org.openhab.binding.draytonwiser/ @andrew-schofield
/bundles/org.openhab.binding.dreamscreen/ @markus7017
/bundles/org.openhab.binding.dscalarm/ @RSStephens
/bundles/org.openhab.binding.dsmr/ @Hilbrand
/bundles/org.openhab.binding.ecobee/ @mhilbush
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 @@ -229,6 +229,11 @@
<artifactId>org.openhab.binding.draytonwiser</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.dreamscreen</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.dscalarm</artifactId>
Expand Down
Binary file added bundles/org.openhab.binding.carnet.zip
Binary file not shown.
32 changes: 32 additions & 0 deletions bundles/org.openhab.binding.dreamscreen/.classpath
Original file line number Diff line number Diff line change
@@ -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-1.8">
<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>
23 changes: 23 additions & 0 deletions bundles/org.openhab.binding.dreamscreen/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.dreamscreen</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>
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.dreamscreen/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
35 changes: 35 additions & 0 deletions bundles/org.openhab.binding.dreamscreen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# DreamScreen Binding

This binding integrates the DreamScreen TV light system

## Supported Things

| Thing UID | Description |
|------------|-----------------------------|
| hd | DreamScreen HD Device |
| 4k | DreamScreen 4k Device |
| sidekick | DreamScreen Sidekick Device |

Note: Sidekick support is primarily and not verified.

## Discovery

DreamScren devices are discovered automatically on the local network (The control protocol is UDP-based and runs on port 8888).
Configure and test your DreamScreen using the manufacture's App before setting up the openHAB integration.

## Channels

Various function of the DreamScreen could be controlled and status is reported.

| Channel | Type | Description |
|----------|--------|--------------------------------------------------------|
| power | Switch | Switch power of the device on/off |
| input | String | HD + 4k: Select input channel: hdmi1, hdmi2 or jdmi3 |
| mode | String | Switch the display mode: video, music or ambient |
| scene | String | Switch the ambient display scene: one of color, random, fireside, twinkle, ocean, rainbow, july_4th, holiday, pop, forest |
| color | Color | Select the active color to use with the Color scene |

## Full Example

_Provide a full usage example based on textual configuration files (*.things, *.items, *.sitemap)._

17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.dreamscreen/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>2.5.9-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.dreamscreen</artifactId>

<name>openHAB Add-ons :: Bundles :: DreamScreen Binding</name>

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

import static java.util.stream.Collectors.toSet;

import java.util.Set;
import java.util.stream.Stream;

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

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

public static final String BINDING_ID = "dreamscreen";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_4K = new ThingTypeUID(BINDING_ID, "4k");
public static final ThingTypeUID THING_TYPE_HD = new ThingTypeUID(BINDING_ID, "hd");
public static final ThingTypeUID THING_TYPE_SIDEKICK = new ThingTypeUID(BINDING_ID, "sidekick");
public static final ThingTypeUID THING_TYPE_SOLO = new ThingTypeUID(BINDING_ID, "solo");
public static final ThingTypeUID THING_TYPE_CONNECT = new ThingTypeUID(BINDING_ID, "connect");
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Stream
.of(THING_TYPE_HD, THING_TYPE_4K, THING_TYPE_SIDEKICK, THING_TYPE_CONNECT).collect(toSet());

public static final String PROPERTY_POWERON_MODE = "powerOnMode";

public static final int PRODUCT_ID_HD = 1;
public static final int PRODUCT_ID_4K = 2;
public static final int PRODUCT_ID_SIDEKICK = 3;
public static final int PRODUCT_ID_CONNECT = 4;
public static final int PRODUCT_ID_SOLO = 7;

// List of all Channel ids
public static final String CHANNEL_POWER = "power";
public static final String CHANNEL_MODE = "mode";
public static final String CHANNEL_SCENE = "scene";
public static final String CHANNEL_INPUT = "input";
public static final String CHANNEL_COLOR = "color";
public static final String CHANNEL_SATURATION = "saturation";
public static final String CHANNEL_BRIGHTNESS = "brightness";

// Mode values
public static final String MODE_VIDEO = "video";
public static final String MODE_MUSIC = "music";
public static final String MODE_AMBIENT = "ambient";

// Scene values
public static final String SCENE_COLOR = "color";
public static final String SCENE_RANDOM = "random";
public static final String SCENE_FIRESIDE = "fireside";
public static final String SCENE_TWINKLE = "twinkle";
public static final String SCENE_OCEAN = "ocean";
public static final String SCENE_RAINBOW = "rainbow";
public static final String SCENE_JULY_4TH = "july4th";
public static final String SCENE_HOLIDAY = "holiday";
public static final String SCENE_POP = "pop";
public static final String SCENE_ENCHANTED_FOREST = "eforrest";

// Input Names
public static final String INPUT_PREFIX = "hdmi";
public static final String INPUT_CHANNEL1 = INPUT_PREFIX + "1";
public static final String INPUT_CHANNEL2 = INPUT_PREFIX + "2";
public static final String INPUT_CHANNEL3 = INPUT_PREFIX + "3";
}
Original file line number Diff line number Diff line change
@@ -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.dreamscreen.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link DreamScreenConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Bruce Brouwer - Initial contribution
*/
@NonNullByDefault
public class DreamScreenConfiguration {
public static final String SERIAL_NUMBER = "serialNumber";

public String serialNumber = "";
public String groupId = "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* 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.dreamscreen.internal;

import static org.openhab.binding.dreamscreen.internal.DreamScreenBindingConstants.*;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.thing.ThingUID;
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.eclipse.smarthome.core.thing.type.DynamicStateDescriptionProvider;
import org.openhab.binding.dreamscreen.internal.handler.DreamScreen4kHandler;
import org.openhab.binding.dreamscreen.internal.handler.DreamScreenConnectHandler;
import org.openhab.binding.dreamscreen.internal.handler.DreamScreenHdHandler;
import org.openhab.binding.dreamscreen.internal.handler.DreamScreenInputDescriptionProvider;
import org.openhab.binding.dreamscreen.internal.handler.DreamScreenSidekickHandler;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* The {@link DreamScreenHandlerFactory} is responsible for creating things and thing handlers.
*
* @author Bruce Brouwer - Initial contribution
*/
@NonNullByDefault
@Component(configurationPid = "binding.dreamscreen", service = ThingHandlerFactory.class)
public class DreamScreenHandlerFactory extends BaseThingHandlerFactory {
private Map<ThingUID, @Nullable ServiceRegistration<?>> services = new HashMap<>();
final DreamScreenServer server;

@Activate
public DreamScreenHandlerFactory(@Reference DreamScreenServer server) {
this.server = server;
}

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

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

if (THING_TYPE_HD.equals(thingTypeUID)) {
return new DreamScreenHdHandler(server, thing, registerDescriptionProvider(thing.getUID()));
} else if (THING_TYPE_4K.equals(thingTypeUID)) {
return new DreamScreen4kHandler(server, thing, registerDescriptionProvider(thing.getUID()));
} else if (THING_TYPE_SIDEKICK.equals(thingTypeUID)) {
return new DreamScreenSidekickHandler(server, thing);
} else if (THING_TYPE_CONNECT.equals(thingTypeUID)) {
return new DreamScreenConnectHandler(server, thing, registerDescriptionProvider(thing.getUID()));
}
return null;
}

private DreamScreenInputDescriptionProvider registerDescriptionProvider(ThingUID thingUID) {
final DreamScreenInputDescriptionProvider description = new DreamScreenInputDescriptionProvider(thingUID);
this.services.put(thingUID,
bundleContext.registerService(DynamicStateDescriptionProvider.class, description, new Hashtable<>()));
return description;
}

/**
* Removes the handler for the specific thing. This also handles disabling the discovery
* service when the bridge is removed.
*/
@Override
protected void removeHandler(ThingHandler thingHandler) {
final @Nullable ServiceRegistration<?> reg = this.services.remove(thingHandler.getThing().getUID());
if (reg != null) {
reg.unregister();
}
super.removeHandler(thingHandler);
}
}