Compare commits

..

16 Commits

Author SHA1 Message Date
clinique
2bcfae7958 Fix headers
Signed-off-by: clinique <gael@lhopital.org>
2025-01-09 15:44:24 +01:00
clinique
111312abc7 Apply spotless
Signed-off-by: clinique <gael@lhopital.org>
2025-01-09 15:31:36 +01:00
gael@lhopital.org
e32eda1c08 Rebased
Some more code refactoring

Signed-off-by: Gaël L'hopital <gael@lhopital.org>
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
2025-01-09 15:31:35 +01:00
gael@lhopital.org
da807f9633 Upgrading to 2025
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
2025-01-09 15:31:33 +01:00
gael@lhopital.org
a3d3feec7f Reviewing connector logic
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
2025-01-09 15:31:31 +01:00
clinique
7dd809b8ab Trying again to clean everything
Signed-off-by: clinique <gael@lhopital.org>
2025-01-09 15:31:30 +01:00
clinique
0959932148 Solving log errors
Signed-off-by: clinique <gael@lhopital.org>
2025-01-09 15:31:28 +01:00
clinique
3320dd39fc Apply spotless
Signed-off-by: clinique <gael@lhopital.org>
2025-01-09 15:31:27 +01:00
clinique
e12876ba11 Review the whole binding
Signed-off-by: clinique <gael@lhopital.org>
2025-01-09 15:31:25 +01:00
clinique
ed2a6d5700 Debugging
Signed-off-by: clinique <gael@lhopital.org>
2025-01-09 15:31:24 +01:00
Gaël L'hopital
c399be7a43 Some more code refactoring
Signed-off-by: Gaël L'hopital <gael@lhopital.org>
2025-01-09 15:31:22 +01:00
clinique
e4b432bb6b Ensure ressources are freed.
A bit of code revamp

Signed-off-by: clinique <gael@lhopital.org>
2025-01-09 15:31:20 +01:00
Jacob Laursen
563caa0762
[energidataservice] Improve rule example for calculating totals (#18024)
* Improve rule example for calculating totals

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Co-authored-by: Jimmy Tanagra <jcode@tanagra.id.au>
2025-01-03 23:16:28 +01:00
Ethan Dye
705feffd54
[omnilink] Improve code quality (#18017)
* Fix minor spelling errors
* Reduce code complexity

Signed-off-by: Ethan Dye <mrtops03@gmail.com>
2025-01-03 08:46:47 +01:00
Jacob Laursen
6af04fc31f
Remove space before colon (#18023)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
2025-01-02 21:38:39 +01:00
Cody Cutrer
22c7ca99ad
[mqtt.homeassistant] Re-fix null component name (#18021)
Re-fixes #15427, regressed from #17933

Signed-off-by: Cody Cutrer <cody@cutrer.us>
2025-01-02 17:00:35 +01:00
54 changed files with 343 additions and 319 deletions

View File

@ -87,19 +87,22 @@ In this example file-based using Rule Builder:
rules.when() rules.when()
.channel('energidataservice:service:energidataservice:electricity#event').triggered('DAY_AHEAD_AVAILABLE') .channel('energidataservice:service:energidataservice:electricity#event').triggered('DAY_AHEAD_AVAILABLE')
.then(event => { .then(event => {
var timeSeries = new items.TimeSeries('REPLACE'); // Short delay because persistence is asynchronous.
var start = time.LocalDate.now().atStartOfDay().atZone(time.ZoneId.systemDefault()); setTimeout(() => {
var spotPrices = items.SpotPrice.persistence.getAllStatesBetween(start, start.plusDays(2)); var timeSeries = new items.TimeSeries('REPLACE');
for (var spotPrice of spotPrices) { var start = time.LocalDate.now().atStartOfDay().atZone(time.ZoneId.systemDefault());
var totalPrice = spotPrice.quantityState var spotPrices = items.SpotPrice.persistence.getAllStatesBetween(start, start.plusDays(2));
.add(items.GridTariff.persistence.persistedState(spotPrice.timestamp).quantityState) for (var spotPrice of spotPrices) {
.add(items.SystemTariff.persistence.persistedState(spotPrice.timestamp).quantityState) var totalPrice = spotPrice.quantityState
.add(items.TransmissionGridTariff.persistence.persistedState(spotPrice.timestamp).quantityState) .add(items.GridTariff.persistence.persistedState(spotPrice.timestamp).quantityState)
.add(items.ElectricityTax.persistence.persistedState(spotPrice.timestamp).quantityState); .add(items.SystemTariff.persistence.persistedState(spotPrice.timestamp).quantityState)
.add(items.TransmissionGridTariff.persistence.persistedState(spotPrice.timestamp).quantityState)
.add(items.ElectricityTax.persistence.persistedState(spotPrice.timestamp).quantityState);
timeSeries.add(spotPrice.timestamp, totalPrice); timeSeries.add(spotPrice.timestamp, totalPrice);
} }
items.TotalPrice.persistence.persist(timeSeries); items.TotalPrice.persistence.persist(timeSeries);
}, 5000);
}) })
.build("Calculate total price"); .build("Calculate total price");
``` ```
@ -112,23 +115,25 @@ rules.when()
rule "Calculate total price" do rule "Calculate total price" do
channel "energidataservice:service:energidataservice:electricity#event", triggered: "DAY_AHEAD_AVAILABLE" channel "energidataservice:service:energidataservice:electricity#event", triggered: "DAY_AHEAD_AVAILABLE"
run do run do
# Persistence methods will call LocalDate#to_zoned_date_time which converts it after 5.seconds do # Short delay because persistence is asynchronous.
# to a ZonedDateTime in the default system zone, with 00:00 as its time portion # Persistence methods will call LocalDate#to_zoned_date_time which converts it
start = LocalDate.now # to a ZonedDateTime in the default system zone, with 00:00 as its time portion
spot_prices = SpotPrice.all_states_between(start, start + 2.days) start = LocalDate.now
spot_prices = SpotPrice.all_states_between(start, start + 2.days)
next unless spot_prices # don't proceed if the persistence result is nil next unless spot_prices # don't proceed if the persistence result is nil
time_series = TimeSeries.new # the default policy is replace time_series = TimeSeries.new # the default policy is replace
spot_prices.each do |spot_price| spot_prices.each do |spot_price|
total_price = spot_price + total_price = spot_price +
GridTariff.persisted_state(spot_price.timestamp) + GridTariff.persisted_state(spot_price.timestamp) +
SystemTariff.persisted_state(spot_price.timestamp) + SystemTariff.persisted_state(spot_price.timestamp) +
TransmissionGridTariff.persisted_state(spot_price.timestamp) + TransmissionGridTariff.persisted_state(spot_price.timestamp) +
ElectricityTax.persisted_state(spot_price.timestamp) ElectricityTax.persisted_state(spot_price.timestamp)
time_series.add(spot_price.timestamp, total_price) time_series.add(spot_price.timestamp, total_price)
end
TotalPrice.persist(time_series)
end end
TotalPrice.persist(time_series)
end end
end end
``` ```

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional
@ -75,8 +75,11 @@ public class Ipx800DeviceConnector extends Thread {
} }
/** /**
* Stop the device thread *
* Stop the
* device thread
*/ */
public void dispose() { public void dispose() {
interrupted = true; interrupted = true;
} }
@ -87,9 +90,20 @@ public class Ipx800DeviceConnector extends Thread {
} }
/** /**
* Send a random keepalive command which cause the IPX to send an update. *
* If we don't receive the update maxKeepAliveFailure time, the connection is closed * Send a
* random keepalive
* command which
* cause the
* IPX to
* send an update.*
* If we don't
* receive the
* update maxKeepAliveFailure time,
* the connection
* is closed
*/ */
private void sendKeepalive() { private void sendKeepalive() {
PortDefinition pd = PortDefinition.values()[randomizer.nextInt(PortDefinition.AS_SET.size())]; PortDefinition pd = PortDefinition.values()[randomizer.nextInt(PortDefinition.AS_SET.size())];
String command = "%s%d".formatted(pd.m2mCommand, randomizer.nextInt(pd.quantity) + 1); String command = "%s%d".formatted(pd.m2mCommand, randomizer.nextInt(pd.quantity) + 1);
@ -153,7 +167,11 @@ public class Ipx800DeviceConnector extends Thread {
} }
/** /**
* Set output of the device sending the corresponding command *
* Set output
* of the
* device sending
* the corresponding command**
* *
* @param targetPort * @param targetPort
* @param targetValue * @param targetValue
@ -165,7 +183,9 @@ public class Ipx800DeviceConnector extends Thread {
} }
/** /**
* Resets the counter value to 0 *
* Resets the
* counter value to 0**
* *
* @param targetCounter * @param targetCounter
*/ */

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -1,4 +1,4 @@
/** /*
* Copyright (c) 2010-2025 Contributors to the openHAB project * Copyright (c) 2010-2025 Contributors to the openHAB project
* *
* See the NOTICE file(s) distributed with this work for additional * See the NOTICE file(s) distributed with this work for additional

View File

@ -289,7 +289,7 @@ public abstract class AbstractComponent<C extends AbstractChannelConfiguration>
*/ */
public String getName() { public String getName() {
String result = channelConfiguration.getName(); String result = channelConfiguration.getName();
if (result.isBlank()) { if (result != null && result.isBlank()) {
result = null; result = null;
} }

View File

@ -166,6 +166,54 @@ public class SwitchTests extends AbstractComponentTests {
assertPublished("zigbee2mqtt/th1/set/auto_lock", "AUTO"); assertPublished("zigbee2mqtt/th1/set/auto_lock", "AUTO");
} }
@Test
public void testSwitchNoName() {
var component = discoverComponent(configTopicToMqtt(CONFIG_TOPIC), """
{
"availability": [
{
"topic": "zigbee2mqtt/bridge/state",
"value_template": "{{ value_json.state }}"
},
{
"topic": "zigbee2mqtt/Master Bedroom Subwoofer/availability",
"value_template": "{{ value_json.state }}"
}
],
"availability_mode": "all",
"command_topic": "zigbee2mqtt/Master Bedroom Subwoofer/set",
"device": {
"configuration_url": "http://z2m:8084/#/device/0x00124b0029e7388c/info",
"identifiers": [
"zigbee2mqtt_0x00124b0029e7388c"
],
"manufacturer": "SONOFF",
"model": "15A Zigbee smart plug (S40ZBTPB)",
"name": "Master Bedroom Subwoofer",
"sw_version": "1.1.0",
"via_device": "zigbee2mqtt_bridge_0xe0798dfffe882ce4"
},
"name": null,
"object_id": "master_bedroom_subwoofer",
"origin": {
"name": "Zigbee2MQTT",
"sw": "1.42.0-dev",
"url": "https://www.zigbee2mqtt.io"
},
"payload_off": "OFF",
"payload_on": "ON",
"state_topic": "zigbee2mqtt/Master Bedroom Subwoofer",
"unique_id": "0x00124b0029e7388c_switch_zigbee2mqtt",
"value_template": "{{ value_json.state }}"
}
""");
assertThat(component.channels.size(), is(1));
assertThat(component.getName(), is("Master Bedroom Subwoofer"));
assertChannel(component, Switch.SWITCH_CHANNEL_ID, "zigbee2mqtt/Master Bedroom Subwoofer",
"zigbee2mqtt/Master Bedroom Subwoofer/set", "Master Bedroom Subwoofer", OnOffValue.class);
}
@Override @Override
protected Set<String> getConfigTopics() { protected Set<String> getConfigTopics() {
return Set.of(CONFIG_TOPIC); return Set.of(CONFIG_TOPIC);

View File

@ -111,7 +111,7 @@ public class RoomActions implements ThingActions {
return; return;
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
logger.info("Invalid mode passed : {} - {}", mode, e.getMessage()); logger.info("Invalid mode passed: {} - {}", mode, e.getMessage());
return; return;
} }

View File

@ -55,6 +55,6 @@ public class AircareApi extends RestManager {
return station; return station;
} }
} }
throw new NetatmoException("Unexpected answer querying device '%s' : not found.", deviceId); throw new NetatmoException("Unexpected answer querying device '%s': not found.", deviceId);
} }
} }

View File

@ -65,14 +65,14 @@ public abstract class RestManager {
URI uri = uriBuilder.build(); URI uri = uriBuilder.build();
T response = apiBridge.executeUri(uri, method, clazz, payload, contentType, 3); T response = apiBridge.executeUri(uri, method, clazz, payload, contentType, 3);
if (response instanceof ApiResponse.Ok apiResponseOk && apiResponseOk.failed()) { if (response instanceof ApiResponse.Ok apiResponseOk && apiResponseOk.failed()) {
throw new NetatmoException("Command failed : %s for uri : %s", response.getStatus(), uri.toString()); throw new NetatmoException("Command failed: %s for uri: %s", response.getStatus(), uri.toString());
} }
return response; return response;
} }
private static UriBuilder appendParams(UriBuilder builder, @Nullable Object... params) { private static UriBuilder appendParams(UriBuilder builder, @Nullable Object... params) {
if (params.length % 2 != 0) { if (params.length % 2 != 0) {
throw new IllegalArgumentException("appendParams : params count must be even"); throw new IllegalArgumentException("appendParams: params count must be even");
} }
for (int i = 0; i < params.length; i += 2) { for (int i = 0; i < params.length; i += 2) {
Object param1 = params[i]; Object param1 = params[i];
@ -82,7 +82,7 @@ public abstract class RestManager {
builder.queryParam(query, param2); builder.queryParam(query, param2);
} }
} else { } else {
throw new IllegalArgumentException("appendParams : even parameters must be Strings"); throw new IllegalArgumentException("appendParams: even parameters must be Strings");
} }
} }
return builder; return builder;

View File

@ -112,7 +112,7 @@ public class SecurityApi extends RestManager {
try { try {
return get(uriBuilder, Ping.class).getStatus(); return get(uriBuilder, Ping.class).getStatus();
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.debug("Pinging {} failed : {}", vpnUrl, e.getMessage()); logger.debug("Pinging {} failed: {}", vpnUrl, e.getMessage());
return null; return null;
} }
} }

View File

@ -77,7 +77,7 @@ public class WeatherApi extends RestManager {
return station; return station;
} }
} }
throw new NetatmoException("Unexpected answer searching device '%s' : not found.", deviceId); throw new NetatmoException("Unexpected answer searching device '%s': not found.", deviceId);
} }
/** /**
@ -98,7 +98,7 @@ public class WeatherApi extends RestManager {
return station; return station;
} }
} }
throw new NetatmoException("Unexpected answer searching device '%s' : not found.", deviceId); throw new NetatmoException("Unexpected answer searching device '%s': not found.", deviceId);
} }
public Collection<NAMain> getFavoriteAndGuestStationsData() throws NetatmoException { public Collection<NAMain> getFavoriteAndGuestStationsData() throws NetatmoException {

View File

@ -248,8 +248,8 @@ public class NetatmoConstants {
} }
// Radio signal quality thresholds // Radio signal quality thresholds
static final int[] WIFI_SIGNAL_LEVELS = new int[] { 99, 84, 69, 54 }; // Resp : bad, average, good, full static final int[] WIFI_SIGNAL_LEVELS = new int[] { 99, 84, 69, 54 }; // Resp: bad, average, good, full
static final int[] RADIO_SIGNAL_LEVELS = new int[] { 90, 80, 70, 60 }; // Resp : low, medium, high, full static final int[] RADIO_SIGNAL_LEVELS = new int[] { 90, 80, 70, 60 }; // Resp: low, medium, high, full
// Thermostat definitions // Thermostat definitions
public enum SetpointMode { public enum SetpointMode {

View File

@ -59,7 +59,7 @@ class NAPushTypeDeserializer implements JsonDeserializer<NAPushType> {
} }
/** /**
* @param apiName : Netatmo Object name (NSD, NACamera...) * @param apiName Netatmo Object name (NSD, NACamera...)
* @return moduletype value if found, or else Unknown * @return moduletype value if found, or else Unknown
*/ */
public static ModuleType fromNetatmoObject(String apiName) { public static ModuleType fromNetatmoObject(String apiName) {
@ -68,7 +68,7 @@ class NAPushTypeDeserializer implements JsonDeserializer<NAPushType> {
} }
/** /**
* @param apiName : Netatmo Event name (hush, off, on ...) * @param apiName Netatmo Event name (hush, off, on ...)
* @return eventType value if found, or else Unknown * @return eventType value if found, or else Unknown
*/ */
public static EventType fromEvent(String apiName) { public static EventType fromEvent(String apiName) {

View File

@ -114,7 +114,7 @@ public class EnergyCapability extends RestCapability<EnergyApi> {
api.setThermpoint(energyId, roomId, mode, endtime, temp); api.setThermpoint(energyId, roomId, mode, endtime, temp);
handler.expireData(); handler.expireData();
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.warn("Error setting room thermostat mode '{}' : {}", mode, e.getMessage()); logger.warn("Error setting room thermostat mode '{}': {}", mode, e.getMessage());
} }
}); });
} }
@ -154,7 +154,7 @@ public class EnergyCapability extends RestCapability<EnergyApi> {
} }
handler.expireData(); handler.expireData();
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.warn("Error handling command '{}' : {}", command, e.getMessage()); logger.warn("Error handling command '{}': {}", command, e.getMessage());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
logger.warn("Command '{}' sent to channel '{}' is not a valid setpoint mode.", command, channelName); logger.warn("Command '{}' sent to channel '{}' is not a valid setpoint mode.", command, channelName);
} }

View File

@ -133,7 +133,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
} }
}); });
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.warn("Error retrieving last events for home '{}' : {}", securityId, e.getMessage()); logger.warn("Error retrieving last events for home '{}': {}", securityId, e.getMessage());
} }
return result; return result;
} }
@ -182,7 +182,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
try { try {
return api.getDeviceEvents(securityId, moduleId, deviceType); return api.getDeviceEvents(securityId, moduleId, deviceType);
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.warn("Error retrieving last events of camera '{}' : {}", moduleId, e.getMessage()); logger.warn("Error retrieving last events of camera '{}': {}", moduleId, e.getMessage());
return null; return null;
} }
}).orElse(List.of())); }).orElse(List.of()));
@ -193,7 +193,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
try { try {
return api.getPersonEvents(securityId, personId); return api.getPersonEvents(securityId, personId);
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.warn("Error retrieving last events of person '{}' : {}", personId, e.getMessage()); logger.warn("Error retrieving last events of person '{}': {}", personId, e.getMessage());
return null; return null;
} }
}).orElse(List.of())); }).orElse(List.of()));
@ -205,7 +205,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
api.setPersonAwayStatus(securityId, personId, away); api.setPersonAwayStatus(securityId, personId, away);
handler.expireData(); handler.expireData();
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.warn("Error setting person away/at home '{}' : {}", personId, e.getMessage()); logger.warn("Error setting person away/at home '{}': {}", personId, e.getMessage());
} }
}); });
} }
@ -224,7 +224,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
api.changeStatus(localURL, status); api.changeStatus(localURL, status);
handler.expireData(); handler.expireData();
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.warn("Error changing camera monitoring status '{}' : {}", status, e.getMessage()); logger.warn("Error changing camera monitoring status '{}': {}", status, e.getMessage());
} }
}); });
} }
@ -235,7 +235,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
api.changeFloodLightMode(securityId, cameraId, mode); api.changeFloodLightMode(securityId, cameraId, mode);
handler.expireData(); handler.expireData();
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.warn("Error changing Presence floodlight mode '{}' : {}", mode, e.getMessage()); logger.warn("Error changing Presence floodlight mode '{}': {}", mode, e.getMessage());
} }
}); });
} }

View File

@ -87,7 +87,7 @@ public class NetatmoThingTypeProvider implements ThingTypeProvider {
return localizationService.createLocalizedThingType(bundle, return localizationService.createLocalizedThingType(bundle,
moduleType.isABridge() ? thingTypeBuilder.buildBridge() : thingTypeBuilder.build(), locale); moduleType.isABridge() ? thingTypeBuilder.buildBridge() : thingTypeBuilder.build(), locale);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
logger.warn("Unable to define ModuleType for thingType {} : {}", thingTypeUID.getId(), e.getMessage()); logger.warn("Unable to define ModuleType for thingType {}: {}", thingTypeUID.getId(), e.getMessage());
} }
} }
return null; return null;

View File

@ -93,7 +93,7 @@ public class GrantServlet extends NetatmoServlet {
resp.getWriter().append(replaceKeysFromMap(accountTemplate, replaceMap)); resp.getWriter().append(replaceKeysFromMap(accountTemplate, replaceMap));
resp.getWriter().close(); resp.getWriter().close();
} else { } else {
logger.warn("Unexpected : requestUrl is null"); logger.warn("Unexpected: requestUrl is null");
} }
} }

View File

@ -71,9 +71,9 @@ public class WebhookServlet extends NetatmoServlet {
logger.info("Setting up WebHook at Netatmo to {}", uri.toString()); logger.info("Setting up WebHook at Netatmo to {}", uri.toString());
hookSet = securityApi.addwebhook(uri); hookSet = securityApi.addwebhook(uri);
} catch (UriBuilderException e) { } catch (UriBuilderException e) {
logger.info("webhookUrl is not a valid URI '{}' : {}", uri, e.getMessage()); logger.info("webhookUrl is not a valid URI '{}': {}", uri, e.getMessage());
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.info("Error setting webhook : {}", e.getMessage()); logger.info("Error setting webhook: {}", e.getMessage());
} }
} }
@ -85,7 +85,7 @@ public class WebhookServlet extends NetatmoServlet {
securityApi.dropWebhook(); securityApi.dropWebhook();
hookSet = false; hookSet = false;
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.warn("Error releasing webhook : {}", e.getMessage()); logger.warn("Error releasing webhook: {}", e.getMessage());
} }
} }
super.dispose(); super.dispose();
@ -99,12 +99,12 @@ public class WebhookServlet extends NetatmoServlet {
private void processEvent(String data) throws IOException { private void processEvent(String data) throws IOException {
if (!data.isEmpty()) { if (!data.isEmpty()) {
logger.debug("Event transmitted from restService : {}", data); logger.debug("Event transmitted from restService: {}", data);
try { try {
WebhookEvent event = deserializer.deserialize(WebhookEvent.class, data); WebhookEvent event = deserializer.deserialize(WebhookEvent.class, data);
notifyListeners(event); notifyListeners(event);
} catch (NetatmoException e) { } catch (NetatmoException e) {
logger.debug("Error deserializing webhook data received : {}. {}", data, e.getMessage()); logger.debug("Error deserializing webhook data received: {}. {}", data, e.getMessage());
} }
} }
} }

View File

@ -47,10 +47,6 @@ public enum AreaAlarm {
return alarmBits.testBit(bit); return alarmBits.testBit(bit);
} }
public boolean isSet(int alarmBits) {
return isSet(BigInteger.valueOf(alarmBits));
}
public String getChannelUID() { public String getChannelUID() {
return channelUID; return channelUID;
} }

View File

@ -162,7 +162,6 @@ public class OmnilinkBindingConstants {
public static final String TRIGGER_CHANNEL_DCM_EVENT = "dcm_event"; public static final String TRIGGER_CHANNEL_DCM_EVENT = "dcm_event";
public static final String TRIGGER_CHANNEL_ENERGY_COST_EVENT = "energy_cost_event"; public static final String TRIGGER_CHANNEL_ENERGY_COST_EVENT = "energy_cost_event";
public static final String TRIGGER_CHANNEL_CAMERA_TRIGGER_EVENT = "camera_trigger_event"; public static final String TRIGGER_CHANNEL_CAMERA_TRIGGER_EVENT = "camera_trigger_event";
public static final String TRIGGER_CHANNEL_ACCESS_CONTROL_READER_EVENT = "access_control_reader_event";
public static final String TRIGGER_CHANNEL_AREA_ALL_ON_OFF_EVENT = "all_on_off_event"; public static final String TRIGGER_CHANNEL_AREA_ALL_ON_OFF_EVENT = "all_on_off_event";
public static final String TRIGGER_CHANNEL_SWITCH_PRESS_EVENT = "switch_press_event"; public static final String TRIGGER_CHANNEL_SWITCH_PRESS_EVENT = "switch_press_event";
public static final String TRIGGER_CHANNEL_UPB_LINK_ACTIVATED_EVENT = "upb_link_activated_event"; public static final String TRIGGER_CHANNEL_UPB_LINK_ACTIVATED_EVENT = "upb_link_activated_event";

View File

@ -51,7 +51,7 @@ public enum TemperatureFormat {
private final int formatNumber; private final int formatNumber;
private TemperatureFormat(int formatNumber) { TemperatureFormat(int formatNumber) {
this.formatNumber = formatNumber; this.formatNumber = formatNumber;
} }

View File

@ -67,11 +67,8 @@ public class OmnilinkActions implements ThingActions {
zdt = ZonedDateTime.now(ZoneId.of(zone)); zdt = ZonedDateTime.now(ZoneId.of(zone));
} else { } else {
logger.debug("Time zone provided invalid, using system default!"); logger.debug("Time zone provided invalid, using system default!");
if (timeZoneProvider.isPresent()) { zdt = timeZoneProvider.map(zoneProvider -> ZonedDateTime.now(zoneProvider.getTimeZone()))
zdt = ZonedDateTime.now(timeZoneProvider.get().getTimeZone()); .orElseGet(() -> ZonedDateTime.now(ZoneId.systemDefault()));
} else {
zdt = ZonedDateTime.now(ZoneId.systemDefault());
}
} }
actionsHandler.synchronizeControllerTime(zdt); actionsHandler.synchronizeControllerTime(zdt);
} }

View File

@ -99,9 +99,9 @@ public class OmnilinkDiscoveryService extends AbstractThingHandlerDiscoveryServi
} }
/** /**
* Calculate the area filter the a supplied area * Calculate the area filter of a supplied area
* *
* @param area Area to calculate filter for. * @param areaProperties Area to calculate filter for.
* @return Calculated Bit Filter for the supplied area. Bit 0 is area 1, bit 2 is area 2 and so on. * @return Calculated Bit Filter for the supplied area. Bit 0 is area 1, bit 2 is area 2 and so on.
*/ */
private static int bitFilterForArea(AreaProperties areaProperties) { private static int bitFilterForArea(AreaProperties areaProperties) {
@ -328,7 +328,7 @@ public class OmnilinkDiscoveryService extends AbstractThingHandlerDiscoveryServi
/** /**
* Discovers OmniLink areas * Discovers OmniLink areas
*/ */
private @Nullable List<AreaProperties> discoverAreas() { private List<AreaProperties> discoverAreas() {
final ThingUID bridgeUID = thingHandler.getThing().getUID(); final ThingUID bridgeUID = thingHandler.getThing().getUID();
List<AreaProperties> areas = new LinkedList<>(); List<AreaProperties> areas = new LinkedList<>();
@ -356,22 +356,18 @@ public class OmnilinkDiscoveryService extends AbstractThingHandlerDiscoveryServi
final String name = thingName; final String name = thingName;
systemType.ifPresentOrElse(t -> { systemType.ifPresentOrElse(t -> {
ThingUID thingUID = null; ThingUID thingUID;
switch (t) { if (t == SystemType.LUMINA) {
case LUMINA: thingUID = new ThingUID(THING_TYPE_LUMINA_AREA, bridgeUID, thingID);
thingUID = new ThingUID(THING_TYPE_LUMINA_AREA, bridgeUID, thingID); } else {
break; thingUID = new ThingUID(THING_TYPE_OMNI_AREA, bridgeUID, thingID);
default:
thingUID = new ThingUID(THING_TYPE_OMNI_AREA, bridgeUID, thingID);
} }
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties) DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
.withProperty(THING_PROPERTIES_NUMBER, thingID) .withProperty(THING_PROPERTIES_NUMBER, thingID)
.withRepresentationProperty(THING_PROPERTIES_NUMBER).withBridge(bridgeUID).withLabel(name) .withRepresentationProperty(THING_PROPERTIES_NUMBER).withBridge(bridgeUID).withLabel(name)
.build(); .build();
thingDiscovered(discoveryResult); thingDiscovered(discoveryResult);
}, () -> { }, () -> logger.warn("Unknown System Type"));
logger.warn("Unknown System Type");
});
areas.add(areaProperties); areas.add(areaProperties);
} }
@ -397,7 +393,7 @@ public class OmnilinkDiscoveryService extends AbstractThingHandlerDiscoveryServi
int thingType = unitProperties.getUnitType(); int thingType = unitProperties.getUnitType();
String thingName = unitProperties.getName(); String thingName = unitProperties.getName();
String thingID = Integer.toString(unitProperties.getNumber()); String thingID = Integer.toString(unitProperties.getNumber());
ThingUID thingUID = null; ThingUID thingUID;
Map<String, Object> properties = new HashMap<>(); Map<String, Object> properties = new HashMap<>();
properties.put(THING_PROPERTIES_NAME, thingName); properties.put(THING_PROPERTIES_NAME, thingName);

View File

@ -21,8 +21,9 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
* @author Craig Hamilton - Initial contribution * @author Craig Hamilton - Initial contribution
*/ */
@NonNullByDefault @NonNullByDefault
@SuppressWarnings("serial")
public class BridgeOfflineException extends Exception { public class BridgeOfflineException extends Exception {
private static final long serialVersionUID = 1L;
public BridgeOfflineException(Exception e) { public BridgeOfflineException(Exception e) {
super(e); super(e);
} }

View File

@ -67,14 +67,14 @@ public abstract class AbstractAreaHandler extends AbstractOmnilinkStatusHandler<
super.initialize(); super.initialize();
if (bridgeHandler != null) { if (bridgeHandler != null) {
updateAreaProperties(bridgeHandler); updateAreaProperties();
} else { } else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
"Received null bridge while initializing Area!"); "Received null bridge while initializing Area!");
} }
} }
private void updateAreaProperties(OmnilinkBridgeHandler bridgeHandler) { private void updateAreaProperties() {
final List<AreaProperties> areas = getAreaProperties(); final List<AreaProperties> areas = getAreaProperties();
if (areas != null) { if (areas != null) {
for (AreaProperties areaProperties : areas) { for (AreaProperties areaProperties : areas) {
@ -99,13 +99,10 @@ public abstract class AbstractAreaHandler extends AbstractOmnilinkStatusHandler<
return; return;
} }
switch (channelUID.getId()) { if (channelUID.getId().equals(CHANNEL_AREA_ACTIVATE_KEYPAD_EMERGENCY)) {
case CHANNEL_AREA_ACTIVATE_KEYPAD_EMERGENCY: handleKeypadEmergency(command);
handleKeypadEmergency(channelUID, command); } else {
break; handleSecurityMode(channelUID, command);
default:
handleSecurityMode(channelUID, command);
break;
} }
} }
@ -176,7 +173,7 @@ public abstract class AbstractAreaHandler extends AbstractOmnilinkStatusHandler<
*/ */
protected abstract EnumSet<AreaAlarm> getAlarms(); protected abstract EnumSet<AreaAlarm> getAlarms();
private void handleKeypadEmergency(ChannelUID channelUID, Command command) { private void handleKeypadEmergency(Command command) {
if (command instanceof DecimalType decimalCommand) { if (command instanceof DecimalType decimalCommand) {
try { try {
final OmnilinkBridgeHandler bridge = getOmnilinkBridgeHandler(); final OmnilinkBridgeHandler bridge = getOmnilinkBridgeHandler();

View File

@ -71,7 +71,7 @@ public abstract class AbstractOmnilinkHandler extends BaseThingHandler {
} }
/** /**
* Calculate the area filter the a supplied area * Calculate the area filter of a supplied area
* *
* @param areaProperties Area to calculate filter for. * @param areaProperties Area to calculate filter for.
* @return Calculated Bit Filter for the supplied area. Bit 0 is area 1, bit 2 is area 2 and so on. * @return Calculated Bit Filter for the supplied area. Bit 0 is area 1, bit 2 is area 2 and so on.
@ -120,7 +120,7 @@ public abstract class AbstractOmnilinkHandler extends BaseThingHandler {
protected int getAreaNumber() { protected int getAreaNumber() {
String areaNumber = getThing().getProperties().get(THING_PROPERTIES_AREA); String areaNumber = getThing().getProperties().get(THING_PROPERTIES_AREA);
if (areaNumber != null) { if (areaNumber != null) {
return Integer.valueOf(areaNumber); return Integer.parseInt(areaNumber);
} else { } else {
return -1; return -1;
} }

View File

@ -25,7 +25,7 @@ import com.digitaldan.jomnilinkII.MessageTypes.statuses.Status;
/** /**
* The {@link AbstractOmnilinkStatusHandler} defines some methods that can be used across * The {@link AbstractOmnilinkStatusHandler} defines some methods that can be used across
* the many different units exposed by the OmniLink protocol to retrive updated status information. * the many different units exposed by the OmniLink protocol to retrieve updated status information.
* *
* @author Craig Hamilton - Initial contribution * @author Craig Hamilton - Initial contribution
* @author Ethan Dye - openHAB3 rewrite * @author Ethan Dye - openHAB3 rewrite

View File

@ -50,7 +50,6 @@ import com.digitaldan.jomnilinkII.OmniUnknownMessageTypeException;
@NonNullByDefault @NonNullByDefault
public class AudioSourceHandler extends AbstractOmnilinkHandler { public class AudioSourceHandler extends AbstractOmnilinkHandler {
private final Logger logger = LoggerFactory.getLogger(AudioSourceHandler.class); private final Logger logger = LoggerFactory.getLogger(AudioSourceHandler.class);
private final int pollDelaySeconds = 5;
private final int thingID = getThingNumber(); private final int thingID = getThingNumber();
private @Nullable ScheduledFuture<?> scheduledPolling = null; private @Nullable ScheduledFuture<?> scheduledPolling = null;
public @Nullable String number; public @Nullable String number;
@ -64,7 +63,7 @@ public class AudioSourceHandler extends AbstractOmnilinkHandler {
final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler(); final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler();
if (bridgeHandler != null) { if (bridgeHandler != null) {
updateStatus(ThingStatus.ONLINE); updateStatus(ThingStatus.ONLINE);
if (((Boolean) getThing().getConfiguration().get(THING_PROPERTIES_AUTOSTART)).booleanValue()) { if ((Boolean) getThing().getConfiguration().get(THING_PROPERTIES_AUTOSTART)) {
logger.debug("Autostart enabled, scheduling polling for Audio Source: {}", thingID); logger.debug("Autostart enabled, scheduling polling for Audio Source: {}", thingID);
schedulePolling(); schedulePolling();
} else { } else {
@ -104,6 +103,7 @@ public class AudioSourceHandler extends AbstractOmnilinkHandler {
private synchronized void schedulePolling() { private synchronized void schedulePolling() {
cancelPolling(); cancelPolling();
logger.debug("Scheduling polling for Audio Source: {}", thingID); logger.debug("Scheduling polling for Audio Source: {}", thingID);
int pollDelaySeconds = 5;
scheduledPolling = super.scheduler.scheduleWithFixedDelay(this::pollAudioSource, 0, pollDelaySeconds, scheduledPolling = super.scheduler.scheduleWithFixedDelay(this::pollAudioSource, 0, pollDelaySeconds,
TimeUnit.SECONDS); TimeUnit.SECONDS);
} }
@ -113,19 +113,17 @@ public class AudioSourceHandler extends AbstractOmnilinkHandler {
logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command); logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command);
final ScheduledFuture<?> scheduledPolling = this.scheduledPolling; final ScheduledFuture<?> scheduledPolling = this.scheduledPolling;
switch (channelUID.getId()) { if (CHANNEL_AUDIO_SOURCE_POLLING.equals(channelUID.getId())) {
case CHANNEL_AUDIO_SOURCE_POLLING: if (command instanceof RefreshType) {
if (command instanceof RefreshType) { updateState(CHANNEL_AUDIO_SOURCE_POLLING,
updateState(CHANNEL_AUDIO_SOURCE_POLLING, OnOffType.from((scheduledPolling != null && !scheduledPolling.isDone())));
OnOffType.from((scheduledPolling != null && !scheduledPolling.isDone()))); } else if (command instanceof OnOffType onOffCommand) {
} else if (command instanceof OnOffType onOffCommand) { handlePolling(channelUID, onOffCommand);
handlePolling(channelUID, onOffCommand); } else {
} else { logger.debug("Invalid command: {}, must be RefreshType or OnOffType", command);
logger.debug("Invalid command: {}, must be RefreshType or OnOffType", command); }
} } else {
break; logger.warn("Unknown channel for Audio Source thing: {}", channelUID);
default:
logger.warn("Unknown channel for Audio Source thing: {}", channelUID);
} }
} }
@ -174,7 +172,7 @@ public class AudioSourceHandler extends AbstractOmnilinkHandler {
logger.debug("Received null bridge while polling Audio Source statuses!"); logger.debug("Received null bridge while polling Audio Source statuses!");
} }
} catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) { } catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) {
logger.debug("Exception recieved while polling for Audio Source statuses: {}", e.getMessage()); logger.debug("Exception received while polling for Audio Source statuses: {}", e.getMessage());
} }
} }
} }

View File

@ -95,17 +95,15 @@ public class ButtonHandler extends AbstractOmnilinkHandler {
return; return;
} }
switch (channelUID.getId()) { if (CHANNEL_BUTTON_PRESS.equals(channelUID.getId())) {
case CHANNEL_BUTTON_PRESS: if (command instanceof OnOffType) {
if (command instanceof OnOffType) { sendOmnilinkCommand(CommandMessage.CMD_BUTTON, 0, thingID);
sendOmnilinkCommand(CommandMessage.CMD_BUTTON, 0, thingID); updateChannels();
updateChannels(); } else {
} else { logger.debug("Invalid command: {}, must be OnOffType", command);
logger.debug("Invalid command: {}, must be OnOffType", command); }
} } else {
break; logger.warn("Unknown channel for Button thing: {}", channelUID);
default:
logger.warn("Unknown channel for Button thing: {}", channelUID);
} }
} }

View File

@ -125,7 +125,7 @@ public class HumiditySensorHandler extends AbstractOmnilinkStatusHandler<Extende
thingID); thingID);
break; break;
default: default:
logger.warn("Unknown channel for Humdity Sensor thing: {}", channelUID); logger.warn("Unknown channel for Humidity Sensor thing: {}", channelUID);
} }
} }

View File

@ -88,17 +88,16 @@ public class LockHandler extends AbstractOmnilinkStatusHandler<ExtendedAccessCon
return; return;
} }
switch (channelUID.getId()) { if (CHANNEL_LOCK_SWITCH.equals(channelUID.getId())) {
case CHANNEL_LOCK_SWITCH: if (command instanceof OnOffType) {
if (command instanceof OnOffType) { sendOmnilinkCommand(
sendOmnilinkCommand(OnOffType.OFF.equals(command) ? CommandMessage.CMD_UNLOCK_DOOR OnOffType.OFF.equals(command) ? CommandMessage.CMD_UNLOCK_DOOR : CommandMessage.CMD_LOCK_DOOR,
: CommandMessage.CMD_LOCK_DOOR, 0, thingID); 0, thingID);
} else { } else {
logger.debug("Invalid command {}, must be OnOffType", command); logger.debug("Invalid command {}, must be OnOffType", command);
} }
break; } else {
default: logger.warn("Unknown channel for Lock thing: {}", channelUID);
logger.warn("Unknown channel for Lock thing: {}", channelUID);
} }
} }

View File

@ -44,22 +44,15 @@ public class LuminaAreaHandler extends AbstractAreaHandler {
@Override @Override
protected int getMode(ChannelUID channelUID) { protected int getMode(ChannelUID channelUID) {
switch (channelUID.getId()) { return switch (channelUID.getId()) {
case CHANNEL_AREA_SECURITY_MODE_HOME: case CHANNEL_AREA_SECURITY_MODE_HOME -> CommandMessage.CMD_SECURITY_LUMINA_HOME_MODE;
return CommandMessage.CMD_SECURITY_LUMINA_HOME_MODE; case CHANNEL_AREA_SECURITY_MODE_SLEEP -> CommandMessage.CMD_SECURITY_LUMINA_SLEEP_MODE;
case CHANNEL_AREA_SECURITY_MODE_SLEEP: case CHANNEL_AREA_SECURITY_MODE_AWAY -> CommandMessage.CMD_SECURITY_LUMINA_AWAY_MODE;
return CommandMessage.CMD_SECURITY_LUMINA_SLEEP_MODE; case CHANNEL_AREA_SECURITY_MODE_VACATION -> CommandMessage.CMD_SECURITY_LUMINA_VACATION_MODE;
case CHANNEL_AREA_SECURITY_MODE_AWAY: case CHANNEL_AREA_SECURITY_MODE_PARTY -> CommandMessage.CMD_SECURITY_LUMINA_PARTY_MODE;
return CommandMessage.CMD_SECURITY_LUMINA_AWAY_MODE; case CHANNEL_AREA_SECURITY_MODE_SPECIAL -> CommandMessage.CMD_SECURITY_LUMINA_SPECIAL_MODE;
case CHANNEL_AREA_SECURITY_MODE_VACATION: default -> throw new IllegalStateException("Unknown channel for area thing " + channelUID);
return CommandMessage.CMD_SECURITY_LUMINA_VACATION_MODE; };
case CHANNEL_AREA_SECURITY_MODE_PARTY:
return CommandMessage.CMD_SECURITY_LUMINA_PARTY_MODE;
case CHANNEL_AREA_SECURITY_MODE_SPECIAL:
return CommandMessage.CMD_SECURITY_LUMINA_SPECIAL_MODE;
default:
throw new IllegalStateException("Unknown channel for area thing " + channelUID);
}
} }
@Override @Override

View File

@ -45,24 +45,16 @@ public class OmniAreaHandler extends AbstractAreaHandler {
@Override @Override
protected int getMode(ChannelUID channelUID) { protected int getMode(ChannelUID channelUID) {
switch (channelUID.getId()) { return switch (channelUID.getId()) {
case CHANNEL_AREA_SECURITY_MODE_DISARM: case CHANNEL_AREA_SECURITY_MODE_DISARM -> CommandMessage.CMD_SECURITY_OMNI_DISARM;
return CommandMessage.CMD_SECURITY_OMNI_DISARM; case CHANNEL_AREA_SECURITY_MODE_DAY -> CommandMessage.CMD_SECURITY_OMNI_DAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_DAY: case CHANNEL_AREA_SECURITY_MODE_NIGHT -> CommandMessage.CMD_SECURITY_OMNI_NIGHT_MODE;
return CommandMessage.CMD_SECURITY_OMNI_DAY_MODE; case CHANNEL_AREA_SECURITY_MODE_AWAY -> CommandMessage.CMD_SECURITY_OMNI_AWAY_MODE;
case CHANNEL_AREA_SECURITY_MODE_NIGHT: case CHANNEL_AREA_SECURITY_MODE_VACATION -> CommandMessage.CMD_SECURITY_OMNI_VACATION_MODE;
return CommandMessage.CMD_SECURITY_OMNI_NIGHT_MODE; case CHANNEL_AREA_SECURITY_MODE_DAY_INSTANT -> CommandMessage.CMD_SECURITY_OMNI_DAY_INSTANT_MODE;
case CHANNEL_AREA_SECURITY_MODE_AWAY: case CHANNEL_AREA_SECURITY_MODE_NIGHT_DELAYED -> CommandMessage.CMD_SECURITY_OMNI_NIGHT_DELAYED_MODE;
return CommandMessage.CMD_SECURITY_OMNI_AWAY_MODE; default -> throw new IllegalStateException("Unknown channel for area thing " + channelUID);
case CHANNEL_AREA_SECURITY_MODE_VACATION: };
return CommandMessage.CMD_SECURITY_OMNI_VACATION_MODE;
case CHANNEL_AREA_SECURITY_MODE_DAY_INSTANT:
return CommandMessage.CMD_SECURITY_OMNI_DAY_INSTANT_MODE;
case CHANNEL_AREA_SECURITY_MODE_NIGHT_DELAYED:
return CommandMessage.CMD_SECURITY_OMNI_NIGHT_DELAYED_MODE;
default:
throw new IllegalStateException("Unknown channel for area thing " + channelUID);
}
} }
@Override @Override

View File

@ -95,7 +95,6 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
private @Nullable Connection omniConnection = null; private @Nullable Connection omniConnection = null;
private @Nullable ScheduledFuture<?> connectJob; private @Nullable ScheduledFuture<?> connectJob;
private @Nullable ScheduledFuture<?> eventPollingJob; private @Nullable ScheduledFuture<?> eventPollingJob;
private final int autoReconnectPeriod = 60;
private Optional<AudioPlayer> audioPlayer = Optional.empty(); private Optional<AudioPlayer> audioPlayer = Optional.empty();
private Optional<SystemType> systemType = Optional.empty(); private Optional<SystemType> systemType = Optional.empty();
private final Gson gson = new Gson(); private final Gson gson = new Gson();
@ -240,9 +239,9 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
* HAI only supports one audio player - cycle through features until we find a feature that is an audio * HAI only supports one audio player - cycle through features until we find a feature that is an audio
* player. * player.
*/ */
audioPlayer = Objects.requireNonNull(reqSystemFeatures().getFeatures().stream() audioPlayer = Objects.requireNonNull(
.map(featureCode -> AudioPlayer.getAudioPlayerForFeatureCode(featureCode)) reqSystemFeatures().getFeatures().stream().map(AudioPlayer::getAudioPlayerForFeatureCode)
.filter(Optional::isPresent).findFirst().orElse(Optional.empty())); .filter(Optional::isPresent).findFirst().orElse(Optional.empty()));
systemType = SystemType.getType(reqSystemInformation().getModel()); systemType = SystemType.getType(reqSystemInformation().getModel());
@ -288,80 +287,83 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
if (objectStatus != null) { if (objectStatus != null) {
Status[] statuses = objectStatus.getStatuses(); Status[] statuses = objectStatus.getStatuses();
for (Status status : statuses) { for (Status status : statuses) {
if (status instanceof ExtendedUnitStatus unitStatus) { switch (status) {
int unitNumber = unitStatus.getNumber(); case ExtendedUnitStatus unitStatus -> {
int unitNumber = unitStatus.getNumber();
logger.debug("Received status update for Unit: {}, status: {}", unitNumber, unitStatus); logger.debug("Received status update for Unit: {}, status: {}", unitNumber, unitStatus);
Optional<Thing> theThing = getUnitThing(unitNumber); Optional<Thing> theThing = getUnitThing(unitNumber);
theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((UnitHandler) theHandler).handleStatus(unitStatus));
} else if (status instanceof ExtendedZoneStatus zoneStatus) {
int zoneNumber = zoneStatus.getNumber();
logger.debug("Received status update for Zone: {}, status: {}", zoneNumber, zoneStatus);
Optional<Thing> theThing = getChildThing(THING_TYPE_ZONE, zoneNumber);
theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((ZoneHandler) theHandler).handleStatus(zoneStatus));
} else if (status instanceof ExtendedAreaStatus areaStatus) {
int areaNumber = areaStatus.getNumber();
logger.debug("Received status update for Area: {}, status: {}", areaNumber, areaStatus);
systemType.ifPresent(t -> {
Optional<Thing> theThing = Optional.empty();
switch (t) {
case LUMINA:
theThing = getChildThing(THING_TYPE_LUMINA_AREA, areaNumber);
break;
case OMNI:
theThing = getChildThing(THING_TYPE_OMNI_AREA, areaNumber);
break;
}
theThing.map(Thing::getHandler) theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((AbstractAreaHandler) theHandler).handleStatus(areaStatus)); .ifPresent(theHandler -> ((UnitHandler) theHandler).handleStatus(unitStatus));
});
} else if (status instanceof ExtendedAccessControlReaderLockStatus lockStatus) {
int lockNumber = lockStatus.getNumber();
logger.debug("Received status update for Lock: {}, status: {}", lockNumber, lockStatus);
Optional<Thing> theThing = getChildThing(THING_TYPE_LOCK, lockNumber);
theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((LockHandler) theHandler).handleStatus(lockStatus));
} else if (status instanceof ExtendedThermostatStatus thermostatStatus) {
int thermostatNumber = thermostatStatus.getNumber();
logger.debug("Received status update for Thermostat: {}, status: {}", thermostatNumber,
thermostatStatus);
Optional<Thing> theThing = getChildThing(THING_TYPE_THERMOSTAT, thermostatNumber);
theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((ThermostatHandler) theHandler).handleStatus(thermostatStatus));
} else if (status instanceof ExtendedAudioZoneStatus audioZoneStatus) {
int audioZoneNumber = audioZoneStatus.getNumber();
logger.debug("Received status update for Audio Zone: {}, status: {}", audioZoneNumber,
audioZoneStatus);
Optional<Thing> theThing = getChildThing(THING_TYPE_AUDIO_ZONE, audioZoneNumber);
theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((AudioZoneHandler) theHandler).handleStatus(audioZoneStatus));
} else if (status instanceof ExtendedAuxSensorStatus auxSensorStatus) {
int auxSensorNumber = auxSensorStatus.getNumber();
// Aux Sensors can be either temperature or humidity, need to check both.
Optional<Thing> tempThing = getChildThing(THING_TYPE_TEMP_SENSOR, auxSensorNumber);
Optional<Thing> humidityThing = getChildThing(THING_TYPE_HUMIDITY_SENSOR, auxSensorNumber);
if (tempThing.isPresent()) {
logger.debug("Received status update for Temperature Sensor: {}, status: {}", auxSensorNumber,
auxSensorStatus);
tempThing.map(Thing::getHandler).ifPresent(
theHandler -> ((TempSensorHandler) theHandler).handleStatus(auxSensorStatus));
} }
if (humidityThing.isPresent()) { case ExtendedZoneStatus zoneStatus -> {
logger.debug("Received status update for Humidity Sensor: {}, status: {}", auxSensorNumber, int zoneNumber = zoneStatus.getNumber();
auxSensorStatus);
humidityThing.map(Thing::getHandler).ifPresent( logger.debug("Received status update for Zone: {}, status: {}", zoneNumber, zoneStatus);
theHandler -> ((HumiditySensorHandler) theHandler).handleStatus(auxSensorStatus)); Optional<Thing> theThing = getChildThing(THING_TYPE_ZONE, zoneNumber);
theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((ZoneHandler) theHandler).handleStatus(zoneStatus));
} }
} else { case ExtendedAreaStatus areaStatus -> {
logger.debug("Received Object Status Notification that was not processed: {}", objectStatus); int areaNumber = areaStatus.getNumber();
logger.debug("Received status update for Area: {}, status: {}", areaNumber, areaStatus);
systemType.ifPresent(t -> {
Optional<Thing> theThing = switch (t) {
case LUMINA -> getChildThing(THING_TYPE_LUMINA_AREA, areaNumber);
case OMNI -> getChildThing(THING_TYPE_OMNI_AREA, areaNumber);
};
theThing.map(Thing::getHandler).ifPresent(
theHandler -> ((AbstractAreaHandler) theHandler).handleStatus(areaStatus));
});
}
case ExtendedAccessControlReaderLockStatus lockStatus -> {
int lockNumber = lockStatus.getNumber();
logger.debug("Received status update for Lock: {}, status: {}", lockNumber, lockStatus);
Optional<Thing> theThing = getChildThing(THING_TYPE_LOCK, lockNumber);
theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((LockHandler) theHandler).handleStatus(lockStatus));
}
case ExtendedThermostatStatus thermostatStatus -> {
int thermostatNumber = thermostatStatus.getNumber();
logger.debug("Received status update for Thermostat: {}, status: {}", thermostatNumber,
thermostatStatus);
Optional<Thing> theThing = getChildThing(THING_TYPE_THERMOSTAT, thermostatNumber);
theThing.map(Thing::getHandler).ifPresent(
theHandler -> ((ThermostatHandler) theHandler).handleStatus(thermostatStatus));
}
case ExtendedAudioZoneStatus audioZoneStatus -> {
int audioZoneNumber = audioZoneStatus.getNumber();
logger.debug("Received status update for Audio Zone: {}, status: {}", audioZoneNumber,
audioZoneStatus);
Optional<Thing> theThing = getChildThing(THING_TYPE_AUDIO_ZONE, audioZoneNumber);
theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((AudioZoneHandler) theHandler).handleStatus(audioZoneStatus));
}
case ExtendedAuxSensorStatus auxSensorStatus -> {
int auxSensorNumber = auxSensorStatus.getNumber();
// Aux Sensors can be either temperature or humidity, need to check both.
Optional<Thing> tempThing = getChildThing(THING_TYPE_TEMP_SENSOR, auxSensorNumber);
Optional<Thing> humidityThing = getChildThing(THING_TYPE_HUMIDITY_SENSOR, auxSensorNumber);
if (tempThing.isPresent()) {
logger.debug("Received status update for Temperature Sensor: {}, status: {}",
auxSensorNumber, auxSensorStatus);
tempThing.map(Thing::getHandler).ifPresent(
theHandler -> ((TempSensorHandler) theHandler).handleStatus(auxSensorStatus));
}
if (humidityThing.isPresent()) {
logger.debug("Received status update for Humidity Sensor: {}, status: {}", auxSensorNumber,
auxSensorStatus);
humidityThing.map(Thing::getHandler).ifPresent(
theHandler -> ((HumiditySensorHandler) theHandler).handleStatus(auxSensorStatus));
}
}
case null, default ->
logger.debug("Received Object Status Notification that was not processed: {}", objectStatus);
} }
} }
} else { } else {
@ -476,12 +478,9 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
SystemStatus status = getOmniConnection().reqSystemStatus(); SystemStatus status = getOmniConnection().reqSystemStatus();
logger.debug("Received system status: {}", status); logger.debug("Received system status: {}", status);
// Update controller's reported time // Update controller's reported time
String dateString = new StringBuilder().append(2000 + status.getYear()).append("-") String dateString = (2000 + status.getYear()) + "-" + String.format("%02d", status.getMonth()) + "-"
.append(String.format("%02d", status.getMonth())).append("-") + String.format("%02d", status.getDay()) + "T" + String.format("%02d", status.getHour()) + ":"
.append(String.format("%02d", status.getDay())).append("T") + String.format("%02d", status.getMinute()) + ":" + String.format("%02d", status.getSecond());
.append(String.format("%02d", status.getHour())).append(":")
.append(String.format("%02d", status.getMinute())).append(":")
.append(String.format("%02d", status.getSecond())).toString();
updateState(CHANNEL_SYSTEM_DATE, new DateTimeType(dateString)); updateState(CHANNEL_SYSTEM_DATE, new DateTimeType(dateString));
} }
@ -578,10 +577,8 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
SystemInformation systemInformation = reqSystemInformation(); SystemInformation systemInformation = reqSystemInformation();
Map<String, String> properties = editProperties(); Map<String, String> properties = editProperties();
properties.put(Thing.PROPERTY_MODEL_ID, Integer.toString(systemInformation.getModel())); properties.put(Thing.PROPERTY_MODEL_ID, Integer.toString(systemInformation.getModel()));
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, properties.put(Thing.PROPERTY_FIRMWARE_VERSION, systemInformation.getMajor() + "."
Integer.toString(systemInformation.getMajor()) + "." + systemInformation.getMinor() + "." + systemInformation.getRevision());
+ Integer.toString(systemInformation.getMinor()) + "."
+ Integer.toString(systemInformation.getRevision()));
properties.put(THING_PROPERTIES_PHONE_NUMBER, systemInformation.getPhone()); properties.put(THING_PROPERTIES_PHONE_NUMBER, systemInformation.getPhone());
updateProperties(properties); updateProperties(properties);
} catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) { } catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) {
@ -597,8 +594,7 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
private void scheduleReconnectJob() { private void scheduleReconnectJob() {
ScheduledFuture<?> currentReconnectJob = connectJob; ScheduledFuture<?> currentReconnectJob = connectJob;
if (currentReconnectJob == null || currentReconnectJob.isDone()) { if (currentReconnectJob == null || currentReconnectJob.isDone()) {
connectJob = super.scheduler.scheduleWithFixedDelay(this::makeOmnilinkConnection, 0, autoReconnectPeriod, connectJob = super.scheduler.scheduleWithFixedDelay(this::makeOmnilinkConnection, 0, 60, TimeUnit.SECONDS);
TimeUnit.SECONDS);
} }
} }
@ -647,13 +643,13 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
logger.debug("Processing event log message number: {}", logData.getEventNumber()); logger.debug("Processing event log message number: {}", logData.getEventNumber());
eventLogNumber = logData.getEventNumber(); eventLogNumber = logData.getEventNumber();
String json = gson.toJson(logData); String json = gson.toJson(logData);
logger.debug("Receieved event log message: {}", json); logger.debug("Received event log message: {}", json);
updateState(CHANNEL_EVENT_LOG, new StringType(json)); updateState(CHANNEL_EVENT_LOG, new StringType(json));
} }
} while (message.getMessageType() != Message.MESG_TYPE_END_OF_DATA); } while (message.getMessageType() != Message.MESG_TYPE_END_OF_DATA);
} catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) { } catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) {
logger.debug("Exception recieved while polling for event log messages: {}", e.getMessage()); logger.debug("Exception received while polling for event log messages: {}", e.getMessage());
} }
} }

View File

@ -103,7 +103,7 @@ public class TempSensorHandler extends AbstractOmnilinkStatusHandler<ExtendedAux
public void handleCommand(ChannelUID channelUID, Command command) { public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command); logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command);
final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler(); final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler();
Optional<TemperatureFormat> temperatureFormat = Optional.empty(); Optional<TemperatureFormat> temperatureFormat;
if (command instanceof RefreshType) { if (command instanceof RefreshType) {
retrieveStatus().ifPresentOrElse(this::updateChannels, () -> updateStatus(ThingStatus.OFFLINE, retrieveStatus().ifPresentOrElse(this::updateChannels, () -> updateStatus(ThingStatus.OFFLINE,
@ -118,7 +118,7 @@ public class TempSensorHandler extends AbstractOmnilinkStatusHandler<ExtendedAux
if (bridgeHandler != null) { if (bridgeHandler != null) {
temperatureFormat = bridgeHandler.getTemperatureFormat(); temperatureFormat = bridgeHandler.getTemperatureFormat();
if (temperatureFormat.isEmpty()) { if (temperatureFormat.isEmpty()) {
logger.warn("Receieved null temperature format!"); logger.warn("Received null temperature format!");
return; return;
} }
} else { } else {
@ -158,7 +158,7 @@ public class TempSensorHandler extends AbstractOmnilinkStatusHandler<ExtendedAux
temperatureFormat.get().omniToFormat(status.getHeatSetpoint()), temperatureFormat.get().omniToFormat(status.getHeatSetpoint()),
temperatureFormat.get().getFormatNumber() == 1 ? ImperialUnits.FAHRENHEIT : SIUnits.CELSIUS)); temperatureFormat.get().getFormatNumber() == 1 ? ImperialUnits.FAHRENHEIT : SIUnits.CELSIUS));
} else { } else {
logger.warn("Receieved null temperature format, could not update Temperature Sensor channels!"); logger.warn("Received null temperature format, could not update Temperature Sensor channels!");
} }
} else { } else {
logger.debug("Received null bridge while updating Temperature Sensor channels!"); logger.debug("Received null bridge while updating Temperature Sensor channels!");

View File

@ -75,7 +75,7 @@ public class ThermostatHandler extends AbstractOmnilinkStatusHandler<ExtendedThe
private final int bit; private final int bit;
private final int modeValue; private final int modeValue;
private ThermostatStatus(int bit, int modeValue) { ThermostatStatus(int bit, int modeValue) {
this.bit = bit; this.bit = bit;
this.modeValue = modeValue; this.modeValue = modeValue;
} }
@ -122,7 +122,7 @@ public class ThermostatHandler extends AbstractOmnilinkStatusHandler<ExtendedThe
public void handleCommand(ChannelUID channelUID, Command command) { public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command); logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command);
final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler(); final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler();
Optional<TemperatureFormat> temperatureFormat = Optional.empty(); Optional<TemperatureFormat> temperatureFormat;
if (command instanceof RefreshType) { if (command instanceof RefreshType) {
retrieveStatus().ifPresentOrElse(this::updateChannels, () -> updateStatus(ThingStatus.OFFLINE, retrieveStatus().ifPresentOrElse(this::updateChannels, () -> updateStatus(ThingStatus.OFFLINE,
@ -137,7 +137,7 @@ public class ThermostatHandler extends AbstractOmnilinkStatusHandler<ExtendedThe
if (bridgeHandler != null) { if (bridgeHandler != null) {
temperatureFormat = bridgeHandler.getTemperatureFormat(); temperatureFormat = bridgeHandler.getTemperatureFormat();
if (temperatureFormat.isEmpty()) { if (temperatureFormat.isEmpty()) {
logger.warn("Receieved null temperature format!"); logger.warn("Received null temperature format!");
return; return;
} }
} else { } else {
@ -226,7 +226,7 @@ public class ThermostatHandler extends AbstractOmnilinkStatusHandler<ExtendedThe
temperatureFormat.get().omniToFormat(status.getHeatSetpoint()), temperatureFormat.get().omniToFormat(status.getHeatSetpoint()),
temperatureFormat.get().getFormatNumber() == 1 ? ImperialUnits.FAHRENHEIT : SIUnits.CELSIUS)); temperatureFormat.get().getFormatNumber() == 1 ? ImperialUnits.FAHRENHEIT : SIUnits.CELSIUS));
} else { } else {
logger.warn("Receieved null temperature format, could not update Thermostat channels!"); logger.warn("Received null temperature format, could not update Thermostat channels!");
} }
} else { } else {
logger.warn("Could not connect to Bridge, failed to get temperature format!"); logger.warn("Could not connect to Bridge, failed to get temperature format!");

View File

@ -160,11 +160,9 @@ public class UnitHandler extends AbstractOmnilinkStatusHandler<ExtendedUnitStatu
public void updateChannels(ExtendedUnitStatus status) { public void updateChannels(ExtendedUnitStatus status) {
logger.debug("updateChannels called for Unit status: {}", status); logger.debug("updateChannels called for Unit status: {}", status);
int unitStatus = status.getStatus(); int unitStatus = status.getStatus();
int level = 0; int level = Status.UNIT_OFF;
if (unitStatus == Status.UNIT_OFF) { if (unitStatus == Status.UNIT_ON) {
level = 0;
} else if (unitStatus == Status.UNIT_ON) {
level = 100; level = 100;
} else if ((unitStatus >= Status.UNIT_SCENE_A) && (unitStatus <= Status.UNIT_SCENE_L)) { } else if ((unitStatus >= Status.UNIT_SCENE_A) && (unitStatus <= Status.UNIT_SCENE_L)) {
level = 100; level = 100;
@ -206,7 +204,7 @@ public class UnitHandler extends AbstractOmnilinkStatusHandler<ExtendedUnitStatu
/** /**
* Handle a switch press event by triggering the appropriate channel. * Handle a switch press event by triggering the appropriate channel.
* *
* @param switchPressEvent * @param switchPressEvent A switch press event to handle.
*/ */
public void handleSwitchPressEvent(SwitchPressEvent switchPressEvent) { public void handleSwitchPressEvent(SwitchPressEvent switchPressEvent) {
ChannelUID activateChannel = new ChannelUID(getThing().getUID(), TRIGGER_CHANNEL_SWITCH_PRESS_EVENT); ChannelUID activateChannel = new ChannelUID(getThing().getUID(), TRIGGER_CHANNEL_SWITCH_PRESS_EVENT);

View File

@ -81,7 +81,7 @@ public class ZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedZoneStatu
final List<AreaProperties> areas = super.getAreaProperties(); final List<AreaProperties> areas = super.getAreaProperties();
if (areas != null) { if (areas != null) {
for (AreaProperties areaProperties : areas) { for (AreaProperties areaProperties : areas) {
int areaFilter = super.bitFilterForArea(areaProperties); int areaFilter = bitFilterForArea(areaProperties);
ObjectPropertyRequest<ZoneProperties> objectPropertyRequest = ObjectPropertyRequest ObjectPropertyRequest<ZoneProperties> objectPropertyRequest = ObjectPropertyRequest
.builder(bridgeHandler, ObjectPropertyRequests.ZONE, getThingNumber(), 0).selectNamed() .builder(bridgeHandler, ObjectPropertyRequests.ZONE, getThingNumber(), 0).selectNamed()
@ -115,16 +115,11 @@ public class ZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedZoneStatu
return; return;
} }
switch (channelUID.getId()) { mode = switch (channelUID.getId()) {
case CHANNEL_ZONE_BYPASS: case CHANNEL_ZONE_BYPASS -> CommandMessage.CMD_SECURITY_BYPASS_ZONE;
mode = CommandMessage.CMD_SECURITY_BYPASS_ZONE; case CHANNEL_ZONE_RESTORE -> CommandMessage.CMD_SECURITY_RESTORE_ZONE;
break; default -> -1;
case CHANNEL_ZONE_RESTORE: };
mode = CommandMessage.CMD_SECURITY_RESTORE_ZONE;
break;
default:
mode = -1;
}
logger.debug("mode {} on zone {} with code {}", mode, thingID, command.toFullString()); logger.debug("mode {} on zone {} with code {}", mode, thingID, command.toFullString());
char[] code = command.toFullString().toCharArray(); char[] code = command.toFullString().toCharArray();
if (code.length != 4) { if (code.length != 4) {
@ -174,7 +169,7 @@ public class ZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedZoneStatu
@Override @Override
protected void updateChannels(ExtendedZoneStatus zoneStatus) { protected void updateChannels(ExtendedZoneStatus zoneStatus) {
// 0 Secure. 1 Not ready, 3 Trouble // 0 Secure. 1 Not ready, 3 Trouble
int current = ((zoneStatus.getStatus() >> 0) & 0x03); int current = ((zoneStatus.getStatus()) & 0x03);
// 0 Secure, 1 Tripped, 2 Reset, but previously tripped // 0 Secure, 1 Tripped, 2 Reset, but previously tripped
int latched = ((zoneStatus.getStatus() >> 2) & 0x03); int latched = ((zoneStatus.getStatus() >> 2) & 0x03);
// 0 Disarmed, 1 Armed, 2 Bypass user, 3 Bypass system // 0 Disarmed, 1 Armed, 2 Bypass user, 3 Bypass system

View File

@ -49,13 +49,11 @@ public class DimmableUnitHandler extends UnitHandler {
@Override @Override
public void handleCommand(ChannelUID channelUID, Command command) { public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command); logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command);
switch (channelUID.getId()) { if (CHANNEL_UNIT_LEVEL.equals(channelUID.getId())) {
case CHANNEL_UNIT_LEVEL: handleUnitLevel(channelUID, command);
handleUnitLevel(channelUID, command); } else {
break; logger.debug("Unknown channel for Dimmable Unit thing: {}", channelUID);
default: super.handleCommand(channelUID, command);
logger.debug("Unknown channel for Dimmable Unit thing: {}", channelUID);
super.handleCommand(channelUID, command);
} }
} }

View File

@ -146,7 +146,7 @@ public class UpbRoomHandler extends UnitHandler {
param2 = ((roomNum * 6) - 3) + cmdValue - 2; param2 = ((roomNum * 6) - 3) + cmdValue - 2;
break; break;
default: default:
logger.warn("Unexpected UPB Room state: {}", Integer.toString(cmdValue)); logger.warn("Unexpected UPB Room state: {}", cmdValue);
return; return;
} }

View File

@ -55,18 +55,16 @@ public class UpbUnitHandler extends DimmableUnitHandler {
return; return;
} }
switch (channelUID.getId()) { if (CHANNEL_UPB_STATUS.equals(channelUID.getId())) {
case CHANNEL_UPB_STATUS: if (command instanceof StringType) {
if (command instanceof StringType) { sendOmnilinkCommand(CommandMessage.CMD_UNIT_UPB_REQ_STATUS, 0, thingID);
sendOmnilinkCommand(CommandMessage.CMD_UNIT_UPB_REQ_STATUS, 0, thingID); updateState(CHANNEL_UPB_STATUS, UnDefType.UNDEF);
updateState(CHANNEL_UPB_STATUS, UnDefType.UNDEF); } else {
} else { logger.debug("Invalid command: {}, must be StringType", command);
logger.debug("Invalid command: {}, must be StringType", command); }
} } else {
break; logger.debug("Unknown channel for UPB Unit thing: {}", channelUID);
default: super.handleCommand(channelUID, command);
logger.debug("Unknown channel for UPB Unit thing: {}", channelUID);
super.handleCommand(channelUID, command);
} }
} }
} }