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 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
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
/bundles/org.openhab.binding.mpd/ @stefanroellin
/bundles/org.openhab.binding.mqtt/ @ccutrer
/bundles/org.openhab.binding.mqtt.espmilighthub/ @Skinah
/bundles/org.openhab.binding.mqtt.fpp/ @computergeek1507
/bundles/org.openhab.binding.mqtt.generic/ @ccutrer
/bundles/org.openhab.binding.mqtt.homeassistant/ @antroids @ccutrer
/bundles/org.openhab.binding.mqtt.homie/ @ccutrer
Expand Down
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
92 changes: 92 additions & 0 deletions bundles/org.openhab.binding.mqtt.fpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# FPP Binding

Binding to control Falcon Player (FPP) Devices using MQTT and HTTP. Status messages are recieved over MQTT and Commands are HTTP Commands.

computergeek1507 marked this conversation as resolved.
Show resolved Hide resolved
## Discovery

Autodiscovering is not supported. We have to define the things manually.

## Supported Things

The binding supports one Thing `player` that represents the Falcon Player.
## Thing Configuration

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

## Channels

| Channel | Type | Description |
|----------------------------------------|--------------------|-------------------------------------------|
| `player` | Player | Play/Stop Current Playlist. |
| `volume` | Dimmer | Playback Audio Volume. |
| `status` | String | Playback Status. |
| `mode` | String | Playback Mode. |
| `uptime` | Number:Time | Device Uptime. |
| `testing-enabled` | Switch | Enabled/Disable Sending Testing Data. |
| `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. |
| `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.

### fpp.things

```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"
```

### fpp.items

```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 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"}
```

### fpp.sitemap

```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=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.3.0-SNAPSHOT</version>
</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 playerAddress = "";
public String playerMQTTTopic = "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* 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_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_SCHEDULER_STATUS = "scheduler-status";
public static final String CHANNEL_SCHEDULER_CURRENT_PLAYLIST = "scheduler-current-playlist";
public static final String CHANNEL_SCHEDULER_CURRENT_PLAYLIST_START = "scheduler-current-playlist-start";
public static final String CHANNEL_SCHEDULER_CURRENT_PLAYLIST_END = "scheduler-current-playlist-end";
public static final String CHANNEL_SCHEDULER_CURRENT_PLAYLIST_STOP_TYPE = "scheduler-current-playlist-stop-type";
public static final String CHANNEL_SCHEDULER_NEXT_PLAYLIST = "scheduler-next-playlist";
public static final String CHANNEL_SCHEDULER_NEXT_PLAYLIST_START = "scheduler-next-playlist-start";

public static final String PROPERTY_UUID = "uuid";
public static final String PROPERTY_SOFTWARE_VERSION = "Software Version";

// Status
public static final String CONNECTED = "connected";
public static final String CHANNEL_STATUS_NAME = "status-name";

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,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;
}
}
Loading
Loading