From 0bbe5ac486f1d1d63a5321b27fc774eca5b85012 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 17 Jan 2024 03:08:05 -0500 Subject: [PATCH 01/20] working on FPP Signed-off-by: Scott Hanson --- bundles/org.openhab.binding.mqtt.fpp/NOTICE | 13 + .../org.openhab.binding.mqtt.fpp/README.md | 71 +++++ bundles/org.openhab.binding.mqtt.fpp/pom.xml | 24 ++ .../src/main/feature/feature.xml | 12 + .../mqtt/fpp/internal/ConfigOptions.java | 26 ++ .../fpp/internal/FPPBindingConstants.java | 58 ++++ .../mqtt/fpp/internal/FPPHandlerFactory.java | 59 ++++ .../mqtt/fpp/internal/FPPPlaylist.java | 54 ++++ .../binding/mqtt/fpp/internal/FPPStatus.java | 157 +++++++++++ .../binding/mqtt/fpp/internal/Helper.java | 65 +++++ .../internal/handler/FPPPlayerHandler.java | 266 ++++++++++++++++++ .../main/resources/OH-INF/config/config.xml | 20 ++ .../resources/OH-INF/i18n/mqtt.properties | 18 ++ .../resources/OH-INF/i18n/mqtt_it.properties | 81 ++++++ .../resources/OH-INF/thing/thing-types.xml | 99 +++++++ bundles/pom.xml | 1 + 16 files changed, 1024 insertions(+) create mode 100644 bundles/org.openhab.binding.mqtt.fpp/NOTICE create mode 100644 bundles/org.openhab.binding.mqtt.fpp/README.md create mode 100644 bundles/org.openhab.binding.mqtt.fpp/pom.xml create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/feature/feature.xml create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/ConfigOptions.java create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPHandlerFactory.java create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/Helper.java create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt_it.properties create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml diff --git a/bundles/org.openhab.binding.mqtt.fpp/NOTICE b/bundles/org.openhab.binding.mqtt.fpp/NOTICE new file mode 100644 index 0000000000000..38d625e349232 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/NOTICE @@ -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 diff --git a/bundles/org.openhab.binding.mqtt.fpp/README.md b/bundles/org.openhab.binding.mqtt.fpp/README.md new file mode 100644 index 0000000000000..28711e97dfc2b --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/README.md @@ -0,0 +1,71 @@ +# FPP Binding + + +Note that the group 0 (or ALL group) is not auto discovered as a thing and thus has to be added manually if needed. + +## Thing Configuration + +| Parameter | Description | Required | Default | +|-|-|-|-| +| `whiteHue` | When both the `whiteHue` and `whiteSat` values are seen by the binding it will trigger the white LEDS. Set to -1 to disable, 0 for Alexa, or 35 for Google Home. | Y | 35 | +| `whiteSat` | When both the whiteHue and whiteSat values are seen by the binding it will trigger the white LEDS. Set to -1 to disable, 100 for Alexa or 32 for Google Home. | Y | 32 | +| `favouriteWhite` | When one of the shortcuts triggers white mode, use this for the colour white instead of the default colour. | Y |200 | +| `dimmedCT` | Traditional globes grow warmer the more they are dimmed. Set this to 370, or leave blank to disable. | N | blank | +| `oneTriggersNightMode` | Night mode is a much lower level of light and this feature allows it to be auto selected when your fader/slider moves to 1%. NOTE: Night mode by design locks out some controls of a physical remote, so this feature is disabled by default. | Y | false | +| `powerFailsToMinimum` | If lights loose power from the power switch OR a power outage, they will default to using the lowest brightness if the light was turned off before the power failure occurred. | Y | true | +| `whiteThreshold` | This feature allows you to use a color control to change to using the real white LEDs when the saturation is equal to, or below this threshold. -1 will disable this feature. | Y | 12 | +| `duvThreshold` | This feature allows you to use a color control to change to using the real warm/cool white LEDs to set a white color temperature if the color is within a certain threshold of the block body curve. 1 will effectively disable this feature. The default settings maps well to Apple's HomeKit that will allow you to choose a color temperature, but sends it as an HSB value. See for more information. | Y | 0.003 | + +## Channels + +| Channel | Type | Description | +|-|-|-| +| `level` | Dimmer | Level changes the brightness of the globe. Not present if the bulb supports the `colour` channel. | +| `colourTemperature` | Dimmer | Change from cool to warm white with this control. | +| `colourTemperatureAbs` | Number:Temperature | Colour temperature in mireds. | +| `colour` | Color | Allows you to change the colour, brightness and saturation of the globe. Can also be linked directly with a Dimmer item if you happen to have a bulb that doesn't support colour, but is controlled by a remote that normally does support colour. | +| `discoMode` | String | Switch to a Disco mode directly from a drop down list. | +| `bulbMode` | String (read only) | Displays the mode the bulb is currently in so that rules can determine if the globe is white, a color, disco modes or night mode are selected. | +| `command` | String | Sends the raw commands that the buttons on a remote send. | + + +## 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 + +```java +Bridge mqtt:broker:myBroker [ host="localhost", secure=false, password="*******", qos=1, username="user"] +Thing mqtt:rgb_cct:myBroker:0xE6C4 "Hallway" (mqtt:broker:myBroker) @ "MQTT" +``` + +*.items + +```java +Dimmer Hallway_Level "Front Hall" {channel="mqtt:rgb_cct:myBroker:0xE6C4:colour"} +Dimmer Hallway_ColourTemperature "White Color Temp" {channel="mqtt:rgb_cct:myBroker:0xE6C4:colourTemperature"} +Number:Temperature Hallway_ColourTemperatureK "White Color Temp [%d %unit%]" {channel="mqtt:rgb_cct:myBroker:0xE6C4:colourTemperatureAbs", unit="K"} +Color Hallway_Colour "Front Hall" ["Lighting"] {channel="mqtt:rgb_cct:myBroker:0xE6C4:colour"} +String Hallway_DiscoMode "Disco Mode" {channel="mqtt:rgb_cct:myBroker:0xE6C4:discoMode"} +String Hallway_BulbCommand "Send Command" {channel="mqtt:rgb_cct:myBroker:0xE6C4:command"} +String Hallway_BulbMode "Bulb Mode" {channel="mqtt:rgb_cct:myBroker:0xE6C4:bulbMode"} + +``` + +*.sitemap + +```perl +Text label="Hallway" icon="light" +{ + Switch item=Hallway_Level + Slider item=Hallway_Level + Slider item=Hallway_ColourTemperature + Colorpicker item=Hallway_Colour + Selection item=Hallway_DiscoMode + Text item=Hallway_BulbMode + Switch item=Hallway_BulbCommand mappings=[next_mode='Mode +', previous_mode='Mode -', mode_speed_up='Speed +', mode_speed_down='Speed -', set_white='White', night_mode='Night' ] +} +``` diff --git a/bundles/org.openhab.binding.mqtt.fpp/pom.xml b/bundles/org.openhab.binding.mqtt.fpp/pom.xml new file mode 100644 index 0000000000000..6c839be9de27f --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/pom.xml @@ -0,0 +1,24 @@ + + + + 4.0.0 + + + org.openhab.addons.bundles + org.openhab.addons.reactor.bundles + 4.2.0-SNAPSHOT + + + org.openhab.binding.mqtt.fpp + openHAB Add-ons :: Bundles :: MQTT FPP + + + + org.openhab.addons.bundles + org.openhab.binding.mqtt + ${project.version} + provided + + + diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/feature/feature.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/feature/feature.xml new file mode 100644 index 0000000000000..1f8b3a2cd5052 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/feature/feature.xml @@ -0,0 +1,12 @@ + + + mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features + + + openhab-runtime-base + openhab-transport-mqtt + mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt/${project.version} + mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.espmilighthub/${project.version} + + + diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/ConfigOptions.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/ConfigOptions.java new file mode 100644 index 0000000000000..2f042c0e4a795 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/ConfigOptions.java @@ -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 = ""; +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java new file mode 100644 index 0000000000000..f3b346aa4a206 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java @@ -0,0 +1,58 @@ +/** + * 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 SUPPORTED_THING_TYPES = Set.of(THING_TYPE_PLAYER); + + // Channels + public static final String CHANNEL_PLAYER = "fppPlayer"; + public static final String CHANNEL_STATUS = "fppStatus"; + public static final String CHANNEL_VOLUME = "fppVolume"; + public static final String CHANNEL_MODE = "fppMode"; + public static final String CHANNEL_CURRENT_SEQUENCE = "fppCurrentSequence"; + public static final String CHANNEL_CURRENT_SONG = "fppCurrentSong"; + public static final String CHANNEL_CURRENT_PLAYLIST = "fppCurrentPlaylist"; + public static final String CHANNEL_SEC_PLAYED = "fppSecPlayed"; + public static final String CHANNEL_SEC_REMAINING = "fppSecRemaining"; + public static final String CHANNEL_UPTIME = "fppUptime"; + public static final String CHANNEL_UUID = "fppUUID"; + public static final String CHANNEL_VERSION = "fppVersion"; + + // Status + public static final String CONNECTED = "connected"; + public static final String CHANNEL_STATUS_NAME = "status_name"; +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPHandlerFactory.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPHandlerFactory.java new file mode 100644 index 0000000000000..96d132ff765c1 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPHandlerFactory.java @@ -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; + } +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java new file mode 100644 index 0000000000000..b3f5ea82b6464 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java @@ -0,0 +1,54 @@ +package org.openhab.binding.mqtt.fpp.internal; + +/** + * Copyright (c) 2010-2019 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 + */ + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * The {@link FPPPlaylist} is responsible for storing + * the FPP JSON Status data. + * + * @author Scott Hanson - Initial contribution + */ +public class FPPPlaylist { + /* + * + * "current_playlist" : + * { + * "count" : "0", + * "description" : "", + * "index" : "0", + * "playlist" : "", + * "type" : "" + * } + * + */ + + @SerializedName("playlist") + @Expose + public String playlist; + + @SerializedName("description") + @Expose + public String description; + + @SerializedName("count") + @Expose + public int count; + + @SerializedName("index") + @Expose + public int index; +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java new file mode 100644 index 0000000000000..73bd886ebbe1b --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java @@ -0,0 +1,157 @@ +package org.openhab.binding.mqtt.fpp.internal; + +/** + * Copyright (c) 2010-2019 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 + */ + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * The {@link FPPStstus} is responsible for storing + * the FPP JSON Status data. + * + * @author Scott Hanson - Initial contribution + */ +public class FPPStatus { + /* + * { + * "MQTT" : + * { + * "configured" : true, + * "connected" : true + * }, + * "bridging" : false, + * "current_playlist" : + * { + * "count" : "0", + * "description" : "", + * "index" : "0", + * "playlist" : "", + * "type" : "" + * }, + * "current_sequence" : "", + * "current_song" : "", + * "dateStr" : "Sun Jan 7", + * "fppd" : "running", + * "mode" : 2, + * "mode_name" : "player", + * "multisync" : true, + * "next_playlist" : + * { + * "playlist" : "No playlist scheduled.", + * "start_time" : "" + * }, + * "repeat_mode" : "0", + * "scheduler" : + * { + * "enabled" : 1, + * "nextPlaylist" : + * { + * "playlistName" : "No playlist scheduled.", + * "scheduledStartTime" : 0, + * "scheduledStartTimeStr" : "" + * }, + * "status" : "idle" + * }, + * "seconds_played" : "0", + * "seconds_remaining" : "0", + * "sensors" : + * [ + * { + * "formatted" : "55.0", + * "label" : "CPU: ", + * "postfix" : "", + * "prefix" : "", + * "value" : 55.017000000000003, + * "valueType" : "Temperature" + * } + * ], + * "status" : 0, + * "status_name" : "idle", + * "time" : "Sun Jan 07 19:15:25 EST 2024", + * "timeStr" : "07:15 PM", + * "timeStrFull" : "07:15:25 PM", + * "time_elapsed" : "00:00", + * "time_remaining" : "00:00", + * "uptime" : "2 days, 01:30:04", + * "uptimeDays" : 2.0625462962962962, + * "uptimeHours" : 1.5011111111111111, + * "uptimeMinutes" : 30.066666666666666, + * "uptimeSeconds" : 4, + * "uptimeStr" : "2 days, 1 hours, 30 minutes, 4 seconds", + * "uptimeTotalSeconds" : 178204, + * "uuid" : "M1-10000000fd93cfe5", + * "volume" : 48 + * } + * + */ + @SerializedName("status") + @Expose + public int status; + + @SerializedName("status_name") + @Expose + public String status_name; + + @SerializedName("mode_name") + @Expose + public String mode_name; + + @SerializedName("current_sequence") + @Expose + public String current_sequence; + + @SerializedName("current_song") + @Expose + public String current_song; + + @SerializedName("time_elapsed") + @Expose + public String time_elapsed; + + @SerializedName("uptimeTotalSeconds") + @Expose + public long uptimeTotalSeconds; + + @SerializedName("seconds_played") + @Expose + public int seconds_played; + + @SerializedName("seconds_remaining") + @Expose + public int seconds_remaining; + + @SerializedName("volume") + @Expose + public int volume; + + @SerializedName("uuid") + @Expose + public String uuid; + + @SerializedName("multisync") + @Expose + public boolean multisync; + + @SerializedName("current_playlist") + @Expose + public FPPPlaylist current_playlist; + + // public String getStatus() { + // return status_name; + // } + + // public String getMode() { + // return mode_name; + // } +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/Helper.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/Helper.java new file mode 100644 index 0000000000000..680fe48bede15 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/Helper.java @@ -0,0 +1,65 @@ +/** + * 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 Helper} Removes the need for any external JSON libs + * + * @author Scott Hanson - Initial contribution + */ +@NonNullByDefault +public class Helper { + /** + * resolveJSON will return a value from any key/path that you give and the string can be terminated by any ,}" + * characters. + * + */ + public static String resolveJSON(String messageJSON, String jsonPath, int resultMaxLength) { + String result = ""; + int index = 0; + index = messageJSON.indexOf(jsonPath); + if (index != -1) { + if ((index + jsonPath.length() + resultMaxLength) > messageJSON.length()) { + result = (messageJSON.substring(index + jsonPath.length(), messageJSON.length())); + } else { + result = (messageJSON.substring(index + jsonPath.length(), + index + jsonPath.length() + resultMaxLength)); + } + index = result.indexOf(','); + if (index == -1) { + index = result.indexOf('"'); + if (index == -1) { + index = result.indexOf('}'); + if (index == -1) { + return result; + } else { + return result.substring(0, index); + } + } else { + return result.substring(0, index); + } + } else { + result = result.substring(0, index); + index = result.indexOf('"'); + if (index == -1) { + return result; + } else { + return result.substring(0, index); + } + } + } + return ""; + } +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java new file mode 100644 index 0000000000000..5ff00560ef6d5 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java @@ -0,0 +1,266 @@ +/** + * 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.handler; + +import static org.openhab.binding.mqtt.fpp.internal.FPPBindingConstants.*; + +import java.io.ByteArrayInputStream; +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; +import java.util.Properties; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.mqtt.fpp.internal.ConfigOptions; +import org.openhab.binding.mqtt.fpp.internal.FPPStatus; +import org.openhab.binding.mqtt.handler.AbstractBrokerHandler; +import org.openhab.core.io.net.http.HttpUtil; +import org.openhab.core.io.transport.mqtt.MqttBrokerConnection; +import org.openhab.core.io.transport.mqtt.MqttMessageSubscriber; +import org.openhab.core.library.types.IncreaseDecreaseType; +import org.openhab.core.library.types.NextPreviousType; +import org.openhab.core.library.types.OnOffType; +import org.openhab.core.library.types.PercentType; +import org.openhab.core.library.types.PlayPauseType; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.types.StringType; +import org.openhab.core.thing.Bridge; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.thing.ThingRegistry; +import org.openhab.core.thing.ThingStatus; +import org.openhab.core.thing.ThingStatusDetail; +import org.openhab.core.thing.ThingStatusInfo; +import org.openhab.core.thing.binding.BaseThingHandler; +import org.openhab.core.thing.binding.ThingHandler; +import org.openhab.core.types.Command; +import org.openhab.core.types.RefreshType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; + +import tech.units.indriya.unit.Units; + +/** + * The {@link FPPPlayerHandler} is responsible for handling commands of the globes, which are then + * sent to one of the bridges to be sent out by MQTT. + * + * @author Scott Hanson - Initial contribution + */ +@NonNullByDefault +public class FPPPlayerHandler extends BaseThingHandler implements MqttMessageSubscriber { + // these are all constants used in color conversion calcuations. + // strings are necessary to prevent floating point loss of precision + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + private @Nullable MqttBrokerConnection connection; + private ThingRegistry thingRegistry; + + private String fullStatusTopic = ""; + private String fullVersionTopic = ""; + private String fullCommandTopic = ""; + private int lastKnownVolume = 50; + private ConfigOptions config = new ConfigOptions(); + + private final Gson gson = new Gson(); + + public FPPPlayerHandler(Thing thing, ThingRegistry thingRegistry) { + super(thing); + this.thingRegistry = thingRegistry; + } + + private void processIncomingState(String messageJSON) { + // Need to handle State and Level at the same time to process level=0 as off// + FPPStatus data = gson.fromJson(messageJSON, FPPStatus.class); + updateState(CHANNEL_STATUS, new StringType(data.status_name)); + updateState(CHANNEL_PLAYER, data.status == 1 ? PlayPauseType.PLAY : PlayPauseType.PAUSE); + lastKnownVolume = data.volume; + updateState(CHANNEL_VOLUME, new PercentType(data.volume)); + updateState(CHANNEL_MODE, new StringType(data.mode_name)); + updateState(CHANNEL_CURRENT_SEQUENCE, new StringType(data.current_sequence)); + updateState(CHANNEL_CURRENT_SONG, new StringType(data.current_song)); + updateState(CHANNEL_CURRENT_PLAYLIST, new StringType(data.current_playlist.playlist)); + updateState(CHANNEL_UUID, new StringType(data.uuid)); + updateState(CHANNEL_SEC_PLAYED, new QuantityType<>(new BigDecimal(data.seconds_played), Units.SECOND)); + updateState(CHANNEL_SEC_REMAINING, new QuantityType<>(new BigDecimal(data.seconds_remaining), Units.SECOND)); + updateState(CHANNEL_UPTIME, new QuantityType<>(new BigDecimal(data.uptimeTotalSeconds), Units.SECOND)); + } + + void handleLevelColour(Command command) { + if (command instanceof OnOffType) { + + } else if (command instanceof IncreaseDecreaseType) { + + // sendMQTT("{\"state\":\"ON\",\"level\":" + savedLevel.intValue() + "}"); + return; + } else if (command instanceof PercentType percentType) { + // sendMQTT("{\"state\":\"ON\",\"level\":" + command + "}"); + return; + } + } + + @Override + public void handleCommand(ChannelUID channelUID, Command command) { + if (command instanceof RefreshType) { + return; + } + String channelId = channelUID.getId(); + if (channelId.equals(CHANNEL_PLAYER)) { + if (command == PlayPauseType.PAUSE || command == OnOffType.OFF) { + executeGet("/api/playlists/stop"); + } else if (command == PlayPauseType.PLAY || command == OnOffType.ON) { + + } else if (command == NextPreviousType.NEXT) { + executeGet("/api/command/Next Playlist Item"); + } else if (command == NextPreviousType.PREVIOUS) { + executeGet("/api/command/Prev Playlist Item"); + } + } + if (channelId.equals(CHANNEL_VOLUME)) { + Integer volume = null; + if (command instanceof PercentType percentCommand) { + volume = percentCommand.intValue(); + } else if (command == OnOffType.OFF) { + volume = 0; + } else if (command == OnOffType.ON) { + volume = lastKnownVolume; + } else if (command == IncreaseDecreaseType.INCREASE) { + if (lastKnownVolume < 100) { + lastKnownVolume++; + volume = lastKnownVolume; + } + } else if (command == IncreaseDecreaseType.DECREASE) { + if (lastKnownVolume > 0) { + lastKnownVolume--; + volume = lastKnownVolume; + } + } + if (volume != null) { + lastKnownVolume = volume; + // { "volume": 34 } + executePost("/api/system/volume", "{\"volume\":" + lastKnownVolume + "}"); + updateState(CHANNEL_VOLUME, new PercentType(lastKnownVolume)); + } + } + } + + @Override + public void initialize() { + config = getConfigAs(ConfigOptions.class); + + fullStatusTopic = config.playerMQTT + "/" + STATUS_TOPIC; + fullVersionTopic = config.playerMQTT + "/" + VERSION_TOPIC; + // Need to remove the lowercase x from 0x12AB in case it contains all numbers + + bridgeStatusChanged(getBridgeStatus()); + } + + @Override + public void processMessage(String topic, byte[] payload) { + String state = new String(payload, StandardCharsets.UTF_8); + logger.trace("Received the following new FPP state:{}:{}", topic, state); + + if (topic.endsWith(STATUS_TOPIC)) { + processIncomingState(state); + } else if (topic.endsWith(VERSION_TOPIC)) { + updateState(CHANNEL_VERSION, new StringType(state)); + updateStatus(ThingStatus.ONLINE); + } + } + + public ThingStatusInfo getBridgeStatus() { + Bridge b = getBridge(); + if (b != null) { + return b.getStatusInfo(); + } else { + return new ThingStatusInfo(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, null); + } + } + + @Override + public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { + if (bridgeStatusInfo.getStatus() == ThingStatus.OFFLINE) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE); + connection = null; + return; + } + if (bridgeStatusInfo.getStatus() != ThingStatus.ONLINE) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR); + return; + } + + Bridge localBridge = this.getBridge(); + if (localBridge == null) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED, + "Bridge is missing or offline, you need to setup a working MQTT broker first."); + return; + } + ThingHandler handler = localBridge.getHandler(); + if (handler instanceof AbstractBrokerHandler abh) { + final MqttBrokerConnection connection; + try { + connection = abh.getConnectionAsync().get(500, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException ignored) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED, + "Bridge handler has no valid broker connection!"); + return; + } + this.connection = connection; + updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.CONFIGURATION_PENDING, + "Waiting for 'fpp/status: connected' MQTT message to be received. Check hub has 'MQTT Client Status Topic' configured."); + connection.subscribe(fullStatusTopic, this); + connection.subscribe(fullVersionTopic, this); + } + return; + } + + private @Nullable String executeGet(String url) { + String response = null; + try { + response = HttpUtil.executeUrl("GET", "http://" + config.playerIP + url, 5000); + + } catch (Exception e) { + logger.error("Failed HTTP Post", e); + } + return response; + } + + private boolean executePost(String url, String json) { + try { + Properties header = new Properties(); + header.put("Accept", "application/json"); + // header.put("Connection", "keep-alive"); + header.put("Content-Type", "application/json"); + String response = HttpUtil.executeUrl("POST", "http://" + config.playerIP + url, header, + new ByteArrayInputStream(json.getBytes()), "application/json", 5000); + + return !response.isEmpty(); + } catch (Exception e) { + logger.error("Failed HTTP Post", e); + } + return false; + } + + @Override + public void dispose() { + MqttBrokerConnection localConnection = connection; + if (localConnection != null) { + localConnection.unsubscribe(fullStatusTopic, this); + localConnection.unsubscribe(fullVersionTopic, this); + } + } +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml new file mode 100644 index 0000000000000..71af1d7cd8526 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml @@ -0,0 +1,20 @@ + + + + + + network-address + + Player IP Address + + + name + + MQTT Player Status Topic + + + + diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties new file mode 100644 index 0000000000000..1241a14c776a3 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties @@ -0,0 +1,18 @@ +# thing types + +thing.label.player=FPP Player +thing.description.player=FPP Player + +# thing types config + +thing-type.config.mqtt.player.playerIP.label = FPP IP +thing-type.config.mqtt.player.playerIP.description = FPP IP. +thing-type.config.mqtt.player.playerMQTT.label = MQTT Path +thing-type.config.mqtt.player.playerMQTT.description = MQTT Path. + +# channel types + +channel-type.mqtt.status.label = Player Status +channel-type.mqtt.status.description = Player Status. +channel-type.mqtt.version.label = Player Version +channel-type.mqtt.version.description = Player Version. diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt_it.properties b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt_it.properties new file mode 100644 index 0000000000000..7d9969e6d9edf --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt_it.properties @@ -0,0 +1,81 @@ +# thing types + +thing-type.mqtt.cct.label = Milight CCT +thing-type.mqtt.cct.description = Lampada LED con comandi per bianchi freddi e caldi +thing-type.mqtt.fut089.label = Milight FUT089 +thing-type.mqtt.fut089.description = Usa questo quando il tuo telecomando è il nuovo tipo con 8 gruppi chiamato FUT089 e le tue lampadine sono rgb_cct +thing-type.mqtt.fut091.label = Milight FUT091 +thing-type.mqtt.fut091.description = Usa questo quando il tuo telecomando è il fut091 più recente e le tue lampadine sono cct +thing-type.mqtt.rgb.label = Milight RGB +thing-type.mqtt.rgb.description = Lampadina RGB senza bianco +thing-type.mqtt.rgb_cct.label = Milight RGBCCT +thing-type.mqtt.rgb_cct.description = Lampada LED a colori, e con bianchi freddi e caldi. +thing-type.mqtt.rgbw.label = Milight RGBW +thing-type.mqtt.rgbw.description = Lampadina RGB con un bianco fisso + +# thing types config + +thing-type.config.mqtt.cct.dimmedCT.label = Temp Colore Impostato +thing-type.config.mqtt.cct.dimmedCT.description = Lampadine tradizionali diventano più calde quando sono regolate. Imposta a 370 o lascia bianco per disabilitare. +thing-type.config.mqtt.cct.oneTriggersNightMode.label = 1% Attiva modalità Notturna +thing-type.config.mqtt.cct.oneTriggersNightMode.description = L'1% su un cursore attiverà la Modalità Notte. +thing-type.config.mqtt.rgb.oneTriggersNightMode.label = 1% Attiva Modalità Notturna +thing-type.config.mqtt.rgb.oneTriggersNightMode.description = L'1% su un cursore attiverà la Modalità Notte. +thing-type.config.mqtt.rgb.powerFailsToMinimum.label = Regolazione se fallisce Accensione +thing-type.config.mqtt.rgb.powerFailsToMinimum.description = Se le luci perdono luminosità quando vengono spente gradualmente, le luci torneranno alla luminosità minima per impostazione predefinita. +thing-type.config.mqtt.rgbandcct.dimmedCT.label = Temp Colore Impostato +thing-type.config.mqtt.rgbandcct.dimmedCT.description = Le tradizionali lampadine sono più calde più sono luminose. Imposta a 370, o lasciare vuoto per disabilitare. +thing-type.config.mqtt.rgbandcct.duvThreshold.label = Soglia Duv +thing-type.config.mqtt.rgbandcct.duvThreshold.description = Valori Duv uguali o inferiori a questo valore su un controllo di colore RGBWW attiveranno la modalità bianca alla temperatura di colore appropriata. 1 disabiliterà effettivamente questa funzione. Vedi questo link per ottenere maggiori informazioni su come viene calcolato. +thing-type.config.mqtt.rgbandcct.favouriteWhite.label = Bianco Preferito +thing-type.config.mqtt.rgbandcct.favouriteWhite.description = Quando uno shortcut attiva la modalità bianca, usala per il colore bianco. +thing-type.config.mqtt.rgbandcct.oneTriggersNightMode.label = 1% Attiva modalità Notturna +thing-type.config.mqtt.rgbandcct.oneTriggersNightMode.description = L'1% del cursore attiverà la Modalità Notte. +thing-type.config.mqtt.rgbandcct.powerFailsToMinimum.label = Regolazione se fallisce Accensione +thing-type.config.mqtt.rgbandcct.powerFailsToMinimum.description = Se manca l'alimentazione alle luci, si riaccenderanno alla luminosità minima. +thing-type.config.mqtt.rgbandcct.whiteHue.label = Tonalità Bianca +thing-type.config.mqtt.rgbandcct.whiteHue.description = Quando entrambi i valori WhiteHue e WhiteSat sono visti dal binding, si attiveranno il LED bianchi. +thing-type.config.mqtt.rgbandcct.whiteSat.label = Saturazione Bianca +thing-type.config.mqtt.rgbandcct.whiteSat.description = Quando entrambi i valori WhiteHue e WhiteSat sono visti dal binding, si attiveranno i LED bianchi. +thing-type.config.mqtt.rgbw.oneTriggersNightMode.label = 1% Attiva modalità Notturna +thing-type.config.mqtt.rgbw.oneTriggersNightMode.description = L'1% sul cursore attiverà la Modalità Notte. +thing-type.config.mqtt.rgbw.powerFailsToMinimum.label = Regolazione se fallisce Accensione +thing-type.config.mqtt.rgbw.powerFailsToMinimum.description = Se manca l'alimentazione alle luci, si riaccenderanno alla luminosità minima. +thing-type.config.mqtt.rgbw.whiteHue.label = Tonalità Bianca +thing-type.config.mqtt.rgbw.whiteHue.description = Quando entrambi i valori WhiteHue e WhiteSat sono visti dal binding, si attiveranno il LED bianchi. +thing-type.config.mqtt.rgbw.whiteSat.label = Saturazione Bianca +thing-type.config.mqtt.rgbw.whiteSat.description = Quando entrambi i valori WhiteHue e WhiteSat sono visti dal binding, si attiveranno il LED bianchi. +thing-type.config.mqtt.rgbw.whiteThreshold.label = Soglia Bianco +thing-type.config.mqtt.rgbw.whiteThreshold.description = I valori di saturazione uguali o inferiori a questo valore su un controllo di colore RGBW attiveranno la modalità bianco. -1 disabiliterà questa funzione. + +# channel types + +channel-type.mqtt.bulbMode.label = Modalità Lampadina +channel-type.mqtt.bulbMode.description = Mostra il modo in cui è la lampadina in questo momento. +channel-type.mqtt.bulbMode.state.option.white = bianco +channel-type.mqtt.bulbMode.state.option.color = colore +channel-type.mqtt.bulbMode.state.option.scene = scena +channel-type.mqtt.bulbMode.state.option.night = notte +channel-type.mqtt.command.label = Command +channel-type.mqtt.command.description = Invia un comando diretto alla/e lampadina/e. +channel-type.mqtt.command.state.option.next_mode = Modalità Successiva +channel-type.mqtt.command.state.option.previous_mode = Modalità Precedente +channel-type.mqtt.command.state.option.mode_speed_up = Modalità Veloce +channel-type.mqtt.command.state.option.mode_speed_down = Modalità Lenta +channel-type.mqtt.command.state.option.set_white = Imposta Bianco +channel-type.mqtt.command.state.option.level_down = Livello Inferiore +channel-type.mqtt.command.state.option.level_up = Livello Superiore +channel-type.mqtt.command.state.option.temperature_down = Abbassa Temperatura +channel-type.mqtt.command.state.option.temperature_up = Alza Temperatura +channel-type.mqtt.command.state.option.night_mode = Modalità Notturna +channel-type.mqtt.discoMode.label = Modalità Discoteca +channel-type.mqtt.discoMode.description = Passa direttamente alla modalità Discoteca. +channel-type.mqtt.discoMode.state.option.0 = Disco 0 +channel-type.mqtt.discoMode.state.option.1 = Disco 1 +channel-type.mqtt.discoMode.state.option.2 = Disco 2 +channel-type.mqtt.discoMode.state.option.3 = Disco 3 +channel-type.mqtt.discoMode.state.option.4 = Disco 4 +channel-type.mqtt.discoMode.state.option.5 = Disco 5 +channel-type.mqtt.discoMode.state.option.6 = Disco 6 +channel-type.mqtt.discoMode.state.option.7 = Disco 7 +channel-type.mqtt.discoMode.state.option.8 = Disco 8 diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml new file mode 100644 index 0000000000000..4cceda46edc35 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml @@ -0,0 +1,99 @@ + + + + + + + + + FPP Player. + + + + + + + + + + + + + + + + + + String + + FPP Player Status + + + + String + + FPP Version + + + + String + + FPP Player Mode + + + + String + + FPP Current Sequence + + + + String + + FPP Current Song + + + + String + + FPP Current Playlist + + + + Number:Time + + FPP Seconds Played + + + + Number:Time + + FPP Seconds Remaining + + + + Number:Time + + FPP uptime (time after start) + + + + String + + FPP Hardware UUID + + + + Player + + FPP Player Control + + + Dimmer + + FPP Volume of the sound + + diff --git a/bundles/pom.xml b/bundles/pom.xml index 14f345d1dfb22..65af78fff7157 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -253,6 +253,7 @@ org.openhab.binding.mpd org.openhab.binding.mqtt org.openhab.binding.mqtt.espmilighthub + org.openhab.binding.mqtt.fpp org.openhab.binding.mqtt.generic org.openhab.binding.mqtt.homeassistant org.openhab.binding.mqtt.homie From 78f992b812f0aa6e16fc6f03d465edcc15bed107 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 17 Jan 2024 12:21:36 -0500 Subject: [PATCH 02/20] added testing support Signed-off-by: Scott Hanson --- .../fpp/internal/FPPBindingConstants.java | 6 ++++ .../binding/mqtt/fpp/internal/FPPStatus.java | 4 +++ .../internal/handler/FPPPlayerHandler.java | 33 ++++++++++++------- .../resources/OH-INF/thing/thing-types.xml | 27 +++++++++++++++ 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java index f3b346aa4a206..1a10a44dd2bad 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java @@ -51,8 +51,14 @@ public class FPPBindingConstants { public static final String CHANNEL_UPTIME = "fppUptime"; public static final String CHANNEL_UUID = "fppUUID"; public static final String CHANNEL_VERSION = "fppVersion"; + public static final String CHANNEL_BRIDGING = "fppBridging"; + public static final String CHANNEL_MULTISYNC = "fppMultisync"; + public static final String CHANNEL_TESTING = "fppTesting"; + public static final String CHANNEL_LAST_PLAYLIST = "fppLastPlaylist"; // Status public static final String CONNECTED = "connected"; public static final String CHANNEL_STATUS_NAME = "status_name"; + + public static final String TESTING = "testing"; } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java index 73bd886ebbe1b..d5ce72ded5186 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java @@ -147,6 +147,10 @@ public class FPPStatus { @Expose public FPPPlaylist current_playlist; + @SerializedName("bridging") + @Expose + public boolean bridging; + // public String getStatus() { // return status_name; // } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java index 5ff00560ef6d5..a555d8d617704 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java @@ -74,6 +74,7 @@ public class FPPPlayerHandler extends BaseThingHandler implements MqttMessageSub private String fullVersionTopic = ""; private String fullCommandTopic = ""; private int lastKnownVolume = 50; + private String lastPlaylist = ""; private ConfigOptions config = new ConfigOptions(); private final Gson gson = new Gson(); @@ -98,18 +99,14 @@ private void processIncomingState(String messageJSON) { updateState(CHANNEL_SEC_PLAYED, new QuantityType<>(new BigDecimal(data.seconds_played), Units.SECOND)); updateState(CHANNEL_SEC_REMAINING, new QuantityType<>(new BigDecimal(data.seconds_remaining), Units.SECOND)); updateState(CHANNEL_UPTIME, new QuantityType<>(new BigDecimal(data.uptimeTotalSeconds), Units.SECOND)); - } - - void handleLevelColour(Command command) { - if (command instanceof OnOffType) { + updateState(CHANNEL_BRIDGING, OnOffType.from(data.bridging)); + updateState(CHANNEL_MULTISYNC, OnOffType.from(data.multisync));// - } else if (command instanceof IncreaseDecreaseType) { + updateState(CHANNEL_TESTING, data.status_name.equals(TESTING) ? OnOffType.ON : OnOffType.OFF); - // sendMQTT("{\"state\":\"ON\",\"level\":" + savedLevel.intValue() + "}"); - return; - } else if (command instanceof PercentType percentType) { - // sendMQTT("{\"state\":\"ON\",\"level\":" + command + "}"); - return; + if (!data.current_playlist.playlist.isEmpty()) { + lastPlaylist = data.current_playlist.playlist; + updateState(CHANNEL_LAST_PLAYLIST, new StringType(lastPlaylist)); } } @@ -123,7 +120,9 @@ public void handleCommand(ChannelUID channelUID, Command command) { if (command == PlayPauseType.PAUSE || command == OnOffType.OFF) { executeGet("/api/playlists/stop"); } else if (command == PlayPauseType.PLAY || command == OnOffType.ON) { - + if (!lastPlaylist.isEmpty()) { + executeGet("/api/playlist/" + lastPlaylist + "/start"); + } } else if (command == NextPreviousType.NEXT) { executeGet("/api/command/Next Playlist Item"); } else if (command == NextPreviousType.PREVIOUS) { @@ -156,6 +155,18 @@ public void handleCommand(ChannelUID channelUID, Command command) { updateState(CHANNEL_VOLUME, new PercentType(lastKnownVolume)); } } + if (channelId.equals(CHANNEL_TESTING)) { + if (command == OnOffType.OFF) { + executePost("/api/testmode", GetTestMode(0)); + } else if (command == OnOffType.ON) { + executePost("/api/testmode", GetTestMode(1)); + } + } + } + + private String GetTestMode(int enable) { + return "{\"mode\":\"RGBChase\",\"subMode\":\"RGBChase-RGB\",\"cycleMS\":1000,\"colorPattern\":\"FF000000FF000000FF\",\"enabled\":" + + enable + ",\"channelSet\": \"1-520\",\"channelSetType\": \"channelRange\"}"; } @Override diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml index 4cceda46edc35..08b943e6f9db7 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml @@ -23,6 +23,10 @@ + + + + @@ -96,4 +100,27 @@ FPP Volume of the sound + + Switch + + FPP Is Bridging + + + + Switch + + FPP Multisync + + + + Switch + + FPP Is Testing + + + String + + FPP Last Run Playlist + + From 7e39fdfef0aa92247749b2cf509299e6d215d9ca Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 17 Jan 2024 12:45:58 -0500 Subject: [PATCH 03/20] added next schedule channels Signed-off-by: Scott Hanson --- .../fpp/internal/FPPBindingConstants.java | 8 +++ .../mqtt/fpp/internal/FPPCurrentPlaylist.java | 41 +++++++++++++++ .../mqtt/fpp/internal/FPPNextPlaylist.java | 46 +++++++++++++++++ .../mqtt/fpp/internal/FPPScheduler.java | 41 +++++++++++++++ .../binding/mqtt/fpp/internal/FPPStatus.java | 4 ++ .../internal/handler/FPPPlayerHandler.java | 25 +++++---- .../resources/OH-INF/thing/thing-types.xml | 51 ++++++++++++++++++- 7 files changed, 206 insertions(+), 10 deletions(-) create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java create mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java index 1a10a44dd2bad..d86ca2738f45a 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java @@ -56,6 +56,14 @@ public class FPPBindingConstants { public static final String CHANNEL_TESTING = "fppTesting"; public static final String CHANNEL_LAST_PLAYLIST = "fppLastPlaylist"; + public static final String CHANNEL_SCHEDULERSTATUS = "fppSchedulerStatus"; + public static final String CHANNEL_SCHEDULERCURRENTPLAYLIST = "fppSchedulerCurrentPlaylist"; + public static final String CHANNEL_SCHEDULERCURRENTPLAYLISTSTART = "fppSchedulerCurrentPlaylistStart"; + public static final String CHANNEL_SCHEDULERCURRENTPLAYLISTEND = "fppSchedulerCurrentPlaylistEnd"; + public static final String CHANNEL_SCHEDULERCURRENTPLAYLISTSTOPTYPE = "fppSchedulerCurrentPlaylistStopType"; + public static final String CHANNEL_SCHEDULERNEXTPLAYLIST = "fppSchedulerNextPlaylist"; + public static final String CHANNEL_SCHEDULERNEXTPLAYLISTSTART = "fppSchedulerNextPlaylistStart"; + // Status public static final String CONNECTED = "connected"; public static final String CHANNEL_STATUS_NAME = "status_name"; diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java new file mode 100644 index 0000000000000..8067943a5825b --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java @@ -0,0 +1,41 @@ +package org.openhab.binding.mqtt.fpp.internal; + +/** + * Copyright (c) 2010-2019 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 + */ + +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; +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java new file mode 100644 index 0000000000000..a3c3b859d080e --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java @@ -0,0 +1,46 @@ +package org.openhab.binding.mqtt.fpp.internal; + +/** + * Copyright (c) 2010-2019 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 + */ + +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; +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java new file mode 100644 index 0000000000000..08a33f3f97039 --- /dev/null +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java @@ -0,0 +1,41 @@ +package org.openhab.binding.mqtt.fpp.internal; + +/** + * Copyright (c) 2010-2019 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 + */ + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +/** + * The {@link FPPPlaylist} is responsible for storing + * the FPP JSON FPPScheduler data. + * + * @author Scott Hanson - Initial contribution + */ +public class FPPScheduler { + @SerializedName("currentPlaylist") + @Expose + public FPPCurrentPlaylist currentPlaylist; + + @SerializedName("nextPlaylist") + @Expose + public FPPNextPlaylist nextPlaylist; + + @SerializedName("enabled") + @Expose + public int enabled; + + @SerializedName("status") + @Expose + public String status; +} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java index d5ce72ded5186..6c2becd072b3c 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java @@ -151,6 +151,10 @@ public class FPPStatus { @Expose public boolean bridging; + @SerializedName("scheduler") + @Expose + public FPPScheduler scheduler; + // public String getStatus() { // return status_name; // } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java index a555d8d617704..081d1eafe0566 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java @@ -68,11 +68,9 @@ public class FPPPlayerHandler extends BaseThingHandler implements MqttMessageSub private final Logger logger = LoggerFactory.getLogger(this.getClass()); private @Nullable MqttBrokerConnection connection; - private ThingRegistry thingRegistry; private String fullStatusTopic = ""; private String fullVersionTopic = ""; - private String fullCommandTopic = ""; private int lastKnownVolume = 50; private String lastPlaylist = ""; private ConfigOptions config = new ConfigOptions(); @@ -81,11 +79,9 @@ public class FPPPlayerHandler extends BaseThingHandler implements MqttMessageSub public FPPPlayerHandler(Thing thing, ThingRegistry thingRegistry) { super(thing); - this.thingRegistry = thingRegistry; } private void processIncomingState(String messageJSON) { - // Need to handle State and Level at the same time to process level=0 as off// FPPStatus data = gson.fromJson(messageJSON, FPPStatus.class); updateState(CHANNEL_STATUS, new StringType(data.status_name)); updateState(CHANNEL_PLAYER, data.status == 1 ? PlayPauseType.PLAY : PlayPauseType.PAUSE); @@ -100,10 +96,24 @@ private void processIncomingState(String messageJSON) { updateState(CHANNEL_SEC_REMAINING, new QuantityType<>(new BigDecimal(data.seconds_remaining), Units.SECOND)); updateState(CHANNEL_UPTIME, new QuantityType<>(new BigDecimal(data.uptimeTotalSeconds), Units.SECOND)); updateState(CHANNEL_BRIDGING, OnOffType.from(data.bridging)); - updateState(CHANNEL_MULTISYNC, OnOffType.from(data.multisync));// - + updateState(CHANNEL_MULTISYNC, OnOffType.from(data.multisync)); updateState(CHANNEL_TESTING, data.status_name.equals(TESTING) ? OnOffType.ON : OnOffType.OFF); + updateState(CHANNEL_SCHEDULERSTATUS, new StringType(data.scheduler.status)); + updateState(CHANNEL_SCHEDULERNEXTPLAYLIST, new StringType(data.scheduler.nextPlaylist.playlistName)); + updateState(CHANNEL_SCHEDULERNEXTPLAYLISTSTART, + new StringType(data.scheduler.nextPlaylist.scheduledStartTimeStr)); + + if (data.scheduler.currentPlaylist != null) { + updateState(CHANNEL_SCHEDULERCURRENTPLAYLIST, new StringType(data.scheduler.currentPlaylist.playlistName)); + updateState(CHANNEL_SCHEDULERCURRENTPLAYLISTSTART, + new StringType(data.scheduler.currentPlaylist.playlistName)); + updateState(CHANNEL_SCHEDULERCURRENTPLAYLISTEND, + new StringType(data.scheduler.currentPlaylist.playlistName)); + updateState(CHANNEL_SCHEDULERCURRENTPLAYLISTSTOPTYPE, + new StringType(data.scheduler.currentPlaylist.playlistName)); + } + if (!data.current_playlist.playlist.isEmpty()) { lastPlaylist = data.current_playlist.playlist; updateState(CHANNEL_LAST_PLAYLIST, new StringType(lastPlaylist)); @@ -150,7 +160,6 @@ public void handleCommand(ChannelUID channelUID, Command command) { } if (volume != null) { lastKnownVolume = volume; - // { "volume": 34 } executePost("/api/system/volume", "{\"volume\":" + lastKnownVolume + "}"); updateState(CHANNEL_VOLUME, new PercentType(lastKnownVolume)); } @@ -175,8 +184,6 @@ public void initialize() { fullStatusTopic = config.playerMQTT + "/" + STATUS_TOPIC; fullVersionTopic = config.playerMQTT + "/" + VERSION_TOPIC; - // Need to remove the lowercase x from 0x12AB in case it contains all numbers - bridgeStatusChanged(getBridgeStatus()); } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml index 08b943e6f9db7..c1eca982d0b8e 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml @@ -27,6 +27,13 @@ + + + + + + + @@ -117,10 +124,52 @@ FPP Is Testing - + String FPP Last Run Playlist + + String + + FPP Scheduler Status + + + + String + + FPP Current Playlist + + + + String + + FPP Scheduler Current Playlist Start Time + + + + String + + FPP Scheduler Current Playlist End Time + + + + String + + FPP Scheduler Current Playlist Stop Type + + + + String + + FPP Scheduler Next Playlist + + + + String + + FPP Scheduler Next Playlist Start Time + + From 4898a7ce959106c47b825a7a18ae08ab3f5b8269 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 17 Jan 2024 12:47:44 -0500 Subject: [PATCH 04/20] fix channels Signed-off-by: Scott Hanson --- .../binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java index 081d1eafe0566..24eb2fde5ea15 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java @@ -175,7 +175,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { private String GetTestMode(int enable) { return "{\"mode\":\"RGBChase\",\"subMode\":\"RGBChase-RGB\",\"cycleMS\":1000,\"colorPattern\":\"FF000000FF000000FF\",\"enabled\":" - + enable + ",\"channelSet\": \"1-520\",\"channelSetType\": \"channelRange\"}"; + + enable + ",\"channelSet\": \"1-1048576\",\"channelSetType\": \"channelRange\"}"; } @Override From e482e063e98012c7d2ed75d77e278b61e6ae0d50 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 17 Jan 2024 12:51:32 -0500 Subject: [PATCH 05/20] fix copyright Signed-off-by: Scott Hanson --- .../openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java | 2 +- .../openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java | 2 +- .../org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java | 2 +- .../org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java | 2 +- .../java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java | 2 +- .../binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java | 4 ---- 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java index 8067943a5825b..af15b09b9a5ae 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java @@ -1,7 +1,7 @@ package org.openhab.binding.mqtt.fpp.internal; /** - * Copyright (c) 2010-2019 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java index a3c3b859d080e..2d5f7d730ee98 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java @@ -1,7 +1,7 @@ package org.openhab.binding.mqtt.fpp.internal; /** - * Copyright (c) 2010-2019 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java index b3f5ea82b6464..ef4b8011e926e 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java @@ -1,7 +1,7 @@ package org.openhab.binding.mqtt.fpp.internal; /** - * Copyright (c) 2010-2019 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java index 08a33f3f97039..1eb7c2d9ce7a2 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java @@ -1,7 +1,7 @@ package org.openhab.binding.mqtt.fpp.internal; /** - * Copyright (c) 2010-2019 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java index 6c2becd072b3c..9f82ec3bce720 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java @@ -1,7 +1,7 @@ package org.openhab.binding.mqtt.fpp.internal; /** - * Copyright (c) 2010-2019 Contributors to the openHAB project + * Copyright (c) 2010-2024 Contributors to the openHAB project * * See the NOTICE file(s) distributed with this work for additional * information. diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java index 24eb2fde5ea15..0eb7fed50f3b4 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java @@ -63,9 +63,6 @@ */ @NonNullByDefault public class FPPPlayerHandler extends BaseThingHandler implements MqttMessageSubscriber { - // these are all constants used in color conversion calcuations. - // strings are necessary to prevent floating point loss of precision - private final Logger logger = LoggerFactory.getLogger(this.getClass()); private @Nullable MqttBrokerConnection connection; @@ -261,7 +258,6 @@ private boolean executePost(String url, String json) { try { Properties header = new Properties(); header.put("Accept", "application/json"); - // header.put("Connection", "keep-alive"); header.put("Content-Type", "application/json"); String response = HttpUtil.executeUrl("POST", "http://" + config.playerIP + url, header, new ByteArrayInputStream(json.getBytes()), "application/json", 5000); From 6310c864cf44d8613fda42e8ab0a90a4d60e178f Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 17 Jan 2024 14:15:15 -0500 Subject: [PATCH 06/20] Update README.md Signed-off-by: Scott Hanson --- .../org.openhab.binding.mqtt.fpp/README.md | 86 +++++++++++-------- 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/README.md b/bundles/org.openhab.binding.mqtt.fpp/README.md index 28711e97dfc2b..2e06bedbfea2f 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/README.md +++ b/bundles/org.openhab.binding.mqtt.fpp/README.md @@ -1,32 +1,40 @@ # FPP Binding - -Note that the group 0 (or ALL group) is not auto discovered as a thing and thus has to be added manually if needed. +Binding to Controls Falcon Player (FPP) Devices. Uses MQTT to update status. Manually add an 'player' thing to get status. ## Thing Configuration | Parameter | Description | Required | Default | |-|-|-|-| -| `whiteHue` | When both the `whiteHue` and `whiteSat` values are seen by the binding it will trigger the white LEDS. Set to -1 to disable, 0 for Alexa, or 35 for Google Home. | Y | 35 | -| `whiteSat` | When both the whiteHue and whiteSat values are seen by the binding it will trigger the white LEDS. Set to -1 to disable, 100 for Alexa or 32 for Google Home. | Y | 32 | -| `favouriteWhite` | When one of the shortcuts triggers white mode, use this for the colour white instead of the default colour. | Y |200 | -| `dimmedCT` | Traditional globes grow warmer the more they are dimmed. Set this to 370, or leave blank to disable. | N | blank | -| `oneTriggersNightMode` | Night mode is a much lower level of light and this feature allows it to be auto selected when your fader/slider moves to 1%. NOTE: Night mode by design locks out some controls of a physical remote, so this feature is disabled by default. | Y | false | -| `powerFailsToMinimum` | If lights loose power from the power switch OR a power outage, they will default to using the lowest brightness if the light was turned off before the power failure occurred. | Y | true | -| `whiteThreshold` | This feature allows you to use a color control to change to using the real white LEDs when the saturation is equal to, or below this threshold. -1 will disable this feature. | Y | 12 | -| `duvThreshold` | This feature allows you to use a color control to change to using the real warm/cool white LEDs to set a white color temperature if the color is within a certain threshold of the block body curve. 1 will effectively disable this feature. The default settings maps well to Apple's HomeKit that will allow you to choose a color temperature, but sends it as an HSB value. See for more information. | Y | 0.003 | +| `playerIP` | IP Address of FPP Devive | Y | | +| `playerMQTT` | MQTT Topic of FPP Devive Status | Y | | ## Channels | Channel | Type | Description | |-|-|-| -| `level` | Dimmer | Level changes the brightness of the globe. Not present if the bulb supports the `colour` channel. | -| `colourTemperature` | Dimmer | Change from cool to warm white with this control. | -| `colourTemperatureAbs` | Number:Temperature | Colour temperature in mireds. | -| `colour` | Color | Allows you to change the colour, brightness and saturation of the globe. Can also be linked directly with a Dimmer item if you happen to have a bulb that doesn't support colour, but is controlled by a remote that normally does support colour. | -| `discoMode` | String | Switch to a Disco mode directly from a drop down list. | -| `bulbMode` | String (read only) | Displays the mode the bulb is currently in so that rules can determine if the globe is white, a color, disco modes or night mode are selected. | -| `command` | String | Sends the raw commands that the buttons on a remote send. | +| `fppPlayer` | Player | Play/Stop Current Playlist. | +| `fppVolume` | Dimmer | Playback Audio Volume. | +| `fppStatus` | String | Playback Status. | +| `fppVersion` | String | Software Version. | +| `fppMode` | String | Playback Mode. | +| `fppUptime` | Number:Time | Device Uptime. | +| `fppTesting` | Switch | Device is in Testing Mode. | +| `fppCurrentSequence` | String (read only) | Currently Playing Sequence File. | +| `fppCurrentSong` | String (read only) | Currently Playing Audio/Media File. | +| `fppCurrentPlaylist` | String (read only) | Currently Playing Playlist. | +| `fppSecPlayed` | Number:Time | Sequence Playback time in secs. | +| `fppSecRemaining` | Number:Time | Sequence Playback time remaining in secs. | +| `fppLastPlaylist` | String | Lasted Played Playlist. | +| `fppUUID` | String | Device UUID. | +| `fppBridging` | Switch | Is Recieving Bridge Data. | +| `fppMultisync` | Switch | Multisync Mode Enabled. | +| `fppSchedulerCurrentPlaylist` | String (read only) | Scheduler Current Playlist. | +| `fppSchedulerCurrentPlaylistStart` | String (read only) | Scheduler Current Playlist Start Time. | +| `fppSchedulerCurrentPlaylistEnd` | String (read only) | Scheduler Current Playlist End Time. | +| `fppSchedulerCurrentPlaylistStopType` | String (read only) | Scheduler Current Playlist End Type. | +| `fppSchedulerNextPlaylist` | String (read only) | Next Scheduled Playlist. | +| `fppSchedulerNextPlaylistStart` | String (read only) | Next Scheduled Start Time. | ## Full Example @@ -39,33 +47,43 @@ The first line in the things file will create a `broker` thing and this can be r ```java Bridge mqtt:broker:myBroker [ host="localhost", secure=false, password="*******", qos=1, username="user"] -Thing mqtt:rgb_cct:myBroker:0xE6C4 "Hallway" (mqtt:broker:myBroker) @ "MQTT" +Thing mqtt:player:myBroker:mainPlayer "Main Player" (mqtt:broker:myBroker) @ "MQTT" ``` *.items ```java -Dimmer Hallway_Level "Front Hall" {channel="mqtt:rgb_cct:myBroker:0xE6C4:colour"} -Dimmer Hallway_ColourTemperature "White Color Temp" {channel="mqtt:rgb_cct:myBroker:0xE6C4:colourTemperature"} -Number:Temperature Hallway_ColourTemperatureK "White Color Temp [%d %unit%]" {channel="mqtt:rgb_cct:myBroker:0xE6C4:colourTemperatureAbs", unit="K"} -Color Hallway_Colour "Front Hall" ["Lighting"] {channel="mqtt:rgb_cct:myBroker:0xE6C4:colour"} -String Hallway_DiscoMode "Disco Mode" {channel="mqtt:rgb_cct:myBroker:0xE6C4:discoMode"} -String Hallway_BulbCommand "Send Command" {channel="mqtt:rgb_cct:myBroker:0xE6C4:command"} -String Hallway_BulbMode "Bulb Mode" {channel="mqtt:rgb_cct:myBroker:0xE6C4:bulbMode"} - +Player FPP_Player "FPP Player" {channel="mqtt:player:myBroker:mainPlayer:fppPlayer"} +Dimmer Audio_Volume "Audio Volume" {channel="mqtt:player:myBroker:mainPlayer:fppVolume"} +String Current_Sequence "Current Sequence" {channel="mqtt:player:myBroker:mainPlayer:fppCurrentSequence"} +String Current_Song "Current Song" {channel="mqtt:player:myBroker:mainPlayer:fppCurrentSong"} +String Current_Playlist "Current Playlist" {channel="mqtt:player:myBroker:mainPlayer:fppCurrentPlaylist"} +String Status "FPP Status" {channel="mqtt:player:myBroker:mainPlayer:fppStatus"} +String Version "FPP Version" {channel="mqtt:player:myBroker:mainPlayer:fppVersion"} +String Mode "FPP Mode" {channel="mqtt:player:myBroker:mainPlayer:fppMode"} +String Last_Playlist "Last Playlist" {channel="mqtt:player:myBroker:mainPlayer:fppLastPlaylist"} +Number:Time Seconds_Played "Seconds Played [%d %unit%]" {channel="mqtt:player:myBroker:mainPlayer:fppSecPlayed"} +Number:Time Seconds_Remaining "Seconds Remaining [%d %unit%]" {channel="mqtt:player:myBroker:mainPlayer:fppSecRemaining"} +Switch Testing "Testing Mode" {channel="mqtt:player:myBroker:mainPlayer:fppTesting"} +Switch Multisync "Multisync" {channel="mqtt:player:myBroker:mainPlayer:fppMultisync"} ``` *.sitemap ```perl -Text label="Hallway" icon="light" +Text label="Main Player" { - Switch item=Hallway_Level - Slider item=Hallway_Level - Slider item=Hallway_ColourTemperature - Colorpicker item=Hallway_Colour - Selection item=Hallway_DiscoMode - Text item=Hallway_BulbMode - Switch item=Hallway_BulbCommand mappings=[next_mode='Mode +', previous_mode='Mode -', mode_speed_up='Speed +', mode_speed_down='Speed -', set_white='White', night_mode='Night' ] + 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 } ``` From b7001fbec77d3acffe403a65d96d70db3ad6e281 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 12 Jun 2024 12:13:26 -0400 Subject: [PATCH 07/20] Updated feature.xml Signed-off-by: Scott Hanson --- .../src/main/feature/feature.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/feature/feature.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/feature/feature.xml index 1f8b3a2cd5052..ca8ff9fdadfd0 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/feature/feature.xml +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/feature/feature.xml @@ -1,12 +1,12 @@ - + mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features - + openhab-runtime-base openhab-transport-mqtt mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt/${project.version} - mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.espmilighthub/${project.version} + mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.fpp/${project.version} From 578583156ddcdefb707c16e0866a7f95d1fa4341 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 12 Jun 2024 13:08:23 -0400 Subject: [PATCH 08/20] Updated thing ids Signed-off-by: Scott Hanson --- .../fpp/internal/FPPBindingConstants.java | 46 +++++----- .../resources/OH-INF/i18n/mqtt_it.properties | 81 ---------------- .../resources/OH-INF/thing/thing-types.xml | 92 +++++++++---------- 3 files changed, 69 insertions(+), 150 deletions(-) delete mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt_it.properties diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java index d86ca2738f45a..815d56fdaffe6 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java @@ -39,30 +39,30 @@ public class FPPBindingConstants { public static final Set SUPPORTED_THING_TYPES = Set.of(THING_TYPE_PLAYER); // Channels - public static final String CHANNEL_PLAYER = "fppPlayer"; - public static final String CHANNEL_STATUS = "fppStatus"; - public static final String CHANNEL_VOLUME = "fppVolume"; - public static final String CHANNEL_MODE = "fppMode"; - public static final String CHANNEL_CURRENT_SEQUENCE = "fppCurrentSequence"; - public static final String CHANNEL_CURRENT_SONG = "fppCurrentSong"; - public static final String CHANNEL_CURRENT_PLAYLIST = "fppCurrentPlaylist"; - public static final String CHANNEL_SEC_PLAYED = "fppSecPlayed"; - public static final String CHANNEL_SEC_REMAINING = "fppSecRemaining"; - public static final String CHANNEL_UPTIME = "fppUptime"; - public static final String CHANNEL_UUID = "fppUUID"; - public static final String CHANNEL_VERSION = "fppVersion"; - public static final String CHANNEL_BRIDGING = "fppBridging"; - public static final String CHANNEL_MULTISYNC = "fppMultisync"; - public static final String CHANNEL_TESTING = "fppTesting"; - public static final String CHANNEL_LAST_PLAYLIST = "fppLastPlaylist"; + 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 = "fppSchedulerStatus"; - public static final String CHANNEL_SCHEDULERCURRENTPLAYLIST = "fppSchedulerCurrentPlaylist"; - public static final String CHANNEL_SCHEDULERCURRENTPLAYLISTSTART = "fppSchedulerCurrentPlaylistStart"; - public static final String CHANNEL_SCHEDULERCURRENTPLAYLISTEND = "fppSchedulerCurrentPlaylistEnd"; - public static final String CHANNEL_SCHEDULERCURRENTPLAYLISTSTOPTYPE = "fppSchedulerCurrentPlaylistStopType"; - public static final String CHANNEL_SCHEDULERNEXTPLAYLIST = "fppSchedulerNextPlaylist"; - public static final String CHANNEL_SCHEDULERNEXTPLAYLISTSTART = "fppSchedulerNextPlaylistStart"; + public static final String CHANNEL_SCHEDULERSTATUS = "scheduler-status"; + 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"; diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt_it.properties b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt_it.properties deleted file mode 100644 index 7d9969e6d9edf..0000000000000 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt_it.properties +++ /dev/null @@ -1,81 +0,0 @@ -# thing types - -thing-type.mqtt.cct.label = Milight CCT -thing-type.mqtt.cct.description = Lampada LED con comandi per bianchi freddi e caldi -thing-type.mqtt.fut089.label = Milight FUT089 -thing-type.mqtt.fut089.description = Usa questo quando il tuo telecomando è il nuovo tipo con 8 gruppi chiamato FUT089 e le tue lampadine sono rgb_cct -thing-type.mqtt.fut091.label = Milight FUT091 -thing-type.mqtt.fut091.description = Usa questo quando il tuo telecomando è il fut091 più recente e le tue lampadine sono cct -thing-type.mqtt.rgb.label = Milight RGB -thing-type.mqtt.rgb.description = Lampadina RGB senza bianco -thing-type.mqtt.rgb_cct.label = Milight RGBCCT -thing-type.mqtt.rgb_cct.description = Lampada LED a colori, e con bianchi freddi e caldi. -thing-type.mqtt.rgbw.label = Milight RGBW -thing-type.mqtt.rgbw.description = Lampadina RGB con un bianco fisso - -# thing types config - -thing-type.config.mqtt.cct.dimmedCT.label = Temp Colore Impostato -thing-type.config.mqtt.cct.dimmedCT.description = Lampadine tradizionali diventano più calde quando sono regolate. Imposta a 370 o lascia bianco per disabilitare. -thing-type.config.mqtt.cct.oneTriggersNightMode.label = 1% Attiva modalità Notturna -thing-type.config.mqtt.cct.oneTriggersNightMode.description = L'1% su un cursore attiverà la Modalità Notte. -thing-type.config.mqtt.rgb.oneTriggersNightMode.label = 1% Attiva Modalità Notturna -thing-type.config.mqtt.rgb.oneTriggersNightMode.description = L'1% su un cursore attiverà la Modalità Notte. -thing-type.config.mqtt.rgb.powerFailsToMinimum.label = Regolazione se fallisce Accensione -thing-type.config.mqtt.rgb.powerFailsToMinimum.description = Se le luci perdono luminosità quando vengono spente gradualmente, le luci torneranno alla luminosità minima per impostazione predefinita. -thing-type.config.mqtt.rgbandcct.dimmedCT.label = Temp Colore Impostato -thing-type.config.mqtt.rgbandcct.dimmedCT.description = Le tradizionali lampadine sono più calde più sono luminose. Imposta a 370, o lasciare vuoto per disabilitare. -thing-type.config.mqtt.rgbandcct.duvThreshold.label = Soglia Duv -thing-type.config.mqtt.rgbandcct.duvThreshold.description = Valori Duv uguali o inferiori a questo valore su un controllo di colore RGBWW attiveranno la modalità bianca alla temperatura di colore appropriata. 1 disabiliterà effettivamente questa funzione. Vedi questo link per ottenere maggiori informazioni su come viene calcolato. -thing-type.config.mqtt.rgbandcct.favouriteWhite.label = Bianco Preferito -thing-type.config.mqtt.rgbandcct.favouriteWhite.description = Quando uno shortcut attiva la modalità bianca, usala per il colore bianco. -thing-type.config.mqtt.rgbandcct.oneTriggersNightMode.label = 1% Attiva modalità Notturna -thing-type.config.mqtt.rgbandcct.oneTriggersNightMode.description = L'1% del cursore attiverà la Modalità Notte. -thing-type.config.mqtt.rgbandcct.powerFailsToMinimum.label = Regolazione se fallisce Accensione -thing-type.config.mqtt.rgbandcct.powerFailsToMinimum.description = Se manca l'alimentazione alle luci, si riaccenderanno alla luminosità minima. -thing-type.config.mqtt.rgbandcct.whiteHue.label = Tonalità Bianca -thing-type.config.mqtt.rgbandcct.whiteHue.description = Quando entrambi i valori WhiteHue e WhiteSat sono visti dal binding, si attiveranno il LED bianchi. -thing-type.config.mqtt.rgbandcct.whiteSat.label = Saturazione Bianca -thing-type.config.mqtt.rgbandcct.whiteSat.description = Quando entrambi i valori WhiteHue e WhiteSat sono visti dal binding, si attiveranno i LED bianchi. -thing-type.config.mqtt.rgbw.oneTriggersNightMode.label = 1% Attiva modalità Notturna -thing-type.config.mqtt.rgbw.oneTriggersNightMode.description = L'1% sul cursore attiverà la Modalità Notte. -thing-type.config.mqtt.rgbw.powerFailsToMinimum.label = Regolazione se fallisce Accensione -thing-type.config.mqtt.rgbw.powerFailsToMinimum.description = Se manca l'alimentazione alle luci, si riaccenderanno alla luminosità minima. -thing-type.config.mqtt.rgbw.whiteHue.label = Tonalità Bianca -thing-type.config.mqtt.rgbw.whiteHue.description = Quando entrambi i valori WhiteHue e WhiteSat sono visti dal binding, si attiveranno il LED bianchi. -thing-type.config.mqtt.rgbw.whiteSat.label = Saturazione Bianca -thing-type.config.mqtt.rgbw.whiteSat.description = Quando entrambi i valori WhiteHue e WhiteSat sono visti dal binding, si attiveranno il LED bianchi. -thing-type.config.mqtt.rgbw.whiteThreshold.label = Soglia Bianco -thing-type.config.mqtt.rgbw.whiteThreshold.description = I valori di saturazione uguali o inferiori a questo valore su un controllo di colore RGBW attiveranno la modalità bianco. -1 disabiliterà questa funzione. - -# channel types - -channel-type.mqtt.bulbMode.label = Modalità Lampadina -channel-type.mqtt.bulbMode.description = Mostra il modo in cui è la lampadina in questo momento. -channel-type.mqtt.bulbMode.state.option.white = bianco -channel-type.mqtt.bulbMode.state.option.color = colore -channel-type.mqtt.bulbMode.state.option.scene = scena -channel-type.mqtt.bulbMode.state.option.night = notte -channel-type.mqtt.command.label = Command -channel-type.mqtt.command.description = Invia un comando diretto alla/e lampadina/e. -channel-type.mqtt.command.state.option.next_mode = Modalità Successiva -channel-type.mqtt.command.state.option.previous_mode = Modalità Precedente -channel-type.mqtt.command.state.option.mode_speed_up = Modalità Veloce -channel-type.mqtt.command.state.option.mode_speed_down = Modalità Lenta -channel-type.mqtt.command.state.option.set_white = Imposta Bianco -channel-type.mqtt.command.state.option.level_down = Livello Inferiore -channel-type.mqtt.command.state.option.level_up = Livello Superiore -channel-type.mqtt.command.state.option.temperature_down = Abbassa Temperatura -channel-type.mqtt.command.state.option.temperature_up = Alza Temperatura -channel-type.mqtt.command.state.option.night_mode = Modalità Notturna -channel-type.mqtt.discoMode.label = Modalità Discoteca -channel-type.mqtt.discoMode.description = Passa direttamente alla modalità Discoteca. -channel-type.mqtt.discoMode.state.option.0 = Disco 0 -channel-type.mqtt.discoMode.state.option.1 = Disco 1 -channel-type.mqtt.discoMode.state.option.2 = Disco 2 -channel-type.mqtt.discoMode.state.option.3 = Disco 3 -channel-type.mqtt.discoMode.state.option.4 = Disco 4 -channel-type.mqtt.discoMode.state.option.5 = Disco 5 -channel-type.mqtt.discoMode.state.option.6 = Disco 6 -channel-type.mqtt.discoMode.state.option.7 = Disco 7 -channel-type.mqtt.discoMode.state.option.8 = Disco 8 diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml index c1eca982d0b8e..a37edf525ed0f 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml @@ -11,162 +11,162 @@ FPP Player. - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + String FPP Player Status - + String FPP Version - + String FPP Player Mode - + String FPP Current Sequence - + String FPP Current Song - + String FPP Current Playlist - + Number:Time FPP Seconds Played - + Number:Time FPP Seconds Remaining - + Number:Time FPP uptime (time after start) - + String FPP Hardware UUID - + Player FPP Player Control - + Dimmer FPP Volume of the sound - + Switch FPP Is Bridging - + Switch FPP Multisync - + Switch FPP Is Testing - + String FPP Last Run Playlist - + String FPP Scheduler Status - + String FPP Current Playlist - + String FPP Scheduler Current Playlist Start Time - + String FPP Scheduler Current Playlist End Time - + String FPP Scheduler Current Playlist Stop Type - + String FPP Scheduler Next Playlist - + String FPP Scheduler Next Playlist Start Time From 285ffbeca029f50f53631bc599549ddc771f1ddd Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 12 Jun 2024 13:18:00 -0400 Subject: [PATCH 09/20] Updated Examples in README.md Signed-off-by: Scott Hanson --- .../org.openhab.binding.mqtt.fpp/README.md | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/README.md b/bundles/org.openhab.binding.mqtt.fpp/README.md index 2e06bedbfea2f..4bc2d2732ddce 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/README.md +++ b/bundles/org.openhab.binding.mqtt.fpp/README.md @@ -13,28 +13,28 @@ Binding to Controls Falcon Player (FPP) Devices. Uses MQTT to update status. Man | Channel | Type | Description | |-|-|-| -| `fppPlayer` | Player | Play/Stop Current Playlist. | -| `fppVolume` | Dimmer | Playback Audio Volume. | -| `fppStatus` | String | Playback Status. | -| `fppVersion` | String | Software Version. | -| `fppMode` | String | Playback Mode. | -| `fppUptime` | Number:Time | Device Uptime. | -| `fppTesting` | Switch | Device is in Testing Mode. | -| `fppCurrentSequence` | String (read only) | Currently Playing Sequence File. | -| `fppCurrentSong` | String (read only) | Currently Playing Audio/Media File. | -| `fppCurrentPlaylist` | String (read only) | Currently Playing Playlist. | -| `fppSecPlayed` | Number:Time | Sequence Playback time in secs. | -| `fppSecRemaining` | Number:Time | Sequence Playback time remaining in secs. | -| `fppLastPlaylist` | String | Lasted Played Playlist. | -| `fppUUID` | String | Device UUID. | -| `fppBridging` | Switch | Is Recieving Bridge Data. | -| `fppMultisync` | Switch | Multisync Mode Enabled. | -| `fppSchedulerCurrentPlaylist` | String (read only) | Scheduler Current Playlist. | -| `fppSchedulerCurrentPlaylistStart` | String (read only) | Scheduler Current Playlist Start Time. | -| `fppSchedulerCurrentPlaylistEnd` | String (read only) | Scheduler Current Playlist End Time. | -| `fppSchedulerCurrentPlaylistStopType` | String (read only) | Scheduler Current Playlist End Type. | -| `fppSchedulerNextPlaylist` | String (read only) | Next Scheduled Playlist. | -| `fppSchedulerNextPlaylistStart` | String (read only) | Next Scheduled Start Time. | +| `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. | +| `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. | ## Full Example @@ -53,19 +53,19 @@ Thing mqtt:player:myBroker:mainPlayer "Main Player" (mqtt:broker:myBroker) @ "MQ *.items ```java -Player FPP_Player "FPP Player" {channel="mqtt:player:myBroker:mainPlayer:fppPlayer"} -Dimmer Audio_Volume "Audio Volume" {channel="mqtt:player:myBroker:mainPlayer:fppVolume"} -String Current_Sequence "Current Sequence" {channel="mqtt:player:myBroker:mainPlayer:fppCurrentSequence"} -String Current_Song "Current Song" {channel="mqtt:player:myBroker:mainPlayer:fppCurrentSong"} -String Current_Playlist "Current Playlist" {channel="mqtt:player:myBroker:mainPlayer:fppCurrentPlaylist"} -String Status "FPP Status" {channel="mqtt:player:myBroker:mainPlayer:fppStatus"} -String Version "FPP Version" {channel="mqtt:player:myBroker:mainPlayer:fppVersion"} -String Mode "FPP Mode" {channel="mqtt:player:myBroker:mainPlayer:fppMode"} -String Last_Playlist "Last Playlist" {channel="mqtt:player:myBroker:mainPlayer:fppLastPlaylist"} -Number:Time Seconds_Played "Seconds Played [%d %unit%]" {channel="mqtt:player:myBroker:mainPlayer:fppSecPlayed"} -Number:Time Seconds_Remaining "Seconds Remaining [%d %unit%]" {channel="mqtt:player:myBroker:mainPlayer:fppSecRemaining"} -Switch Testing "Testing Mode" {channel="mqtt:player:myBroker:mainPlayer:fppTesting"} -Switch Multisync "Multisync" {channel="mqtt:player:myBroker:mainPlayer:fppMultisync"} +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 From f14c46f8c3afbd2e1e99be0cda78a103c848342b Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 12 Jun 2024 17:17:28 -0400 Subject: [PATCH 10/20] Fix Headers Signed-off-by: Scott Hanson --- .../openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java | 3 +-- .../org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java | 3 +-- .../org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java | 3 +-- .../org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java | 3 +-- .../java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java index af15b09b9a5ae..3b4a4a3d918ad 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java @@ -1,5 +1,3 @@ -package org.openhab.binding.mqtt.fpp.internal; - /** * Copyright (c) 2010-2024 Contributors to the openHAB project * @@ -12,6 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ +package org.openhab.binding.mqtt.fpp.internal; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java index 2d5f7d730ee98..34c8f8c123bd7 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java @@ -1,5 +1,3 @@ -package org.openhab.binding.mqtt.fpp.internal; - /** * Copyright (c) 2010-2024 Contributors to the openHAB project * @@ -12,6 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ +package org.openhab.binding.mqtt.fpp.internal; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java index ef4b8011e926e..0a2495bdf0fb3 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java @@ -1,5 +1,3 @@ -package org.openhab.binding.mqtt.fpp.internal; - /** * Copyright (c) 2010-2024 Contributors to the openHAB project * @@ -12,6 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ +package org.openhab.binding.mqtt.fpp.internal; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java index 1eb7c2d9ce7a2..783ec83a5e630 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java @@ -1,5 +1,3 @@ -package org.openhab.binding.mqtt.fpp.internal; - /** * Copyright (c) 2010-2024 Contributors to the openHAB project * @@ -12,6 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ +package org.openhab.binding.mqtt.fpp.internal; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java index 9f82ec3bce720..76f8fbf982689 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java @@ -1,5 +1,3 @@ -package org.openhab.binding.mqtt.fpp.internal; - /** * Copyright (c) 2010-2024 Contributors to the openHAB project * @@ -12,6 +10,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ +package org.openhab.binding.mqtt.fpp.internal; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; From c9a514f409c681365aed9ac5776184697f6232e1 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Sat, 27 Jul 2024 18:58:55 -0400 Subject: [PATCH 11/20] Update bundles/org.openhab.binding.mqtt.fpp/pom.xml Co-authored-by: Wouter Born Signed-off-by: Scott Hanson --- bundles/org.openhab.binding.mqtt.fpp/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/pom.xml b/bundles/org.openhab.binding.mqtt.fpp/pom.xml index 6c839be9de27f..b6c67c8aadeb9 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/pom.xml +++ b/bundles/org.openhab.binding.mqtt.fpp/pom.xml @@ -7,7 +7,7 @@ org.openhab.addons.bundles org.openhab.addons.reactor.bundles - 4.2.0-SNAPSHOT + 4.3.0-SNAPSHOT org.openhab.binding.mqtt.fpp From ba20dd42afc16193b28355e899ae872aabf6a0e9 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 31 Jul 2024 23:18:04 -0400 Subject: [PATCH 12/20] Update bundles/org.openhab.binding.mqtt.fpp/README.md Co-authored-by: lsiepel Signed-off-by: Scott Hanson --- bundles/org.openhab.binding.mqtt.fpp/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bundles/org.openhab.binding.mqtt.fpp/README.md b/bundles/org.openhab.binding.mqtt.fpp/README.md index 4bc2d2732ddce..be438f0342b19 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/README.md +++ b/bundles/org.openhab.binding.mqtt.fpp/README.md @@ -2,6 +2,13 @@ Binding to Controls Falcon Player (FPP) Devices. Uses MQTT to update status. Manually add an 'player' thing to get status. +## 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 | From 0b40ebbd244064903bd5985fa23e0ecb961cc09b Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 31 Jul 2024 23:18:17 -0400 Subject: [PATCH 13/20] Update bundles/org.openhab.binding.mqtt.fpp/README.md Co-authored-by: lsiepel Signed-off-by: Scott Hanson --- bundles/org.openhab.binding.mqtt.fpp/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/README.md b/bundles/org.openhab.binding.mqtt.fpp/README.md index be438f0342b19..cbd68a3cdb068 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/README.md +++ b/bundles/org.openhab.binding.mqtt.fpp/README.md @@ -1,6 +1,6 @@ # FPP Binding -Binding to Controls Falcon Player (FPP) Devices. Uses MQTT to update status. Manually add an 'player' thing to get status. +Binding to control Falcon Player (FPP) Devices using MQTT. ## Discovery From 5bab93a96b7b8e453ab129d54ac445805da93716 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Wed, 31 Jul 2024 23:23:23 -0400 Subject: [PATCH 14/20] Apply suggestions from code review Co-authored-by: lsiepel Signed-off-by: Scott Hanson --- .../org.openhab.binding.mqtt.fpp/README.md | 7 +++---- .../fpp/internal/FPPBindingConstants.java | 4 ++-- .../binding/mqtt/fpp/internal/FPPStatus.java | 7 ------- .../internal/handler/FPPPlayerHandler.java | 19 +++++++------------ 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/README.md b/bundles/org.openhab.binding.mqtt.fpp/README.md index cbd68a3cdb068..fa7d2a6ebe5ec 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/README.md +++ b/bundles/org.openhab.binding.mqtt.fpp/README.md @@ -43,21 +43,20 @@ The binding supports one Thing `player` that represents the Falcon Player. | `scheduler-next-playlist` | String (read only) | Next Scheduled Playlist. | | `scheduler-next-playlist-start` | String (read only) | Next Scheduled Start Time. | - ## 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 +### 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" ``` -*.items +### fpp.items ```java Player FPP_Player "FPP Player" {channel="mqtt:player:myBroker:mainPlayer:player"} @@ -75,7 +74,7 @@ Switch Testing "Testing Mode" {channel="mqtt:player:myBroker:mainPlayer:testing- Switch Multisync "Multisync" {channel="mqtt:player:myBroker:mainPlayer:multisync-enabled"} ``` -*.sitemap +### fpp.sitemap ```perl Text label="Main Player" diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java index 815d56fdaffe6..25e19788be432 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java @@ -56,7 +56,7 @@ public class FPPBindingConstants { 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"; + public static final String CHANNEL_SCHEDULER_STATUS = "scheduler-status"; 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"; @@ -66,7 +66,7 @@ public class FPPBindingConstants { // Status public static final String CONNECTED = "connected"; - public static final String CHANNEL_STATUS_NAME = "status_name"; + public static final String CHANNEL_STATUS_NAME = "status-name"; public static final String TESTING = "testing"; } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java index 76f8fbf982689..02d1180149a00 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java @@ -154,11 +154,4 @@ public class FPPStatus { @Expose public FPPScheduler scheduler; - // public String getStatus() { - // return status_name; - // } - - // public String getMode() { - // return mode_name; - // } } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java index 0eb7fed50f3b4..8b6b75f63b24a 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java @@ -53,7 +53,7 @@ import com.google.gson.Gson; -import tech.units.indriya.unit.Units; +import org.openhab.core.library.unit.Units; /** * The {@link FPPPlayerHandler} is responsible for handling commands of the globes, which are then @@ -198,7 +198,7 @@ public void processMessage(String topic, byte[] payload) { } public ThingStatusInfo getBridgeStatus() { - Bridge b = getBridge(); + Bridge bridge = getBridge(); if (b != null) { return b.getStatusInfo(); } else { @@ -213,10 +213,6 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { connection = null; return; } - if (bridgeStatusInfo.getStatus() != ThingStatus.ONLINE) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR); - return; - } Bridge localBridge = this.getBridge(); if (localBridge == null) { @@ -235,8 +231,7 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { return; } this.connection = connection; - updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.CONFIGURATION_PENDING, - "Waiting for 'fpp/status: connected' MQTT message to be received. Check hub has 'MQTT Client Status Topic' configured."); + updateStatus(ThingStatus.UNKNOWN); connection.subscribe(fullStatusTopic, this); connection.subscribe(fullVersionTopic, this); } @@ -248,8 +243,8 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { try { response = HttpUtil.executeUrl("GET", "http://" + config.playerIP + url, 5000); - } catch (Exception e) { - logger.error("Failed HTTP Post", e); + } catch (IOException e) { + logger.warn("Failed HTTP Post", e); } return response; } @@ -263,8 +258,8 @@ private boolean executePost(String url, String json) { new ByteArrayInputStream(json.getBytes()), "application/json", 5000); return !response.isEmpty(); - } catch (Exception e) { - logger.error("Failed HTTP Post", e); + } catch (IOException e) { + logger.warn("Failed HTTP Post", e); } return false; } From 30de5b8aa632a8da790aff449f55da4c35607d2a Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Fri, 2 Aug 2024 01:06:22 -0400 Subject: [PATCH 15/20] Review cleanup Signed-off-by: Scott Hanson --- .../org.openhab.binding.mqtt.fpp/README.md | 59 ++++++++--------- .../fpp/internal/FPPBindingConstants.java | 12 ++-- .../binding/mqtt/fpp/internal/FPPStatus.java | 1 - .../binding/mqtt/fpp/internal/Helper.java | 65 ------------------- .../{ => dto}/FPPCurrentPlaylist.java | 0 .../internal/{ => dto}/FPPNextPlaylist.java | 0 .../fpp/internal/{ => dto}/FPPPlaylist.java | 0 .../fpp/internal/{ => dto}/FPPScheduler.java | 0 .../internal/handler/FPPPlayerHandler.java | 40 +++++++----- .../main/resources/OH-INF/config/config.xml | 3 +- 10 files changed, 60 insertions(+), 120 deletions(-) delete mode 100644 bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/Helper.java rename bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/{ => dto}/FPPCurrentPlaylist.java (100%) rename bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/{ => dto}/FPPNextPlaylist.java (100%) rename bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/{ => dto}/FPPPlaylist.java (100%) rename bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/{ => dto}/FPPScheduler.java (100%) diff --git a/bundles/org.openhab.binding.mqtt.fpp/README.md b/bundles/org.openhab.binding.mqtt.fpp/README.md index fa7d2a6ebe5ec..01eaddea0f13d 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/README.md +++ b/bundles/org.openhab.binding.mqtt.fpp/README.md @@ -1,6 +1,6 @@ # FPP Binding -Binding to control Falcon Player (FPP) Devices using MQTT. +Binding to control Falcon Player (FPP) Devices using MQTT and HTTP. Status messages are recieved over MQTT and Commands are HTTP Commands. ## Discovery @@ -11,37 +11,38 @@ Autodiscovering is not supported. We have to define the things manually. The binding supports one Thing `player` that represents the Falcon Player. ## Thing Configuration -| Parameter | Description | Required | Default | -|-|-|-|-| -| `playerIP` | IP Address of FPP Devive | Y | | -| `playerMQTT` | MQTT Topic of FPP Devive Status | Y | | +| 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. | -| `version` | String | Software Version. | -| `mode` | String | Playback Mode. | -| `uptime` | Number:Time | Device Uptime. | -| `testing-enabled` | Switch | Device is in Testing Mode. | -| `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. | +| Channel | Type | Description | +|----------------------------------------|--------------------|-------------------------------------------| +| `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. | +| `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 (read only) | 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. | + ## Full Example diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java index 25e19788be432..5b94fd0ba9ae5 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java @@ -57,12 +57,12 @@ public class FPPBindingConstants { public static final String CHANNEL_LAST_PLAYLIST = "last-playlist"; public static final String CHANNEL_SCHEDULER_STATUS = "scheduler-status"; - 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"; + 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"; // Status public static final String CONNECTED = "connected"; diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java index 02d1180149a00..25adf6dd80559 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPStatus.java @@ -153,5 +153,4 @@ public class FPPStatus { @SerializedName("scheduler") @Expose public FPPScheduler scheduler; - } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/Helper.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/Helper.java deleted file mode 100644 index 680fe48bede15..0000000000000 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/Helper.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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 Helper} Removes the need for any external JSON libs - * - * @author Scott Hanson - Initial contribution - */ -@NonNullByDefault -public class Helper { - /** - * resolveJSON will return a value from any key/path that you give and the string can be terminated by any ,}" - * characters. - * - */ - public static String resolveJSON(String messageJSON, String jsonPath, int resultMaxLength) { - String result = ""; - int index = 0; - index = messageJSON.indexOf(jsonPath); - if (index != -1) { - if ((index + jsonPath.length() + resultMaxLength) > messageJSON.length()) { - result = (messageJSON.substring(index + jsonPath.length(), messageJSON.length())); - } else { - result = (messageJSON.substring(index + jsonPath.length(), - index + jsonPath.length() + resultMaxLength)); - } - index = result.indexOf(','); - if (index == -1) { - index = result.indexOf('"'); - if (index == -1) { - index = result.indexOf('}'); - if (index == -1) { - return result; - } else { - return result.substring(0, index); - } - } else { - return result.substring(0, index); - } - } else { - result = result.substring(0, index); - index = result.indexOf('"'); - if (index == -1) { - return result; - } else { - return result.substring(0, index); - } - } - } - return ""; - } -} diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/dto/FPPCurrentPlaylist.java similarity index 100% rename from bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPCurrentPlaylist.java rename to bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/dto/FPPCurrentPlaylist.java diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/dto/FPPNextPlaylist.java similarity index 100% rename from bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPNextPlaylist.java rename to bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/dto/FPPNextPlaylist.java diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/dto/FPPPlaylist.java similarity index 100% rename from bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPPlaylist.java rename to bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/dto/FPPPlaylist.java diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/dto/FPPScheduler.java similarity index 100% rename from bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPScheduler.java rename to bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/dto/FPPScheduler.java diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java index 8b6b75f63b24a..c1a211106506d 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java @@ -15,6 +15,7 @@ import static org.openhab.binding.mqtt.fpp.internal.FPPBindingConstants.*; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.util.Properties; @@ -37,6 +38,7 @@ import org.openhab.core.library.types.PlayPauseType; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; +import org.openhab.core.library.unit.Units; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; @@ -53,8 +55,6 @@ import com.google.gson.Gson; -import org.openhab.core.library.unit.Units; - /** * The {@link FPPPlayerHandler} is responsible for handling commands of the globes, which are then * sent to one of the bridges to be sent out by MQTT. @@ -96,18 +96,19 @@ private void processIncomingState(String messageJSON) { updateState(CHANNEL_MULTISYNC, OnOffType.from(data.multisync)); updateState(CHANNEL_TESTING, data.status_name.equals(TESTING) ? OnOffType.ON : OnOffType.OFF); - updateState(CHANNEL_SCHEDULERSTATUS, new StringType(data.scheduler.status)); - updateState(CHANNEL_SCHEDULERNEXTPLAYLIST, new StringType(data.scheduler.nextPlaylist.playlistName)); - updateState(CHANNEL_SCHEDULERNEXTPLAYLISTSTART, + updateState(CHANNEL_SCHEDULER_STATUS, new StringType(data.scheduler.status)); + updateState(CHANNEL_SCHEDULER_NEXT_PLAYLIST, new StringType(data.scheduler.nextPlaylist.playlistName)); + updateState(CHANNEL_SCHEDULER_NEXT_PLAYLIST_START, new StringType(data.scheduler.nextPlaylist.scheduledStartTimeStr)); if (data.scheduler.currentPlaylist != null) { - updateState(CHANNEL_SCHEDULERCURRENTPLAYLIST, new StringType(data.scheduler.currentPlaylist.playlistName)); - updateState(CHANNEL_SCHEDULERCURRENTPLAYLISTSTART, + updateState(CHANNEL_SCHEDULER_CURRENT_PLAYLIST, + new StringType(data.scheduler.currentPlaylist.playlistName)); + updateState(CHANNEL_SCHEDULER_CURRENT_PLAYLIST_START, new StringType(data.scheduler.currentPlaylist.playlistName)); - updateState(CHANNEL_SCHEDULERCURRENTPLAYLISTEND, + updateState(CHANNEL_SCHEDULER_CURRENT_PLAYLIST_END, new StringType(data.scheduler.currentPlaylist.playlistName)); - updateState(CHANNEL_SCHEDULERCURRENTPLAYLISTSTOPTYPE, + updateState(CHANNEL_SCHEDULER_CURRENT_PLAYLIST_STOP_TYPE, new StringType(data.scheduler.currentPlaylist.playlistName)); } @@ -177,11 +178,14 @@ private String GetTestMode(int enable) { @Override public void initialize() { + updateStatus(ThingStatus.UNKNOWN); config = getConfigAs(ConfigOptions.class); - - fullStatusTopic = config.playerMQTT + "/" + STATUS_TOPIC; - fullVersionTopic = config.playerMQTT + "/" + VERSION_TOPIC; - bridgeStatusChanged(getBridgeStatus()); + if (!config.playerMQTT.isEmpty()) { + fullStatusTopic = config.playerMQTT + "/" + STATUS_TOPIC; + fullVersionTopic = config.playerMQTT + "/" + VERSION_TOPIC; + bridgeStatusChanged(getBridgeStatus()); + updateStatus(ThingStatus.ONLINE); + } } @Override @@ -198,7 +202,7 @@ public void processMessage(String topic, byte[] payload) { } public ThingStatusInfo getBridgeStatus() { - Bridge bridge = getBridge(); + Bridge b = getBridge(); if (b != null) { return b.getStatusInfo(); } else { @@ -224,7 +228,7 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { if (handler instanceof AbstractBrokerHandler abh) { final MqttBrokerConnection connection; try { - connection = abh.getConnectionAsync().get(500, TimeUnit.MILLISECONDS); + connection = abh.getConnectionAsync().get(5000, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException ignored) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED, "Bridge handler has no valid broker connection!"); @@ -232,8 +236,10 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { } this.connection = connection; updateStatus(ThingStatus.UNKNOWN); - connection.subscribe(fullStatusTopic, this); - connection.subscribe(fullVersionTopic, this); + if (!fullStatusTopic.isEmpty()) { + connection.subscribe(fullStatusTopic, this); + connection.subscribe(fullVersionTopic, this); + } } return; } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml index 71af1d7cd8526..d5413c667ea64 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml @@ -8,13 +8,12 @@ network-address - Player IP Address + Player IP Address or Host Name name MQTT Player Status Topic - From fce620e1769ccb071ecec00a4fb6c93f593fa69a Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Sun, 4 Aug 2024 10:55:52 -0400 Subject: [PATCH 16/20] Switch "uuid" and "version" to properties Signed-off-by: Scott Hanson --- bundles/org.openhab.binding.mqtt.fpp/README.md | 6 +----- .../mqtt/fpp/internal/FPPBindingConstants.java | 5 +++-- .../fpp/internal/handler/FPPPlayerHandler.java | 5 +++-- .../resources/OH-INF/thing/thing-types.xml | 18 ++++++------------ 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/README.md b/bundles/org.openhab.binding.mqtt.fpp/README.md index 01eaddea0f13d..19d46cac76a69 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/README.md +++ b/bundles/org.openhab.binding.mqtt.fpp/README.md @@ -23,17 +23,15 @@ The binding supports one Thing `player` that represents the Falcon Player. | `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. | +| `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. | -| `uuid` | String (read only) | Device UUID. | | `bridging-enabled` | Switch | Is Recieving Bridge Data. | | `multisync-enabled` | Switch | Multisync Mode Enabled. | | `scheduler-current-playlist` | String (read only) | Scheduler Current Playlist. | @@ -66,7 +64,6 @@ String Current_Sequence "Current Sequence" {channel="mqtt:player:myBroker:mainPl 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"} @@ -87,7 +84,6 @@ Text label="Main Player" Text item=Current_Song Text item=Current_Playlist Text item=Status - Text item=Version Text item=Mode Selection item=Last_Playlist Switch item=Testing diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java index 5b94fd0ba9ae5..9c27ea30ec233 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/FPPBindingConstants.java @@ -49,8 +49,6 @@ public class FPPBindingConstants { 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"; @@ -64,6 +62,9 @@ public class FPPBindingConstants { 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"; diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java index c1a211106506d..3c8e6b1043259 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java @@ -88,7 +88,6 @@ private void processIncomingState(String messageJSON) { updateState(CHANNEL_CURRENT_SEQUENCE, new StringType(data.current_sequence)); updateState(CHANNEL_CURRENT_SONG, new StringType(data.current_song)); updateState(CHANNEL_CURRENT_PLAYLIST, new StringType(data.current_playlist.playlist)); - updateState(CHANNEL_UUID, new StringType(data.uuid)); updateState(CHANNEL_SEC_PLAYED, new QuantityType<>(new BigDecimal(data.seconds_played), Units.SECOND)); updateState(CHANNEL_SEC_REMAINING, new QuantityType<>(new BigDecimal(data.seconds_remaining), Units.SECOND)); updateState(CHANNEL_UPTIME, new QuantityType<>(new BigDecimal(data.uptimeTotalSeconds), Units.SECOND)); @@ -116,6 +115,8 @@ private void processIncomingState(String messageJSON) { lastPlaylist = data.current_playlist.playlist; updateState(CHANNEL_LAST_PLAYLIST, new StringType(lastPlaylist)); } + + thing.setProperty(PROPERTY_UUID, data.uuid); } @Override @@ -196,7 +197,7 @@ public void processMessage(String topic, byte[] payload) { if (topic.endsWith(STATUS_TOPIC)) { processIncomingState(state); } else if (topic.endsWith(VERSION_TOPIC)) { - updateState(CHANNEL_VERSION, new StringType(state)); + thing.setProperty(PROPERTY_SOFTWARE_VERSION, state); updateStatus(ThingStatus.ONLINE); } } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml index a37edf525ed0f..2033ac874d2ea 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml @@ -35,6 +35,12 @@ + + + unknown + unknown + + @@ -43,12 +49,6 @@ FPP Player Status - - String - - FPP Version - - String @@ -91,12 +91,6 @@ FPP uptime (time after start) - - String - - FPP Hardware UUID - - Player From 5b6d882244a7cb1cbcd42a4e12cffd0ce32d0641 Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Sun, 4 Aug 2024 13:10:45 -0400 Subject: [PATCH 17/20] update names Signed-off-by: Scott Hanson --- .../binding/mqtt/fpp/internal/ConfigOptions.java | 4 ++-- .../mqtt/fpp/internal/handler/FPPPlayerHandler.java | 10 +++++----- .../src/main/resources/OH-INF/config/config.xml | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/ConfigOptions.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/ConfigOptions.java index 2f042c0e4a795..9ffcada0992e3 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/ConfigOptions.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/ConfigOptions.java @@ -21,6 +21,6 @@ */ @NonNullByDefault public class ConfigOptions { - public String playerIP = ""; - public String playerMQTT = ""; + public String playerAddress = ""; + public String playerMQTTTopic = ""; } diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java index 3c8e6b1043259..bb89b7562a3c7 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/java/org/openhab/binding/mqtt/fpp/internal/handler/FPPPlayerHandler.java @@ -181,9 +181,9 @@ private String GetTestMode(int enable) { public void initialize() { updateStatus(ThingStatus.UNKNOWN); config = getConfigAs(ConfigOptions.class); - if (!config.playerMQTT.isEmpty()) { - fullStatusTopic = config.playerMQTT + "/" + STATUS_TOPIC; - fullVersionTopic = config.playerMQTT + "/" + VERSION_TOPIC; + if (!config.playerMQTTTopic.isEmpty()) { + fullStatusTopic = config.playerMQTTTopic + "/" + STATUS_TOPIC; + fullVersionTopic = config.playerMQTTTopic + "/" + VERSION_TOPIC; bridgeStatusChanged(getBridgeStatus()); updateStatus(ThingStatus.ONLINE); } @@ -248,7 +248,7 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { private @Nullable String executeGet(String url) { String response = null; try { - response = HttpUtil.executeUrl("GET", "http://" + config.playerIP + url, 5000); + response = HttpUtil.executeUrl("GET", "http://" + config.playerAddress + url, 5000); } catch (IOException e) { logger.warn("Failed HTTP Post", e); @@ -261,7 +261,7 @@ private boolean executePost(String url, String json) { Properties header = new Properties(); header.put("Accept", "application/json"); header.put("Content-Type", "application/json"); - String response = HttpUtil.executeUrl("POST", "http://" + config.playerIP + url, header, + String response = HttpUtil.executeUrl("POST", "http://" + config.playerAddress + url, header, new ByteArrayInputStream(json.getBytes()), "application/json", 5000); return !response.isEmpty(); diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml index d5413c667ea64..82c725d815a0a 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/config/config.xml @@ -5,14 +5,14 @@ xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0 https://openhab.org/schemas/config-description-1.0.0.xsd"> - + network-address - + Player IP Address or Host Name - + name - + MQTT Player Status Topic From b612b32e6c6148a7349f31442273fced608a9e0f Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Sat, 14 Sep 2024 21:44:27 -0400 Subject: [PATCH 18/20] Update Descriptions and Labels, updated i18n Signed-off-by: Scott Hanson --- .../resources/OH-INF/i18n/mqtt.properties | 54 ++++++++++++++++--- .../resources/OH-INF/thing/thing-types.xml | 16 +++--- 2 files changed, 54 insertions(+), 16 deletions(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties index 1241a14c776a3..cedd5180e25c1 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties @@ -5,14 +5,52 @@ thing.description.player=FPP Player # thing types config -thing-type.config.mqtt.player.playerIP.label = FPP IP -thing-type.config.mqtt.player.playerIP.description = FPP IP. -thing-type.config.mqtt.player.playerMQTT.label = MQTT Path -thing-type.config.mqtt.player.playerMQTT.description = MQTT Path. +thing-type.config.mqtt.player.playerAddress.label = Player Address +thing-type.config.mqtt.player.playerAddress.description = Player IP Address or Host Name +thing-type.config.mqtt.player.playerMQTTTopic.label = MQTT Player Topic +thing-type.config.mqtt.player.playerMQTTTopic.description = MQTT Player Status Topic # channel types -channel-type.mqtt.status.label = Player Status -channel-type.mqtt.status.description = Player Status. -channel-type.mqtt.version.label = Player Version -channel-type.mqtt.version.description = Player Version. +channel-type.mqtt.player.status.label = Status +channel-type.mqtt.player.status.description = FPP Player Status +channel-type.mqtt.player.mode.label = Mode +channel-type.mqtt.player.mode.description = FPP Player Mode +channel-type.mqtt.player.current-sequence.label = Current Sequence +channel-type.mqtt.player.current-sequence.description = FPP Current Sequence +channel-type.mqtt.player.current-song.label = Current Song +channel-type.mqtt.player.current-song.description = FPP Current Song +channel-type.mqtt.player.current-playlist.label = Current Playlist +channel-type.mqtt.player.current-playlist.description = FPP Current Playlist +channel-type.mqtt.player.seconds-played.label = Seconds Played +channel-type.mqtt.player.seconds-played.description = FPP Seconds Played +channel-type.mqtt.player.seconds-remaining.label = Seconds Remaining +channel-type.mqtt.player.seconds-remaining.description = FPP Seconds Remaining +channel-type.mqtt.player.uptime.label = Uptime +channel-type.mqtt.player.uptime.description = FPP System Uptime (time after start) +channel-type.mqtt.player.player.label = Player +channel-type.mqtt.player.player.description = FPP Player Control +channel-type.mqtt.player.volume.label = Volume +channel-type.mqtt.player.volume.description = FPP Volume of the Output +channel-type.mqtt.player.bridging-enabled.label = Bridging +channel-type.mqtt.player.bridging-enabled.description = FPP Recieving Bridge Data +channel-type.mqtt.player.multisync-enabled.label = Multisync +channel-type.mqtt.player.multisync-enabled.description = FPP Multisync Mode Enabled +channel-type.mqtt.player.testing-enabled.label = Testing +channel-type.mqtt.player.testing-enabled.description = FPP Is In Test Mode +channel-type.mqtt.player.last-playlist.label = Last Run Playlist +channel-type.mqtt.player.last-playlist.description = FPP Last Run Playlist +channel-type.mqtt.player.scheduler-status.label = Scheduler Status +channel-type.mqtt.player.scheduler-status.description = FPP Scheduler Status +channel-type.mqtt.player.scheduler-current-playlist.label = Scheduler Current Playlist +channel-type.mqtt.player.scheduler-current-playlist.description = FPP Scheduler Current Playlist +channel-type.mqtt.player.scheduler-current-playlist-start.label = Scheduler Current Playlist Start +channel-type.mqtt.player.scheduler-current-playlist-start.description = FPP Scheduler Current Playlist Start Time +channel-type.mqtt.player.scheduler-current-playlist-end.label = Scheduler Current Playlist End +channel-type.mqtt.player.scheduler-current-playlist-end.description = FPP Scheduler Current Playlist End Time +channel-type.mqtt.player.scheduler-current-playlist-stop-type.label = Scheduler Current Playlist Stop Type +channel-type.mqtt.player.scheduler-current-playlist-stop-type.description = FPP Scheduler Current Playlist Stop Type +channel-type.mqtt.player.scheduler-next-playlist.label = Scheduler Next Playlist +channel-type.mqtt.player.scheduler-next-playlist.description = FPP Scheduler Next Playlist +channel-type.mqtt.player.scheduler-next-playlist-start.label = Scheduler Next Playlist Start +channel-type.mqtt.player.scheduler-next-playlist-start.description = FPP Scheduler Next Playlist Start Time \ No newline at end of file diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml index 2033ac874d2ea..99076559f5d8f 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/thing/thing-types.xml @@ -9,7 +9,7 @@ - FPP Player. + FPP Player @@ -87,8 +87,8 @@ Number:Time - - FPP uptime (time after start) + + FPP System Uptime (time after start) @@ -99,24 +99,24 @@ Dimmer - FPP Volume of the sound + FPP Volume of the Output Switch - FPP Is Bridging + FPP Recieving Bridge Data Switch - FPP Multisync + FPP Multisync Mode Enabled Switch - FPP Is Testing + FPP Is In Test Mode String @@ -133,7 +133,7 @@ String - FPP Current Playlist + FPP Scheduler Current Playlist From 473a7f76e2ca0419fbcec4f524ade3476f2a350a Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Sat, 14 Sep 2024 22:13:06 -0400 Subject: [PATCH 19/20] Added newline Signed-off-by: Scott Hanson --- .../src/main/resources/OH-INF/i18n/mqtt.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties index cedd5180e25c1..542c765a31955 100644 --- a/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties +++ b/bundles/org.openhab.binding.mqtt.fpp/src/main/resources/OH-INF/i18n/mqtt.properties @@ -53,4 +53,4 @@ channel-type.mqtt.player.scheduler-current-playlist-stop-type.description = FPP channel-type.mqtt.player.scheduler-next-playlist.label = Scheduler Next Playlist channel-type.mqtt.player.scheduler-next-playlist.description = FPP Scheduler Next Playlist channel-type.mqtt.player.scheduler-next-playlist-start.label = Scheduler Next Playlist Start -channel-type.mqtt.player.scheduler-next-playlist-start.description = FPP Scheduler Next Playlist Start Time \ No newline at end of file +channel-type.mqtt.player.scheduler-next-playlist-start.description = FPP Scheduler Next Playlist Start Time From 893635ba90c2597413a7d6d9f8e1941f6294602b Mon Sep 17 00:00:00 2001 From: Scott Hanson Date: Fri, 20 Sep 2024 11:24:57 -0400 Subject: [PATCH 20/20] Added me to codeowner and added to footer Signed-off-by: Scott Hanson --- CODEOWNERS | 1 + features/openhab-addons/src/main/resources/footer.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/CODEOWNERS b/CODEOWNERS index 0a4f724322f04..359ed701d6a36 100755 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -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 diff --git a/features/openhab-addons/src/main/resources/footer.xml b/features/openhab-addons/src/main/resources/footer.xml index eab649b5c3965..c9da2e0fe0112 100644 --- a/features/openhab-addons/src/main/resources/footer.xml +++ b/features/openhab-addons/src/main/resources/footer.xml @@ -23,6 +23,7 @@ openhab-transport-mqtt mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt/${project.version} mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.espmilighthub/${project.version} + mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.fpp/${project.version} mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.generic/${project.version} mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.homeassistant/${project.version} mvn:org.openhab.addons.bundles/org.openhab.binding.mqtt.homie/${project.version}