Skip to content

Commit 43fa2c7

Browse files
authored
[epsonprojector] Add SDDP discovery (openhab#16802)
* Replace AMX discovery with SDDP Signed-off-by: Michael Lobstein <[email protected]>
1 parent 09a22e5 commit 43fa2c7

File tree

3 files changed

+119
-31
lines changed

3 files changed

+119
-31
lines changed

bundles/org.openhab.binding.epsonprojector/README.md

+31-31
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This binding supports two thing types based on the connection used: `projector-s
99

1010
## Discovery
1111

12-
If the projector has a built-in Ethernet port connected to the same network as the openHAB server and the 'AMX Device Discovery' option is present and enabled in the projector's network menu, the thing will be discovered automatically.
12+
If the projector has a built-in Ethernet port connected to the same network as the openHAB server and either the 'AMX Device Discovery' or 'Control4 SDDP' options are present and enabled in the projector's network menu, the thing will be discovered automatically.
1313
Serial port or serial over IP connections must be configured manually.
1414

1515
## Binding Configuration
@@ -72,36 +72,36 @@ connection: &conEpson
7272
7373
## Channels
7474
75-
| Channel | Item Type | Purpose | Values |
76-
| ------------------ | --------- | ------------------------------------------------------------------------------------------ | --------- |
77-
| power | Switch | Powers the projector on or off. | |
78-
| powerstate | String | Retrieves the textual power state of the projector. | Read only |
79-
| source | String | Retrieve or set the input source. | See above |
80-
| aspectratio | String | Retrieve or set the aspect ratio. | See above |
81-
| colormode | String | Retrieve or set the color mode. | See above |
82-
| freeze | Switch | Turn the freeze screen mode on or off. | |
83-
| mute | Switch | Turn the AV mute on or off. | |
84-
| volume | Dimmer | Retrieve or set the volume. Scaled to 0-20 or 0-40 on the projector per maxVolume setting. | 0% - 100% |
85-
| luminance | String | Retrieve or set the lamp mode. | See above |
86-
| brightness | Number | Retrieve or set the brightness. | -24 - +24 |
87-
| contrast | Number | Retrieve or set the contrast. | -24 - +24 |
88-
| density | Number | Retrieve or set the density (color saturation). | -32 - +32 |
89-
| tint | Number | Retrieve or set the tint. | -32 - +32 |
90-
| colortemperature | Number | Retrieve or set the color temperature. | 0 - +9 |
91-
| fleshtemperature | Number | Retrieve or set the flesh temperature. | 0 - +6 |
92-
| gamma | String | Retrieve or set the gamma setting. | See above |
93-
| autokeystone | Switch | Turn the auto keystone mode on or off. | |
94-
| verticalkeystone | Number | Retrieve or set the vertical keystone. | -30 - +30 |
95-
| horizontalkeystone | Number | Retrieve or set the horizontal keystone. | -30 - +30 |
96-
| verticalposition | Number | Retrieve or set the vertical position. | -8 - +10 |
97-
| horizontalposition | Number | Retrieve or set the horizontal position. | -23 - +26 |
98-
| verticalreverse | Switch | Turn the vertical reverse mode on or off. | |
99-
| horizontalreverse | Switch | Turn the horizontal reverse mode on or off. | |
100-
| background | String | Retrieve or set the background color/logo. | See above |
101-
| keycode | String | Send a key operation command to the projector. (2 character code) | Send only |
102-
| lamptime | Number | Retrieves the lamp hours. | Read only |
103-
| errcode | Number | Retrieves the last error code. | Read only |
104-
| errmessage | String | Retrieves the description of the last error. | Read only |
75+
| Channel | Item Type | Purpose | Values |
76+
| ------------------ | --------- | ------------------------------------------------------------------------------------------ | ---------- |
77+
| power | Switch | Powers the projector on or off. | |
78+
| powerstate | String | Retrieves the textual power state of the projector. | Read only |
79+
| source | String | Retrieve or set the input source. | See above |
80+
| aspectratio | String | Retrieve or set the aspect ratio. | See above |
81+
| colormode | String | Retrieve or set the color mode. | See above |
82+
| freeze | Switch | Turn the freeze screen mode on or off. | |
83+
| mute | Switch | Turn the AV mute on or off. | |
84+
| volume | Dimmer | Retrieve or set the volume. Scaled to 0-20 or 0-40 on the projector per maxVolume setting. | 0% - 100% |
85+
| luminance | String | Retrieve or set the lamp mode. | See above |
86+
| brightness | Number | Retrieve or set the brightness. | -24 - +24 |
87+
| contrast | Number | Retrieve or set the contrast. | -24 - +24 |
88+
| density | Number | Retrieve or set the density (color saturation). | -32 - +32 |
89+
| tint | Number | Retrieve or set the tint. | -32 - +32 |
90+
| colortemperature | Number | Retrieve or set the color temperature. | 0 - +9 |
91+
| fleshtemperature | Number | Retrieve or set the flesh temperature. | 0 - +6 |
92+
| gamma | String | Retrieve or set the gamma setting. | See above |
93+
| autokeystone | Switch | Turn the auto keystone mode on or off. | |
94+
| verticalkeystone | Number | Retrieve or set the vertical keystone. | -30 - +30 |
95+
| horizontalkeystone | Number | Retrieve or set the horizontal keystone. | -30 - +30 |
96+
| verticalposition | Number | Retrieve or set the vertical position. | -8 - +10 |
97+
| horizontalposition | Number | Retrieve or set the horizontal position. | -23 - +26 |
98+
| verticalreverse | Switch | Turn the vertical reverse mode on or off. | |
99+
| horizontalreverse | Switch | Turn the horizontal reverse mode on or off. | |
100+
| background | String | Retrieve or set the background color/logo. | See above |
101+
| keycode | String | Send a key operation command to the projector. (2 character code) | Write only |
102+
| lamptime | Number | Retrieves the number of hours the lamp has been used. | Read only |
103+
| errcode | Number | Retrieves the last error code. | Read only |
104+
| errmessage | String | Retrieves the description of the last error. | Read only |
105105
106106
## Full Example
107107

bundles/org.openhab.binding.epsonprojector/src/main/feature/feature.xml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<feature name="openhab-binding-epsonprojector" description="Epson Projector Binding" version="${project.version}">
66
<feature>openhab-runtime-base</feature>
77
<feature>openhab-transport-serial</feature>
8+
<feature>openhab-core-config-discovery-sddp</feature>
89
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.epsonprojector/${project.version}</bundle>
910
</feature>
1011
</features>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* Copyright (c) 2010-2024 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.epsonprojector.internal.discovery;
14+
15+
import static org.openhab.binding.epsonprojector.internal.EpsonProjectorBindingConstants.*;
16+
17+
import java.util.HashMap;
18+
import java.util.Locale;
19+
import java.util.Map;
20+
import java.util.Set;
21+
22+
import org.eclipse.jdt.annotation.NonNullByDefault;
23+
import org.eclipse.jdt.annotation.Nullable;
24+
import org.openhab.core.config.discovery.DiscoveryResult;
25+
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
26+
import org.openhab.core.config.discovery.sddp.SddpDevice;
27+
import org.openhab.core.config.discovery.sddp.SddpDiscoveryParticipant;
28+
import org.openhab.core.thing.Thing;
29+
import org.openhab.core.thing.ThingTypeUID;
30+
import org.openhab.core.thing.ThingUID;
31+
import org.osgi.service.component.annotations.Component;
32+
import org.slf4j.Logger;
33+
import org.slf4j.LoggerFactory;
34+
35+
/**
36+
*
37+
* Discovery Service for Epson Projectors that support SDDP.
38+
*
39+
* @author Michael Lobstein - Initial contribution
40+
*
41+
*/
42+
@NonNullByDefault
43+
@Component(immediate = true)
44+
public class EpsonProjectorDiscoveryParticipant implements SddpDiscoveryParticipant {
45+
private final Logger logger = LoggerFactory.getLogger(EpsonProjectorDiscoveryParticipant.class);
46+
47+
private static final String EPSON = "EPSON";
48+
private static final String TYPE_PROJECTOR = "PROJECTOR";
49+
50+
@Override
51+
public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
52+
return SUPPORTED_THING_TYPES_UIDS;
53+
}
54+
55+
@Override
56+
public @Nullable DiscoveryResult createResult(SddpDevice device) {
57+
final ThingUID uid = getThingUID(device);
58+
if (uid != null) {
59+
final Map<String, Object> properties = new HashMap<>(3);
60+
final String label = device.manufacturer + " " + device.model;
61+
62+
properties.put(Thing.PROPERTY_MAC_ADDRESS, uid.getId());
63+
properties.put(THING_PROPERTY_HOST, device.ipAddress);
64+
properties.put(THING_PROPERTY_PORT, DEFAULT_PORT);
65+
66+
final DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
67+
.withRepresentationProperty(Thing.PROPERTY_MAC_ADDRESS).withLabel(label).build();
68+
69+
logger.debug("Created a DiscoveryResult for device '{}' with UID '{}'", label, uid.getId());
70+
return result;
71+
} else {
72+
return null;
73+
}
74+
}
75+
76+
@Override
77+
public @Nullable ThingUID getThingUID(SddpDevice device) {
78+
if (device.manufacturer.toUpperCase(Locale.ENGLISH).contains(EPSON)
79+
&& device.type.toUpperCase(Locale.ENGLISH).contains(TYPE_PROJECTOR) && !device.macAddress.isBlank()) {
80+
81+
logger.debug("Epson projector with mac {} found at {}", device.macAddress, device.ipAddress);
82+
return new ThingUID(THING_TYPE_PROJECTOR_TCP,
83+
device.macAddress.replaceAll("-", "").toUpperCase(Locale.ENGLISH));
84+
}
85+
return null;
86+
}
87+
}

0 commit comments

Comments
 (0)