Skip to content

Commit

Permalink
Various fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRSatzteil committed Sep 21, 2023
1 parent 80200f7 commit 9a3b469
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class AwtrixLightBindingConstants {
public static final String PROP_APPID = "appid";
public static final String PROP_APPLOCKTIMEOUT = "appLockTimeout";
public static final String PROP_APPNAME = "appname";
public static final String PROP_APP_CONTROLLABLE = "useButtons";
public static final String PROP_BASETOPIC = "basetopic";
public static final String PROP_DISCOVERDEFAULT = "discoverDefaultApps";
public static final String PROP_FIRMWARE = "firmware";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.openhab.binding.mqtt.awtrixlight.internal;

import java.math.BigDecimal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
Expand All @@ -24,5 +26,5 @@ public class BridgeConfigOptions {
public String basetopic = "awtrix";
public int appLockTimeout = 10;
public boolean discoverDefaultApps = false;
public int lowBatteryThreshold = 25;
public BigDecimal lowBatteryThreshold = new BigDecimal(25);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.AWTRIX_APP;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_APPID;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_APPNAME;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_APP_CONTROLLABLE;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_UNIQUEID;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.THING_TYPE_APP;

Expand Down Expand Up @@ -91,7 +92,8 @@ void publishApp(ThingUID connectionBridgeUid, String bridgeHardwareId, String ba
String appId = bridgeHardwareId + "-" + appName;
thingDiscovered(DiscoveryResultBuilder
.create(new ThingUID(new ThingTypeUID(BINDING_ID, AWTRIX_APP), connectionBridgeUid, appName))
.withBridge(connectionBridgeUid).withProperty(PROP_APPID, appId).withProperty(PROP_APPNAME, appName)
.withBridge(connectionBridgeUid).withProperty(PROP_APPID, appId)
.withProperty(PROP_APP_CONTROLLABLE, false).withProperty(PROP_APPNAME, appName)
.withRepresentationProperty(PROP_APPID).withLabel("Awtrix App " + appName).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.FIELD_BRIDGE_FIRMWARE;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.FIELD_BRIDGE_TYPE;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.FIELD_BRIDGE_UID;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_APPLOCKTIMEOUT;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_BASETOPIC;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_DISCOVERDEFAULT;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_FIRMWARE;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_UNIQUEID;
import static org.openhab.binding.mqtt.awtrixlight.internal.AwtrixLightBindingConstants.PROP_VENDOR;
Expand Down Expand Up @@ -118,7 +116,6 @@ void publishClock(ThingUID connectionBridgeUid, String baseTopic, String vendor,
.create(new ThingUID(new ThingTypeUID(BINDING_ID, AWTRIX_CLOCK), connectionBridgeUid, hardwareUid))
.withBridge(connectionBridgeUid).withProperty(PROP_VENDOR, vendor).withProperty(PROP_FIRMWARE, firmware)
.withProperty(PROP_UNIQUEID, hardwareUid).withProperty(PROP_BASETOPIC, baseTopic)
.withProperty(PROP_APPLOCKTIMEOUT, 10).withProperty(PROP_DISCOVERDEFAULT, false)
.withRepresentationProperty(PROP_UNIQUEID).withLabel("Awtrix Clock " + name).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void initialize() {
this.basetopic = config.basetopic;
this.appLockTimeout = config.appLockTimeout;
this.discoverDefaultApps = config.discoverDefaultApps;
this.lowBatteryThreshold = new BigDecimal(config.lowBatteryThreshold);
this.lowBatteryThreshold = config.lowBatteryThreshold;
this.channelPrefix = thing.getUID() + ":";
logger.debug(
"Configured handler with baseTopic {}, channelPrefix {}, appLockTimeout {}, discoverDefaultApps {}",
Expand Down Expand Up @@ -332,15 +332,15 @@ public Collection<Class<? extends ThingHandlerService>> getServices() {
}

public void reboot() {
this.sendMQTT(TOPIC_REBOOT, "", false);
this.sendMQTT(this.basetopic + TOPIC_REBOOT, "", false);
}

public void playSound(String melodyName) {
this.sendMQTT(TOPIC_SOUND, "{\"sound\":\"" + melodyName + "\"}", false);
this.sendMQTT(this.basetopic + TOPIC_SOUND, "{\"sound\":\"" + melodyName + "\"}", false);
}

public void upgrade() {
this.sendMQTT(TOPIC_UPGRADE, "", false);
this.sendMQTT(this.basetopic + TOPIC_UPGRADE, "", false);
}

public void setAppDiscoveryCallback(AwtrixLightBridgeDiscoveryService awtrixLightBridgeDiscoveryService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
recommended to ignore them during app discovery.</description>
<default>false</default>
</parameter>
<parameter name="lowBatteryThreshold" type="integer" required="true">
<parameter name="lowBatteryThreshold" type="decimal" required="true">
<label>Low battery threshold</label>
<description>Threshold for issuing a low battery warning.</description>
<default>25</default>
Expand All @@ -37,7 +37,7 @@
<label>Button controlled</label>
<description><![CDATA[
Activate if the app can be controlled by the user.
The select button locks on current app and the app will emit subsequent button events until the appLockTimeout is reached. Every button press before the timeout will reset timeout.
The select button locks on current app and the app will emit subsequent button events until the appLockTimeout of the bridge is reached. Every button press before the timeout will reset timeout.
]]>
</description>
<default>false</default>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@
<channel id="textCase" typeId="textCase"/>
<channel id="topText" typeId="topText"/>
<channel id="textOffset" typeId="textOffset"/>
<channel id="blinkText" typeId="blinkText"/>
<channel id="fadeText" typeId="fadeText"/>
<channel id="scrollSpeed" typeId="scrollSpeed"/>
<channel id="center" typeId="center"/>
<channel id="color" typeId="color"/>
<channel id="gradientColor" typeId="gradientColor"/>
<channel id="blinkText" typeId="blinkText"/>
<channel id="fadeText" typeId="fadeText"/>
<channel id="background" typeId="background"/>
<channel id="rainbow" typeId="rainbow"/>
<channel id="icon" typeId="icon"/>
<channel id="pushIcon" typeId="pushIcon"/>
<channel id="background" typeId="background"/>
<channel id="duration" typeId="duration"/>
<channel id="line" typeId="line"/>
<channel id="bar" typeId="bar"/>
<channel id="autoscale" typeId="autoscale"/>
<channel id="progress" typeId="progress"/>
<channel id="progressColor" typeId="progressColor"/>
<channel id="progressBackground" typeId="progressBackground"/>
<channel id="scrollSpeed" typeId="scrollSpeed"/>
<channel id="effect" typeId="effect"/>
<channel id="effectSpeed" typeId="effectSpeed"/>
<channel id="effectPalette" typeId="effectPalette"/>
Expand Down

0 comments on commit 9a3b469

Please sign in to comment.