diff --git a/bundles/org.openhab.binding.chromecast/README.md b/bundles/org.openhab.binding.chromecast/README.md index bd9c26b7528bd..f4d3f2f59e49c 100644 --- a/bundles/org.openhab.binding.chromecast/README.md +++ b/bundles/org.openhab.binding.chromecast/README.md @@ -56,7 +56,7 @@ Thing chromecast:audiogroup:bathroom [ ipAddress="192.168.0.23", port=42139] | playuri | String | Can be used to tell the Chromecast to play media from a given url | | appName | String | Name of currently running application | | appId | String | ID of currently running application | -| idling | Switch | Read-only indication on weather Chromecast is on idle screen | +| idling | Switch | Read-only indication on whether Chromecast is on idle screen | | statustext | String | | | currentTime | Number:Time | Current time of currently playing media | | duration | Number:Time | Duration of current track (null if between tracks) | diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java index 595f1716282f6..0cf5c0c0d2cea 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java @@ -15,7 +15,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.library.types.PercentType; import org.openhab.core.thing.ThingTypeUID; -import org.openhab.core.thing.type.ChannelTypeUID; /** * The {@link BindingConstants} class defines common constants, which are @@ -120,11 +119,6 @@ public class BindingConstants { public static final String CHANNEL_SCENE = "scene"; public static final String CHANNEL_ONTIME = "ontime"; - // channel uids - public static final ChannelTypeUID CHANNEL_EFFECT_TYPE_UID = new ChannelTypeUID(BINDING_ID, CHANNEL_EFFECT); - public static final ChannelTypeUID CHANNEL_EFFECT_SPEED_TYPE_UID = new ChannelTypeUID(BINDING_ID, - CHANNEL_EFFECT_SPEED); - // Thing configuration public static final String CONFIG_HOST = "host"; public static final String CONFIG_HTTP_PORT = "httpPort"; diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBaseThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBaseThingHandler.java index 9f40f49022676..e869fd15cbb5b 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBaseThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/DeconzBaseThingHandler.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.deconz.internal.handler; +import static org.openhab.binding.deconz.internal.BindingConstants.*; + import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; @@ -25,12 +27,16 @@ import org.openhab.binding.deconz.internal.netutils.WebSocketMessageListener; import org.openhab.binding.deconz.internal.types.ResourceType; import org.openhab.core.thing.Bridge; +import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; 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.ThingHandlerCallback; +import org.openhab.core.thing.type.ChannelKind; +import org.openhab.core.thing.type.ChannelTypeUID; import org.openhab.core.types.Command; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -222,4 +228,30 @@ public void initialize() { bridgeStatusChanged(bridge.getStatusInfo()); } } + + protected void createChannel(String channelId, ChannelKind kind) { + if (thing.getChannel(channelId) != null) { + // channel already exists, no update necessary + return; + } + + ThingHandlerCallback callback = getCallback(); + if (callback != null) { + ChannelUID channelUID = new ChannelUID(thing.getUID(), channelId); + ChannelTypeUID channelTypeUID; + switch (channelId) { + case CHANNEL_BATTERY_LEVEL: + channelTypeUID = new ChannelTypeUID("system:battery-level"); + break; + case CHANNEL_BATTERY_LOW: + channelTypeUID = new ChannelTypeUID("system:low-battery"); + break; + default: + channelTypeUID = new ChannelTypeUID(BINDING_ID, channelId); + break; + } + Channel channel = callback.createChannelBuilder(channelUID, channelTypeUID).withKind(kind).build(); + updateThing(editThing().withChannel(channel).build()); + } + } } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index dab69ea8100b2..4a6a81328b481 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -46,8 +46,7 @@ import org.openhab.core.thing.ThingStatus; import org.openhab.core.thing.ThingStatusDetail; import org.openhab.core.thing.ThingTypeUID; -import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.core.thing.binding.builder.ThingBuilder; +import org.openhab.core.thing.type.ChannelKind; import org.openhab.core.types.Command; import org.openhab.core.types.CommandOption; import org.openhab.core.types.RefreshType; @@ -346,22 +345,13 @@ private void checkAndUpdateEffectChannels(LightMessage lightMessage) { } ChannelUID effectChannelUID = new ChannelUID(thing.getUID(), CHANNEL_EFFECT); - ChannelUID effectSpeedChannelUID = new ChannelUID(thing.getUID(), CHANNEL_EFFECT_SPEED); - - if (thing.getChannel(CHANNEL_EFFECT) == null) { - ThingBuilder thingBuilder = editThing(); - thingBuilder.withChannel( - ChannelBuilder.create(effectChannelUID, "String").withType(CHANNEL_EFFECT_TYPE_UID).build()); - if (model == EffectLightModel.LIDL_MELINARA) { - // additional channels - thingBuilder.withChannel(ChannelBuilder.create(effectSpeedChannelUID, "Number") - .withType(CHANNEL_EFFECT_SPEED_TYPE_UID).build()); - } - updateThing(thingBuilder.build()); - } + createChannel(CHANNEL_EFFECT, ChannelKind.STATE); switch (model) { case LIDL_MELINARA: + // additional channels + createChannel(CHANNEL_EFFECT_SPEED, ChannelKind.STATE); + List options = List.of("none", "steady", "snow", "rainbow", "snake", "tinkle", "fireworks", "flag", "waves", "updown", "vintage", "fading", "collide", "strobe", "sparkles", "carnival", "glow"); diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorBaseThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorBaseThingHandler.java index 389d8c83f69c8..f54998b58b84a 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorBaseThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorBaseThingHandler.java @@ -38,9 +38,7 @@ import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; import org.openhab.core.thing.ThingStatusDetail; -import org.openhab.core.thing.binding.ThingHandlerCallback; import org.openhab.core.thing.type.ChannelKind; -import org.openhab.core.thing.type.ChannelTypeUID; import org.openhab.core.types.Command; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -172,32 +170,6 @@ private void processLastSeen(DeconzBaseMessage stateResponse) { } } - protected void createChannel(String channelId, ChannelKind kind) { - if (thing.getChannel(channelId) != null) { - // channel already exists, no update necessary - return; - } - - ThingHandlerCallback callback = getCallback(); - if (callback != null) { - ChannelUID channelUID = new ChannelUID(thing.getUID(), channelId); - ChannelTypeUID channelTypeUID; - switch (channelId) { - case CHANNEL_BATTERY_LEVEL: - channelTypeUID = new ChannelTypeUID("system:battery-level"); - break; - case CHANNEL_BATTERY_LOW: - channelTypeUID = new ChannelTypeUID("system:low-battery"); - break; - default: - channelTypeUID = new ChannelTypeUID(BINDING_ID, channelId); - break; - } - Channel channel = callback.createChannelBuilder(channelUID, channelTypeUID).withKind(kind).build(); - updateThing(editThing().withChannel(channel).build()); - } - } - /** * Update channel value from {@link SensorConfig} object - override to include further channels * diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorThermostatThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorThermostatThingHandler.java index a3df6fb063245..f6e83fbb23a87 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorThermostatThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/SensorThermostatThingHandler.java @@ -39,9 +39,7 @@ import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingTypeUID; -import org.openhab.core.thing.binding.builder.ChannelBuilder; -import org.openhab.core.thing.binding.builder.ThingBuilder; -import org.openhab.core.thing.type.ChannelTypeUID; +import org.openhab.core.thing.type.ChannelKind; import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; import org.slf4j.Logger; @@ -201,11 +199,8 @@ protected void processStateResponse(DeconzBaseMessage stateResponse) { SensorMessage sensorMessage = (SensorMessage) stateResponse; SensorState sensorState = sensorMessage.state; - if (sensorState != null && sensorState.windowopen != null && thing.getChannel(CHANNEL_WINDOWOPEN) == null) { - ThingBuilder thingBuilder = editThing(); - thingBuilder.withChannel(ChannelBuilder.create(new ChannelUID(thing.getUID(), CHANNEL_WINDOWOPEN), "String") - .withType(new ChannelTypeUID(BINDING_ID, "open")).build()); - updateThing(thingBuilder.build()); + if (sensorState != null && sensorState.windowopen != null) { + createChannel(CHANNEL_WINDOWOPEN, ChannelKind.STATE); } super.processStateResponse(stateResponse); diff --git a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/servlet/HomeConnectServlet.java b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/servlet/HomeConnectServlet.java index de8520c742ac7..84dc26470c50a 100644 --- a/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/servlet/HomeConnectServlet.java +++ b/bundles/org.openhab.binding.homeconnect/src/main/java/org/openhab/binding/homeconnect/internal/servlet/HomeConnectServlet.java @@ -163,9 +163,7 @@ protected void doGet(@Nullable HttpServletRequest request, @Nullable HttpServlet String path = request.getPathInfo(); if (path == null || path.isEmpty() || path.equals(ROOT_PATH)) { - @Nullable String code = request.getParameter(PARAM_CODE); - @Nullable String state = request.getParameter(PARAM_STATE); if (code != null && state != null && !code.trim().isEmpty() && !state.trim().isEmpty()) { getBridgeAuthenticationPage(request, response, code, state); @@ -173,9 +171,7 @@ protected void doGet(@Nullable HttpServletRequest request, @Nullable HttpServlet getBridgesPage(request, response); } } else if (pathMatches(path, APPLIANCES_PATH)) { - @Nullable String action = request.getParameter(PARAM_ACTION); - @Nullable String thingId = request.getParameter(PARAM_THING_ID); if (action != null && thingId != null && !action.trim().isEmpty() && !thingId.trim().isEmpty()) { processApplianceActions(response, action, thingId); @@ -183,9 +179,7 @@ protected void doGet(@Nullable HttpServletRequest request, @Nullable HttpServlet getAppliancesPage(request, response); } } else if (pathMatches(path, REQUEST_LOG_PATH)) { - @Nullable String export = request.getParameter(PARAM_EXPORT); - @Nullable String bridgeId = request.getParameter(PARAM_BRIDGE_ID); if (export != null && bridgeId != null && !export.trim().isEmpty() && !bridgeId.trim().isEmpty()) { getRequestLogExport(response, bridgeId); @@ -193,9 +187,7 @@ protected void doGet(@Nullable HttpServletRequest request, @Nullable HttpServlet getRequestLogPage(request, response); } } else if (pathMatches(path, EVENT_LOG_PATH)) { - @Nullable String export = request.getParameter(PARAM_EXPORT); - @Nullable String bridgeId = request.getParameter(PARAM_BRIDGE_ID); if (export != null && bridgeId != null && !export.trim().isEmpty() && !bridgeId.trim().isEmpty()) { getEventLogExport(response, bridgeId); @@ -225,11 +217,8 @@ protected void doPost(@Nullable HttpServletRequest request, @Nullable HttpServle } } else if (pathMatches(path, APPLIANCES_PATH)) { String requestPayload = request.getReader().lines().collect(Collectors.joining(System.lineSeparator())); - @Nullable String action = request.getParameter(PARAM_ACTION); - @Nullable String thingId = request.getParameter(PARAM_THING_ID); - @Nullable String targetPath = request.getParameter(PARAM_PATH); if ((ACTION_PUT_RAW.equals(action) || ACTION_GET_RAW.equals(action)) && thingId != null @@ -366,7 +355,6 @@ private void processRawApplianceActions(HttpServletResponse response, String act String actionResponse = bridgeHandler.get().getApiClient().putRaw(haId, path, body); response.getWriter().write(actionResponse); } else if (ACTION_GET_RAW.equals(action)) { - @Nullable String actionResponse = bridgeHandler.get().getApiClient().getRaw(haId, path, true); if (actionResponse == null) { response.getWriter().write("{\"status\": \"No response\"}"); @@ -393,9 +381,7 @@ private void getBridgesPage(HttpServletRequest request, HttpServletResponse resp } private void postBridgesPage(HttpServletRequest request, HttpServletResponse response) throws IOException { - @Nullable String action = request.getParameter(PARAM_ACTION); - @Nullable String bridgeId = request.getParameter(PARAM_BRIDGE_ID); Optional bridgeHandlerOptional = bridgeHandlers.stream().filter( homeConnectBridgeHandler -> homeConnectBridgeHandler.getThing().getUID().toString().equals(bridgeId)) diff --git a/bundles/org.openhab.binding.homeconnect/src/main/resources/assets/js/homeconnect.js b/bundles/org.openhab.binding.homeconnect/src/main/resources/assets/js/homeconnect.js index 596a7f0d2821c..9f7fb05ef11e6 100644 --- a/bundles/org.openhab.binding.homeconnect/src/main/resources/assets/js/homeconnect.js +++ b/bundles/org.openhab.binding.homeconnect/src/main/resources/assets/js/homeconnect.js @@ -1,4 +1,4 @@ -/* globals Chart:false, feather:false, Plotly:false, requests:false */ +/* globals Chart:false, feather:false, requests:false */ (function () { 'use strict' @@ -112,6 +112,7 @@ var modal = $(this); var requestBodyElement = modal.find('.modal-request-body'); var title = modal.find('.modal-title'); + var titleBadgeElement = modal.find('.modal-title-badge'); var responseBodyElement = modal.find('.modal-response-body'); var requestHeaderElement = modal.find('.modal-request-header'); var responseHeaderElement = modal.find('.modal-response-header'); @@ -134,6 +135,23 @@ responseBodyElement.addClass('text-muted') } + titleBadgeElement.empty(); + if (request.homeConnectResponse) { + var statusCode = request.homeConnectResponse.code; + titleBadgeElement.text(statusCode); + titleBadgeElement.removeClass('badge-success'); + titleBadgeElement.removeClass('badge-danger'); + titleBadgeElement.removeClass('badge-warning'); + + if (statusCode >= 300 && statusCode != 404) { + titleBadgeElement.addClass('badge-danger'); + } else if (statusCode >= 200 && statusCode < 300) { + titleBadgeElement.addClass('badge-success'); + } else { + titleBadgeElement.addClass('badge-warning'); + } + } + responseHeaderElement.empty(); if (request.homeConnectResponse && request.homeConnectResponse.header) { var responseHeader = request.homeConnectResponse.header; @@ -159,60 +177,4 @@ $('.reload-page').click(function () { location.reload(); }); - - $('.request-chart').each(function (index, element) { - var bridgeId = $(this).data('bridge-id'); - var chartElement = element; - - function makeplot (bridgeId, chartElement) { - Plotly.d3.csv('requests?bridgeId=' + bridgeId + '&action=request-csv', function (data) { - processData(data, chartElement) - }); - } - - function processData (allRows, chartElement) { - console.log(allRows); - var x = [], y = [], standardDeviation = []; - - for (var i = 0; i < allRows.length; i++) { - var row = allRows[i]; - x.push(row['time']); - y.push(row['requests']); - } - console.log('X', x, 'Y', y, 'SD', standardDeviation); - makePlotly(x, y, standardDeviation, chartElement); - } - - function makePlotly (x, y, standard_deviation, chartElement){ - var traces = [{ - x: x, - y: y, - type: 'histogram', - histfunc: 'sum', - xbins: { - size: 1000 - } - }]; - - Plotly.newPlot(chartElement, traces, - { - xaxis: { - rangemode: 'nonnegative', - autorange: true, - title: '', - type: 'date' - }, - yaxis: { - title: 'requests', - rangemode: 'nonnegative' - } - }, - { - displayModeBar: false, - responsive: true - }); - } - - makeplot(bridgeId, chartElement); - }); }()) diff --git a/bundles/org.openhab.binding.homeconnect/src/main/resources/templates/log-requests.html b/bundles/org.openhab.binding.homeconnect/src/main/resources/templates/log-requests.html index 62cc0e7f8f12f..e70625008bc07 100644 --- a/bundles/org.openhab.binding.homeconnect/src/main/resources/templates/log-requests.html +++ b/bundles/org.openhab.binding.homeconnect/src/main/resources/templates/log-requests.html @@ -60,6 +60,7 @@