Skip to content

Commit

Permalink
Initial OH 3.4 release with experimental skyq changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andan67 committed Nov 6, 2022
1 parent 25f5653 commit 2d3492b
Show file tree
Hide file tree
Showing 21 changed files with 134 additions and 66 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.skyq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>3.4.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.skyq</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down Expand Up @@ -134,13 +134,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
List<String> commandList = new ArrayList<>();
commandList.add("backup");
commandList.addAll(Arrays.asList(command.toString().split("")));
if (controlProtocol.sendCommand(commandList)) {
SkyChannel skyChannel = sidToSkyChannelMap.get(command.toString());
updateState(
new ChannelUID(thing.getUID(), CHANNEL_GROUP_STATUS, CHANNEL_CURRENT_CHANNEL_TITLE),
new StringType(skyChannel != null ? skyChannel.title : "UNDEF"));
}
;
controlProtocol.sendCommand(commandList);
}
}
break;
Expand Down Expand Up @@ -170,6 +164,8 @@ public void handleCommand(ChannelUID channelUID, Command command) {
default:
break;
}
// refresh states from handling event for channel id
refreshState(id);
}

@Override
Expand Down Expand Up @@ -215,7 +211,6 @@ private void refreshSkyChannels() {
sidToSkyChannelMap = new LinkedHashMap<>();
skyChannels.forEach(s -> sidToSkyChannelMap.put(s.id, s));

// sidToSkyChannelMap.clear();
List<StateOption> stateOptions = new ArrayList<>();

if (config != null && config.configurablePresets) {
Expand Down Expand Up @@ -254,7 +249,6 @@ private void refreshSkyChannels() {
if (!dispNum.isEmpty()) {
si = Optional.of(new StateOption(dispNum, title));
}
// sidToSkyChannelMap.put(e.id, e);
return si;
}).filter(Optional::isPresent).map(Optional::get)
.filter(a -> (rankMap.getOrDefault(a.getValue(), Integer.MAX_VALUE)) >= 0)
Expand Down Expand Up @@ -303,7 +297,6 @@ private void refreshSkyChannels() {
final List<StateOption> stateOptionsToAdd = favorites.stream().map(f -> {
SkyChannel c = sidToSkyChannelMap.get(f.id);
StateOption si = new StateOption(Utils.defaultIfEmpty(c.dispNum, "000"), c.title);
// sidToSkyChannelMap.put(c.id, c);
return si;
}).collect(Collectors.toList());
stateOptions.add(new StateOption(RESTProtocol.PRESET_REFRESH, RESTProtocol.PRESET_REFRESH));
Expand Down Expand Up @@ -471,9 +464,19 @@ private void refreshPowerStatus(boolean performUpdate) {
}

private void refreshState(boolean initial) {
refreshState(initial, "");
}

private void refreshState(String handledChannel) {
refreshState(false, handledChannel);
}

private void refreshState(boolean initial, String handledChannel) {
// get current system information
if (restProtocol != null) {
refreshPowerStatus(true);
if (handledChannel.isEmpty()) {
refreshPowerStatus(true);
}
if (initial || sidToSkyChannelMap.isEmpty()) {
refreshSkyChannels();
}
Expand All @@ -490,10 +493,15 @@ private void refreshState(boolean initial) {
SkyChannel skyChannel = sidToSkyChannelMap.get(currentSid);
updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_STATUS, CHANNEL_CURRENT_CHANNEL_TITLE),
new StringType(skyChannel != null ? skyChannel.title : "UNDEF"));
updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_CONTROL, CHANNEL_PRESET),
new StringType(skyChannel != null ? skyChannel.dispNum : "UNDEF"));
updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_CONTROL, CHANNEL_FAVORITES),
new StringType(skyChannel != null ? skyChannel.dispNum : "UNDEF"));
if (handledChannel.equals(CHANNEL_FAVORITES)) {
updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_CONTROL, CHANNEL_PRESET),
new StringType(skyChannel != null ? skyChannel.dispNum : "UNDEF"));
}
if (handledChannel.equals(CHANNEL_PRESET)) {
updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_CONTROL, CHANNEL_FAVORITES),
new StringType(skyChannel != null ? skyChannel.dispNum : "UNDEF"));
}

}
}
@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand All @@ -10,7 +10,6 @@
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.openhab.binding.skyq.internal.models;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand All @@ -10,7 +10,6 @@
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.openhab.binding.skyq.internal.models;

import org.eclipse.jdt.annotation.NonNullByDefault;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
* Copyright (c) 2010-2022 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.sony/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>3.4.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.sony</artifactId>
Expand Down
Loading

0 comments on commit 2d3492b

Please sign in to comment.