Skip to content

Commit

Permalink
Merge branch 'openhab:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRSatzteil authored Jul 6, 2021
2 parents df6d002 + 28c580b commit 0911618
Show file tree
Hide file tree
Showing 29 changed files with 189 additions and 358 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.chromecast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> options = List.of("none", "steady", "snow", "rainbow", "snake", "tinkle", "fireworks",
"flag", "waves", "updown", "vintage", "fading", "collide", "strobe", "sparkles", "carnival",
"glow");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,39 +163,31 @@ 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);
} else {
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);
} else {
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);
} else {
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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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\"}");
Expand All @@ -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<HomeConnectBridgeHandler> bridgeHandlerOptional = bridgeHandlers.stream().filter(
homeConnectBridgeHandler -> homeConnectBridgeHandler.getThing().getUID().toString().equals(bridgeId))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals Chart:false, feather:false, Plotly:false, requests:false */
/* globals Chart:false, feather:false, requests:false */

(function () {
'use strict'
Expand Down Expand Up @@ -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');
Expand All @@ -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;
Expand All @@ -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);
});
}())
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ <h2 th:text="${thing.getLabel() + ' (' + uid + ')'}" style="display: inline-bloc
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<span class="modal-title-badge badge mt-2 mr-1">200</span>
<h5 class="modal-title .text-truncate" id="requestDetailModalLabel">Request Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.insteon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ Avoid duplicate keys by finding the highest fake product key in the `device_type

### Adding New Device Features

If you can't can't build a new device out of the existing device features (for a complete list see `device_features.xml`) you can add new features by specifying a file (let's call it `my_own_features.xml`) with the "additionalDevices" option in the network config parameters:
If you can't build a new device out of the existing device features (for a complete list see `device_features.xml`) you can add new features by specifying a file (let's call it `my_own_features.xml`) with the "additionalDevices" option in the network config parameters:

additionalFeatures="/usr/local/openhab/rt/my_own_features.xml"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
<label>Insteon Device</label>
<description>Insteon devices such as switches, dimmers, keypads, sensors, etc.</description>

<representation-property>address</representation-property>

<config-description>
<parameter name="address" type="text" required="true">
<label>Address</label>
Expand Down
Loading

0 comments on commit 0911618

Please sign in to comment.