Skip to content

Commit 163f517

Browse files
[fpp] Initial contribution (openhab#16298)
* working on FPP Signed-off-by: Scott Hanson <[email protected]>
1 parent ab2dade commit 163f517

File tree

19 files changed

+1162
-0
lines changed

19 files changed

+1162
-0
lines changed

Diff for: CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@
235235
/bundles/org.openhab.binding.mpd/ @stefanroellin
236236
/bundles/org.openhab.binding.mqtt/ @ccutrer
237237
/bundles/org.openhab.binding.mqtt.espmilighthub/ @Skinah
238+
/bundles/org.openhab.binding.mqtt.fpp/ @computergeek1507
238239
/bundles/org.openhab.binding.mqtt.generic/ @ccutrer
239240
/bundles/org.openhab.binding.mqtt.homeassistant/ @antroids @ccutrer
240241
/bundles/org.openhab.binding.mqtt.homie/ @ccutrer

Diff for: bundles/org.openhab.binding.mqtt.fpp/NOTICE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This content is produced and maintained by the openHAB project.
2+
3+
* Project home: https://www.openhab.org
4+
5+
== Declared Project Licenses
6+
7+
This program and the accompanying materials are made available under the terms
8+
of the Eclipse Public License 2.0 which is available at
9+
https://www.eclipse.org/legal/epl-2.0/.
10+
11+
== Source Code
12+
13+
https://github.com/openhab/openhab-addons

Diff for: bundles/org.openhab.binding.mqtt.fpp/README.md

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# FPP Binding
2+
3+
Binding to control Falcon Player (FPP) Devices using MQTT and HTTP. Status messages are recieved over MQTT and Commands are HTTP Commands.
4+
5+
## Discovery
6+
7+
Autodiscovering is not supported. We have to define the things manually.
8+
9+
## Supported Things
10+
11+
The binding supports one Thing `player` that represents the Falcon Player.
12+
## Thing Configuration
13+
14+
| Parameter | Description | Required | Default |
15+
|--------------|-----------------------------------------|----------|---------|
16+
| `playerIP` | IP Address or Host Name of FPP Devive | Y | |
17+
| `playerMQTT` | MQTT Topic of FPP Devive Status Updates | Y | |
18+
19+
## Channels
20+
21+
| Channel | Type | Description |
22+
|----------------------------------------|--------------------|-------------------------------------------|
23+
| `player` | Player | Play/Stop Current Playlist. |
24+
| `volume` | Dimmer | Playback Audio Volume. |
25+
| `status` | String | Playback Status. |
26+
| `mode` | String | Playback Mode. |
27+
| `uptime` | Number:Time | Device Uptime. |
28+
| `testing-enabled` | Switch | Enabled/Disable Sending Testing Data. |
29+
| `current-sequence` | String (read only) | Currently Playing Sequence File. |
30+
| `current-song` | String (read only) | Currently Playing Audio/Media File. |
31+
| `current-playlist` | String (read only) | Currently Playing Playlist. |
32+
| `seconds-played` | Number:Time | Sequence Playback time in secs. |
33+
| `seconds-remaining` | Number:Time | Sequence Playback time remaining in secs. |
34+
| `last-playlist` | String | Lasted Played Playlist. |
35+
| `bridging-enabled` | Switch | Is Recieving Bridge Data. |
36+
| `multisync-enabled` | Switch | Multisync Mode Enabled. |
37+
| `scheduler-current-playlist` | String (read only) | Scheduler Current Playlist. |
38+
| `scheduler-current-playlist-start` | String (read only) | Scheduler Current Playlist Start Time. |
39+
| `scheduler-current-playlist-end` | String (read only) | Scheduler Current Playlist End Time. |
40+
| `scheduler-current-playlist-stop-type` | String (read only) | Scheduler Current Playlist End Type. |
41+
| `scheduler-next-playlist` | String (read only) | Next Scheduled Playlist. |
42+
| `scheduler-next-playlist-start` | String (read only) | Next Scheduled Start Time. |
43+
44+
45+
## Full Example
46+
47+
To use these examples for textual configuration, you must already have a configured MQTT `broker` thing, and know its unique ID.
48+
This UID will be used in the things file and will replace the text `myBroker`.
49+
The first line in the things file will create a `broker` thing and this can be removed if you have already setup a broker in another file or via the UI already.
50+
51+
### fpp.things
52+
53+
```java
54+
Bridge mqtt:broker:myBroker [ host="localhost", secure=false, password="*******", qos=1, username="user"]
55+
Thing mqtt:player:myBroker:mainPlayer "Main Player" (mqtt:broker:myBroker) @ "MQTT"
56+
```
57+
58+
### fpp.items
59+
60+
```java
61+
Player FPP_Player "FPP Player" {channel="mqtt:player:myBroker:mainPlayer:player"}
62+
Dimmer Audio_Volume "Audio Volume" {channel="mqtt:player:myBroker:mainPlayer:volume"}
63+
String Current_Sequence "Current Sequence" {channel="mqtt:player:myBroker:mainPlayer:current-sequence"}
64+
String Current_Song "Current Song" {channel="mqtt:player:myBroker:mainPlayer:current-song"}
65+
String Current_Playlist "Current Playlist" {channel="mqtt:player:myBroker:mainPlayer:current-playlist"}
66+
String Status "FPP Status" {channel="mqtt:player:myBroker:mainPlayer:status"}
67+
String Mode "FPP Mode" {channel="mqtt:player:myBroker:mainPlayer:mode"}
68+
String Last_Playlist "Last Playlist" {channel="mqtt:player:myBroker:mainPlayer:last-playlist"}
69+
Number:Time Seconds_Played "Seconds Played [%d %unit%]" {channel="mqtt:player:myBroker:mainPlayer:seconds-played"}
70+
Number:Time Seconds_Remaining "Seconds Remaining [%d %unit%]" {channel="mqtt:player:myBroker:mainPlayer:seconds-remaining"}
71+
Switch Testing "Testing Mode" {channel="mqtt:player:myBroker:mainPlayer:testing-enabled"}
72+
Switch Multisync "Multisync" {channel="mqtt:player:myBroker:mainPlayer:multisync-enabled"}
73+
```
74+
75+
### fpp.sitemap
76+
77+
```perl
78+
Text label="Main Player"
79+
{
80+
Player item=FPP_Player
81+
Switch item=Testing
82+
Slider item=Audio_Volume
83+
Text item=Current_Sequence
84+
Text item=Current_Song
85+
Text item=Current_Playlist
86+
Text item=Status
87+
Text item=Mode
88+
Selection item=Last_Playlist
89+
Switch item=Testing
90+
Switch item=Multisync
91+
}
92+
```

Diff for: bundles/org.openhab.binding.mqtt.fpp/pom.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.openhab.addons.bundles</groupId>
9+
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
10+
<version>4.3.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>org.openhab.binding.mqtt.fpp</artifactId>
14+
<name>openHAB Add-ons :: Bundles :: MQTT FPP</name>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.openhab.addons.bundles</groupId>
19+
<artifactId>org.openhab.binding.mqtt</artifactId>
20+
<version>${project.version}</version>
21+
<scope>provided</scope>
22+
</dependency>
23+
</dependencies>
24+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<features name="org.openhab.binding.mqtt.fpp-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
3+
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
4+
5+
<feature name="openhab-binding-mqtt-fpp" description="MQTT Binding FPP" version="${project.version}">
6+
<feature>openhab-runtime-base</feature>
7+
<feature>openhab-transport-mqtt</feature>
8+
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt/${project.version}</bundle>
9+
<bundle start-level="81">mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.fpp/${project.version}</bundle>
10+
</feature>
11+
12+
</features>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.mqtt.fpp.internal;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
17+
/**
18+
* The {@link ConfigOptions} Holds the config for the settings.
19+
*
20+
* @author Scott Hanson - Initial contribution
21+
*/
22+
@NonNullByDefault
23+
public class ConfigOptions {
24+
public String playerAddress = "";
25+
public String playerMQTTTopic = "";
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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.mqtt.fpp.internal;
14+
15+
import static org.openhab.binding.mqtt.MqttBindingConstants.BINDING_ID;
16+
17+
import java.util.Set;
18+
19+
import org.eclipse.jdt.annotation.NonNullByDefault;
20+
import org.openhab.core.thing.ThingTypeUID;
21+
22+
/**
23+
* The {@link FPPBindingConstants} class defines common constants, which are
24+
* used across the whole binding.
25+
*
26+
* @author Scott Hanson - Initial contribution
27+
*/
28+
@NonNullByDefault
29+
public class FPPBindingConstants {
30+
// falcon/player/FPP/fppd_status
31+
public static final String STATUS_TOPIC = "fppd_status";
32+
public static final String VERSION_TOPIC = "version";
33+
public static final String PLAYLIST_TOPIC = "playlist";
34+
public static final String MQTT_PREFIX = "falcon/player/";
35+
36+
// List of all Thing Type UIDs
37+
public static final ThingTypeUID THING_TYPE_PLAYER = new ThingTypeUID(BINDING_ID, "player");
38+
39+
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_PLAYER);
40+
41+
// Channels
42+
public static final String CHANNEL_PLAYER = "player";
43+
public static final String CHANNEL_STATUS = "status";
44+
public static final String CHANNEL_VOLUME = "volume";
45+
public static final String CHANNEL_MODE = "mode";
46+
public static final String CHANNEL_CURRENT_SEQUENCE = "current-sequence";
47+
public static final String CHANNEL_CURRENT_SONG = "current-song";
48+
public static final String CHANNEL_CURRENT_PLAYLIST = "current-playlist";
49+
public static final String CHANNEL_SEC_PLAYED = "seconds-played";
50+
public static final String CHANNEL_SEC_REMAINING = "seconds-remaining";
51+
public static final String CHANNEL_UPTIME = "uptime";
52+
public static final String CHANNEL_BRIDGING = "bridging-enabled";
53+
public static final String CHANNEL_MULTISYNC = "multisync-enabled";
54+
public static final String CHANNEL_TESTING = "testing-enabled";
55+
public static final String CHANNEL_LAST_PLAYLIST = "last-playlist";
56+
57+
public static final String CHANNEL_SCHEDULER_STATUS = "scheduler-status";
58+
public static final String CHANNEL_SCHEDULER_CURRENT_PLAYLIST = "scheduler-current-playlist";
59+
public static final String CHANNEL_SCHEDULER_CURRENT_PLAYLIST_START = "scheduler-current-playlist-start";
60+
public static final String CHANNEL_SCHEDULER_CURRENT_PLAYLIST_END = "scheduler-current-playlist-end";
61+
public static final String CHANNEL_SCHEDULER_CURRENT_PLAYLIST_STOP_TYPE = "scheduler-current-playlist-stop-type";
62+
public static final String CHANNEL_SCHEDULER_NEXT_PLAYLIST = "scheduler-next-playlist";
63+
public static final String CHANNEL_SCHEDULER_NEXT_PLAYLIST_START = "scheduler-next-playlist-start";
64+
65+
public static final String PROPERTY_UUID = "uuid";
66+
public static final String PROPERTY_SOFTWARE_VERSION = "Software Version";
67+
68+
// Status
69+
public static final String CONNECTED = "connected";
70+
public static final String CHANNEL_STATUS_NAME = "status-name";
71+
72+
public static final String TESTING = "testing";
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.mqtt.fpp.internal;
14+
15+
import static org.openhab.binding.mqtt.fpp.internal.FPPBindingConstants.SUPPORTED_THING_TYPES;
16+
17+
import org.eclipse.jdt.annotation.NonNullByDefault;
18+
import org.eclipse.jdt.annotation.Nullable;
19+
import org.openhab.binding.mqtt.fpp.internal.handler.FPPPlayerHandler;
20+
import org.openhab.core.thing.Thing;
21+
import org.openhab.core.thing.ThingRegistry;
22+
import org.openhab.core.thing.ThingTypeUID;
23+
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
24+
import org.openhab.core.thing.binding.ThingHandler;
25+
import org.openhab.core.thing.binding.ThingHandlerFactory;
26+
import org.osgi.service.component.annotations.Activate;
27+
import org.osgi.service.component.annotations.Component;
28+
import org.osgi.service.component.annotations.Reference;
29+
30+
/**
31+
* The {@link FPPHandlerFactory} is responsible for creating things and thing
32+
* handlers.
33+
*
34+
* @author Scott Hanson - Initial contribution
35+
*/
36+
@Component(service = ThingHandlerFactory.class)
37+
@NonNullByDefault
38+
public class FPPHandlerFactory extends BaseThingHandlerFactory {
39+
private final ThingRegistry thingRegistry;
40+
41+
@Activate
42+
public FPPHandlerFactory(final @Reference ThingRegistry thingRegistry) {
43+
this.thingRegistry = thingRegistry;
44+
}
45+
46+
@Override
47+
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
48+
return SUPPORTED_THING_TYPES.contains(thingTypeUID);
49+
}
50+
51+
@Override
52+
protected @Nullable ThingHandler createHandler(Thing thing) {
53+
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
54+
if (SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
55+
return new FPPPlayerHandler(thing, thingRegistry);
56+
}
57+
return null;
58+
}
59+
}

0 commit comments

Comments
 (0)