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

[fpp] Initial contribution #16298

Merged
merged 21 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.mqtt.fpp/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
89 changes: 89 additions & 0 deletions bundles/org.openhab.binding.mqtt.fpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# FPP Binding

Binding to Controls Falcon Player (FPP) Devices. Uses MQTT to update status. Manually add an 'player' thing to get status.
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved

computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved
## Thing Configuration

| Parameter | Description | Required | Default |
|-|-|-|-|
| `playerIP` | IP Address of FPP Devive | Y | |
| `playerMQTT` | MQTT Topic of FPP Devive Status | Y | |

## Channels

| Channel | Type | Description |
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved
|-|-|-|
| `player` | Player | Play/Stop Current Playlist. |
| `volume` | Dimmer | Playback Audio Volume. |
| `status` | String | Playback Status. |
| `version` | String | Software Version. |
| `mode` | String | Playback Mode. |
| `uptime` | Number:Time | Device Uptime. |
| `testing-enabled` | Switch | Device is in Testing Mode. |
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved
| `current-sequence` | String (read only) | Currently Playing Sequence File. |
| `current-song` | String (read only) | Currently Playing Audio/Media File. |
| `current-playlist` | String (read only) | Currently Playing Playlist. |
| `seconds-played` | Number:Time | Sequence Playback time in secs. |
| `seconds-remaining` | Number:Time | Sequence Playback time remaining in secs. |
| `last-playlist` | String | Lasted Played Playlist. |
| `uuid` | String | Device UUID. |
| `bridging-enabled` | Switch | Is Recieving Bridge Data. |
| `multisync-enabled` | Switch | Multisync Mode Enabled. |
| `scheduler-current-playlist` | String (read only) | Scheduler Current Playlist. |
| `scheduler-current-playlist-start` | String (read only) | Scheduler Current Playlist Start Time. |
| `scheduler-current-playlist-end` | String (read only) | Scheduler Current Playlist End Time. |
| `scheduler-current-playlist-stop-type` | String (read only) | Scheduler Current Playlist End Type. |
| `scheduler-next-playlist` | String (read only) | Next Scheduled Playlist. |
| `scheduler-next-playlist-start` | String (read only) | Next Scheduled Start Time. |


computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved
## Full Example

To use these examples for textual configuration, you must already have a configured MQTT `broker` thing, and know its unique ID.
This UID will be used in the things file and will replace the text `myBroker`.
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.

*.things
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved

```java
Bridge mqtt:broker:myBroker [ host="localhost", secure=false, password="*******", qos=1, username="user"]
Thing mqtt:player:myBroker:mainPlayer "Main Player" (mqtt:broker:myBroker) @ "MQTT"
```

*.items
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved

```java
Player FPP_Player "FPP Player" {channel="mqtt:player:myBroker:mainPlayer:player"}
Dimmer Audio_Volume "Audio Volume" {channel="mqtt:player:myBroker:mainPlayer:volume"}
String Current_Sequence "Current Sequence" {channel="mqtt:player:myBroker:mainPlayer:current-sequence"}
String Current_Song "Current Song" {channel="mqtt:player:myBroker:mainPlayer:current-song"}
String Current_Playlist "Current Playlist" {channel="mqtt:player:myBroker:mainPlayer:current-playlist"}
String Status "FPP Status" {channel="mqtt:player:myBroker:mainPlayer:status"}
String Version "FPP Version" {channel="mqtt:player:myBroker:mainPlayer:version"}
String Mode "FPP Mode" {channel="mqtt:player:myBroker:mainPlayer:mode"}
String Last_Playlist "Last Playlist" {channel="mqtt:player:myBroker:mainPlayer:last-playlist"}
Number:Time Seconds_Played "Seconds Played [%d %unit%]" {channel="mqtt:player:myBroker:mainPlayer:seconds-played"}
Number:Time Seconds_Remaining "Seconds Remaining [%d %unit%]" {channel="mqtt:player:myBroker:mainPlayer:seconds-remaining"}
Switch Testing "Testing Mode" {channel="mqtt:player:myBroker:mainPlayer:testing-enabled"}
Switch Multisync "Multisync" {channel="mqtt:player:myBroker:mainPlayer:multisync-enabled"}
```

*.sitemap
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved

```perl
Text label="Main Player"
{
Player item=FPP_Player
Switch item=Testing
Slider item=Audio_Volume
Text item=Current_Sequence
Text item=Current_Song
Text item=Current_Playlist
Text item=Status
Text item=Version
Text item=Mode
Selection item=Last_Playlist
Switch item=Testing
Switch item=Multisync
}
```
24 changes: 24 additions & 0 deletions bundles/org.openhab.binding.mqtt.fpp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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 https://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>4.2.0-SNAPSHOT</version>
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved
</parent>

<artifactId>org.openhab.binding.mqtt.fpp</artifactId>
<name>openHAB Add-ons :: Bundles :: MQTT FPP</name>

<dependencies>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.mqtt</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.mqtt.fpp-${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-mqtt-fpp" description="MQTT Binding FPP" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab-transport-mqtt</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt/${project.version}</bundle>
<bundle start-level="81">mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.fpp/${project.version}</bundle>
</feature>

</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2024 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.mqtt.fpp.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link ConfigOptions} Holds the config for the settings.
*
* @author Scott Hanson - Initial contribution
*/
@NonNullByDefault
public class ConfigOptions {
public String playerIP = "";
public String playerMQTT = "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Copyright (c) 2010-2024 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.mqtt.fpp.internal;

import static org.openhab.binding.mqtt.MqttBindingConstants.BINDING_ID;

import java.util.Set;

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

/**
* The {@link FPPBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Scott Hanson - Initial contribution
*/
@NonNullByDefault
public class FPPBindingConstants {
// falcon/player/FPP/fppd_status
public static final String STATUS_TOPIC = "fppd_status";
public static final String VERSION_TOPIC = "version";
public static final String PLAYLIST_TOPIC = "playlist";
public static final String MQTT_PREFIX = "falcon/player/";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_PLAYER = new ThingTypeUID(BINDING_ID, "player");

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_PLAYER);

// Channels
public static final String CHANNEL_PLAYER = "player";
public static final String CHANNEL_STATUS = "status";
public static final String CHANNEL_VOLUME = "volume";
public static final String CHANNEL_MODE = "mode";
public static final String CHANNEL_CURRENT_SEQUENCE = "current-sequence";
public static final String CHANNEL_CURRENT_SONG = "current-song";
public static final String CHANNEL_CURRENT_PLAYLIST = "current-playlist";
public static final String CHANNEL_SEC_PLAYED = "seconds-played";
public static final String CHANNEL_SEC_REMAINING = "seconds-remaining";
public static final String CHANNEL_UPTIME = "uptime";
public static final String CHANNEL_UUID = "uuid";
public static final String CHANNEL_VERSION = "version";
public static final String CHANNEL_BRIDGING = "bridging-enabled";
public static final String CHANNEL_MULTISYNC = "multisync-enabled";
public static final String CHANNEL_TESTING = "testing-enabled";
public static final String CHANNEL_LAST_PLAYLIST = "last-playlist";

public static final String CHANNEL_SCHEDULERSTATUS = "scheduler-status";
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved
public static final String CHANNEL_SCHEDULERCURRENTPLAYLIST = "scheduler-current-playlist";
public static final String CHANNEL_SCHEDULERCURRENTPLAYLISTSTART = "scheduler-current-playlist-start";
public static final String CHANNEL_SCHEDULERCURRENTPLAYLISTEND = "scheduler-current-playlist-end";
public static final String CHANNEL_SCHEDULERCURRENTPLAYLISTSTOPTYPE = "scheduler-current-playlist-stop-type";
public static final String CHANNEL_SCHEDULERNEXTPLAYLIST = "scheduler-next-playlist";
public static final String CHANNEL_SCHEDULERNEXTPLAYLISTSTART = "scheduler-next-playlist-start";

// Status
public static final String CONNECTED = "connected";
public static final String CHANNEL_STATUS_NAME = "status_name";
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved

public static final String TESTING = "testing";
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2010-2024 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.mqtt.fpp.internal;
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
* The {@link FPPCurrentPlaylist} is responsible for storing
* the FPP JSON Current Playlist data.
*
* @author Scott Hanson - Initial contribution
*/
public class FPPCurrentPlaylist {
@SerializedName("playlistName")
@Expose
public String playlistName;

@SerializedName("scheduledStartTimeStr")
@Expose
public String scheduledStartTimeStr;

@SerializedName("scheduledEndTimeStr")
@Expose
public String scheduledEndTimeStr;

@SerializedName("stopTypeStr")
@Expose
public String stopTypeStr;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright (c) 2010-2024 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.mqtt.fpp.internal;

import static org.openhab.binding.mqtt.fpp.internal.FPPBindingConstants.SUPPORTED_THING_TYPES;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.mqtt.fpp.internal.handler.FPPPlayerHandler;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingRegistry;
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 FPPHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Scott Hanson - Initial contribution
*/
@Component(service = ThingHandlerFactory.class)
@NonNullByDefault
public class FPPHandlerFactory extends BaseThingHandlerFactory {
private final ThingRegistry thingRegistry;

@Activate
public FPPHandlerFactory(final @Reference ThingRegistry thingRegistry) {
this.thingRegistry = thingRegistry;
}

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

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new FPPPlayerHandler(thing, thingRegistry);
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2024 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.mqtt.fpp.internal;
computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
* The {@link FPPNextPlaylist} is responsible for storing
* the FPP JSON Next Playlist data.
*
* @author Scott Hanson - Initial contribution
*/
public class FPPNextPlaylist {
/*
* "nextPlaylist" :
* {
* "playlistName" : "No playlist scheduled.",
* "scheduledStartTime" : 0,
* "scheduledStartTimeStr" : ""
* },
*/

@SerializedName("playlistName")
@Expose
public String playlistName;

@SerializedName("scheduledStartTimeStr")
@Expose
public String scheduledStartTimeStr;

@SerializedName("scheduledStartTime")
@Expose
public int scheduledStartTime;
}
Loading