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,6 +87,8 @@ In this example file-based using Rule Builder:
rules.when()
.channel('energidataservice:service:energidataservice:electricity#event').triggered('DAY_AHEAD_AVAILABLE')
.then(event => {
// Short delay because persistence is asynchronous.
setTimeout(() => {
var timeSeries = new items.TimeSeries('REPLACE');
var start = time.LocalDate.now().atStartOfDay().atZone(time.ZoneId.systemDefault());
var spotPrices = items.SpotPrice.persistence.getAllStatesBetween(start, start.plusDays(2));
@ -100,6 +102,7 @@ rules.when()
timeSeries.add(spotPrice.timestamp, totalPrice);
}
items.TotalPrice.persistence.persist(timeSeries);
}, 5000);
})
.build("Calculate total price");
```
@ -112,6 +115,7 @@ rules.when()
rule "Calculate total price" do
channel "energidataservice:service:energidataservice:electricity#event", triggered: "DAY_AHEAD_AVAILABLE"
run do
after 5.seconds do # Short delay because persistence is asynchronous.
# Persistence methods will call LocalDate#to_zoned_date_time which converts it
# to a ZonedDateTime in the default system zone, with 00:00 as its time portion
start = LocalDate.now
@ -130,6 +134,7 @@ rule "Calculate total price" do
end
TotalPrice.persist(time_series)
end
end
end
```

View File

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2010-2025 Contributors to the openHAB project
*
* 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
*
* 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
*
* 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
*
* 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
*
* 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
*
* 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
*
* 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
*
* 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() {
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() {
PortDefinition pd = PortDefinition.values()[randomizer.nextInt(PortDefinition.AS_SET.size())];
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 targetValue
@ -165,7 +183,9 @@ public class Ipx800DeviceConnector extends Thread {
}
/**
* Resets the counter value to 0
*
* Resets the
* counter value to 0**
*
* @param targetCounter
*/

View File

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2010-2025 Contributors to the openHAB project
*
* 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
*
* 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
*
* 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
*
* 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
*
* 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
*
* 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
*
* 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
*
* 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() {
String result = channelConfiguration.getName();
if (result.isBlank()) {
if (result != null && result.isBlank()) {
result = null;
}

View File

@ -166,6 +166,54 @@ public class SwitchTests extends AbstractComponentTests {
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
protected Set<String> getConfigTopics() {
return Set.of(CONFIG_TOPIC);

View File

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

View File

@ -55,6 +55,6 @@ public class AircareApi extends RestManager {
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();
T response = apiBridge.executeUri(uri, method, clazz, payload, contentType, 3);
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;
}
private static UriBuilder appendParams(UriBuilder builder, @Nullable Object... params) {
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) {
Object param1 = params[i];
@ -82,7 +82,7 @@ public abstract class RestManager {
builder.queryParam(query, param2);
}
} else {
throw new IllegalArgumentException("appendParams : even parameters must be Strings");
throw new IllegalArgumentException("appendParams: even parameters must be Strings");
}
}
return builder;

View File

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

View File

@ -77,7 +77,7 @@ public class WeatherApi extends RestManager {
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;
}
}
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 {

View File

@ -248,8 +248,8 @@ public class NetatmoConstants {
}
// Radio signal quality thresholds
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[] 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
// Thermostat definitions
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
*/
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
*/
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);
handler.expireData();
} 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();
} catch (NetatmoException e) {
logger.warn("Error handling command '{}' : {}", command, e.getMessage());
logger.warn("Error handling command '{}': {}", command, e.getMessage());
} catch (IllegalArgumentException e) {
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) {
logger.warn("Error retrieving last events for home '{}' : {}", securityId, e.getMessage());
logger.warn("Error retrieving last events for home '{}': {}", securityId, e.getMessage());
}
return result;
}
@ -182,7 +182,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
try {
return api.getDeviceEvents(securityId, moduleId, deviceType);
} 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;
}
}).orElse(List.of()));
@ -193,7 +193,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
try {
return api.getPersonEvents(securityId, personId);
} 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;
}
}).orElse(List.of()));
@ -205,7 +205,7 @@ class SecurityCapability extends RestCapability<SecurityApi> {
api.setPersonAwayStatus(securityId, personId, away);
handler.expireData();
} 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);
handler.expireData();
} 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);
handler.expireData();
} 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,
moduleType.isABridge() ? thingTypeBuilder.buildBridge() : thingTypeBuilder.build(), locale);
} 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;

View File

@ -93,7 +93,7 @@ public class GrantServlet extends NetatmoServlet {
resp.getWriter().append(replaceKeysFromMap(accountTemplate, replaceMap));
resp.getWriter().close();
} 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());
hookSet = securityApi.addwebhook(uri);
} 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) {
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();
hookSet = false;
} catch (NetatmoException e) {
logger.warn("Error releasing webhook : {}", e.getMessage());
logger.warn("Error releasing webhook: {}", e.getMessage());
}
}
super.dispose();
@ -99,12 +99,12 @@ public class WebhookServlet extends NetatmoServlet {
private void processEvent(String data) throws IOException {
if (!data.isEmpty()) {
logger.debug("Event transmitted from restService : {}", data);
logger.debug("Event transmitted from restService: {}", data);
try {
WebhookEvent event = deserializer.deserialize(WebhookEvent.class, data);
notifyListeners(event);
} 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);
}
public boolean isSet(int alarmBits) {
return isSet(BigInteger.valueOf(alarmBits));
}
public String getChannelUID() {
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_ENERGY_COST_EVENT = "energy_cost_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_SWITCH_PRESS_EVENT = "switch_press_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 TemperatureFormat(int formatNumber) {
TemperatureFormat(int formatNumber) {
this.formatNumber = formatNumber;
}

View File

@ -67,11 +67,8 @@ public class OmnilinkActions implements ThingActions {
zdt = ZonedDateTime.now(ZoneId.of(zone));
} else {
logger.debug("Time zone provided invalid, using system default!");
if (timeZoneProvider.isPresent()) {
zdt = ZonedDateTime.now(timeZoneProvider.get().getTimeZone());
} else {
zdt = ZonedDateTime.now(ZoneId.systemDefault());
}
zdt = timeZoneProvider.map(zoneProvider -> ZonedDateTime.now(zoneProvider.getTimeZone()))
.orElseGet(() -> ZonedDateTime.now(ZoneId.systemDefault()));
}
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.
*/
private static int bitFilterForArea(AreaProperties areaProperties) {
@ -328,7 +328,7 @@ public class OmnilinkDiscoveryService extends AbstractThingHandlerDiscoveryServi
/**
* Discovers OmniLink areas
*/
private @Nullable List<AreaProperties> discoverAreas() {
private List<AreaProperties> discoverAreas() {
final ThingUID bridgeUID = thingHandler.getThing().getUID();
List<AreaProperties> areas = new LinkedList<>();
@ -356,12 +356,10 @@ public class OmnilinkDiscoveryService extends AbstractThingHandlerDiscoveryServi
final String name = thingName;
systemType.ifPresentOrElse(t -> {
ThingUID thingUID = null;
switch (t) {
case LUMINA:
ThingUID thingUID;
if (t == SystemType.LUMINA) {
thingUID = new ThingUID(THING_TYPE_LUMINA_AREA, bridgeUID, thingID);
break;
default:
} else {
thingUID = new ThingUID(THING_TYPE_OMNI_AREA, bridgeUID, thingID);
}
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)
@ -369,9 +367,7 @@ public class OmnilinkDiscoveryService extends AbstractThingHandlerDiscoveryServi
.withRepresentationProperty(THING_PROPERTIES_NUMBER).withBridge(bridgeUID).withLabel(name)
.build();
thingDiscovered(discoveryResult);
}, () -> {
logger.warn("Unknown System Type");
});
}, () -> logger.warn("Unknown System Type"));
areas.add(areaProperties);
}
@ -397,7 +393,7 @@ public class OmnilinkDiscoveryService extends AbstractThingHandlerDiscoveryServi
int thingType = unitProperties.getUnitType();
String thingName = unitProperties.getName();
String thingID = Integer.toString(unitProperties.getNumber());
ThingUID thingUID = null;
ThingUID thingUID;
Map<String, Object> properties = new HashMap<>();
properties.put(THING_PROPERTIES_NAME, thingName);

View File

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

View File

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

View File

@ -50,7 +50,6 @@ import com.digitaldan.jomnilinkII.OmniUnknownMessageTypeException;
@NonNullByDefault
public class AudioSourceHandler extends AbstractOmnilinkHandler {
private final Logger logger = LoggerFactory.getLogger(AudioSourceHandler.class);
private final int pollDelaySeconds = 5;
private final int thingID = getThingNumber();
private @Nullable ScheduledFuture<?> scheduledPolling = null;
public @Nullable String number;
@ -64,7 +63,7 @@ public class AudioSourceHandler extends AbstractOmnilinkHandler {
final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler();
if (bridgeHandler != null) {
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);
schedulePolling();
} else {
@ -104,6 +103,7 @@ public class AudioSourceHandler extends AbstractOmnilinkHandler {
private synchronized void schedulePolling() {
cancelPolling();
logger.debug("Scheduling polling for Audio Source: {}", thingID);
int pollDelaySeconds = 5;
scheduledPolling = super.scheduler.scheduleWithFixedDelay(this::pollAudioSource, 0, pollDelaySeconds,
TimeUnit.SECONDS);
}
@ -113,8 +113,7 @@ public class AudioSourceHandler extends AbstractOmnilinkHandler {
logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command);
final ScheduledFuture<?> scheduledPolling = this.scheduledPolling;
switch (channelUID.getId()) {
case CHANNEL_AUDIO_SOURCE_POLLING:
if (CHANNEL_AUDIO_SOURCE_POLLING.equals(channelUID.getId())) {
if (command instanceof RefreshType) {
updateState(CHANNEL_AUDIO_SOURCE_POLLING,
OnOffType.from((scheduledPolling != null && !scheduledPolling.isDone())));
@ -123,8 +122,7 @@ public class AudioSourceHandler extends AbstractOmnilinkHandler {
} else {
logger.debug("Invalid command: {}, must be RefreshType or OnOffType", command);
}
break;
default:
} else {
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!");
}
} 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,16 +95,14 @@ public class ButtonHandler extends AbstractOmnilinkHandler {
return;
}
switch (channelUID.getId()) {
case CHANNEL_BUTTON_PRESS:
if (CHANNEL_BUTTON_PRESS.equals(channelUID.getId())) {
if (command instanceof OnOffType) {
sendOmnilinkCommand(CommandMessage.CMD_BUTTON, 0, thingID);
updateChannels();
} else {
logger.debug("Invalid command: {}, must be OnOffType", command);
}
break;
default:
} else {
logger.warn("Unknown channel for Button thing: {}", channelUID);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -95,7 +95,6 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
private @Nullable Connection omniConnection = null;
private @Nullable ScheduledFuture<?> connectJob;
private @Nullable ScheduledFuture<?> eventPollingJob;
private final int autoReconnectPeriod = 60;
private Optional<AudioPlayer> audioPlayer = Optional.empty();
private Optional<SystemType> systemType = Optional.empty();
private final Gson gson = new Gson();
@ -240,8 +239,8 @@ 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
* player.
*/
audioPlayer = Objects.requireNonNull(reqSystemFeatures().getFeatures().stream()
.map(featureCode -> AudioPlayer.getAudioPlayerForFeatureCode(featureCode))
audioPlayer = Objects.requireNonNull(
reqSystemFeatures().getFeatures().stream().map(AudioPlayer::getAudioPlayerForFeatureCode)
.filter(Optional::isPresent).findFirst().orElse(Optional.empty()));
systemType = SystemType.getType(reqSystemInformation().getModel());
@ -288,53 +287,54 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
if (objectStatus != null) {
Status[] statuses = objectStatus.getStatuses();
for (Status status : statuses) {
if (status instanceof ExtendedUnitStatus unitStatus) {
switch (status) {
case ExtendedUnitStatus unitStatus -> {
int unitNumber = unitStatus.getNumber();
logger.debug("Received status update for Unit: {}, status: {}", unitNumber, unitStatus);
Optional<Thing> theThing = getUnitThing(unitNumber);
theThing.map(Thing::getHandler)
.ifPresent(theHandler -> ((UnitHandler) theHandler).handleStatus(unitStatus));
} else if (status instanceof ExtendedZoneStatus zoneStatus) {
}
case 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) {
}
case 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)
.ifPresent(theHandler -> ((AbstractAreaHandler) theHandler).handleStatus(areaStatus));
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));
});
} else if (status instanceof ExtendedAccessControlReaderLockStatus lockStatus) {
}
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));
} else if (status instanceof ExtendedThermostatStatus thermostatStatus) {
}
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));
} else if (status instanceof ExtendedAudioZoneStatus audioZoneStatus) {
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,
@ -342,15 +342,16 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
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) {
}
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);
logger.debug("Received status update for Temperature Sensor: {}, status: {}",
auxSensorNumber, auxSensorStatus);
tempThing.map(Thing::getHandler).ifPresent(
theHandler -> ((TempSensorHandler) theHandler).handleStatus(auxSensorStatus));
}
@ -360,7 +361,8 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
humidityThing.map(Thing::getHandler).ifPresent(
theHandler -> ((HumiditySensorHandler) theHandler).handleStatus(auxSensorStatus));
}
} else {
}
case null, default ->
logger.debug("Received Object Status Notification that was not processed: {}", objectStatus);
}
}
@ -476,12 +478,9 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
SystemStatus status = getOmniConnection().reqSystemStatus();
logger.debug("Received system status: {}", status);
// Update controller's reported time
String dateString = new StringBuilder().append(2000 + status.getYear()).append("-")
.append(String.format("%02d", status.getMonth())).append("-")
.append(String.format("%02d", status.getDay())).append("T")
.append(String.format("%02d", status.getHour())).append(":")
.append(String.format("%02d", status.getMinute())).append(":")
.append(String.format("%02d", status.getSecond())).toString();
String dateString = (2000 + status.getYear()) + "-" + String.format("%02d", status.getMonth()) + "-"
+ String.format("%02d", status.getDay()) + "T" + String.format("%02d", status.getHour()) + ":"
+ String.format("%02d", status.getMinute()) + ":" + String.format("%02d", status.getSecond());
updateState(CHANNEL_SYSTEM_DATE, new DateTimeType(dateString));
}
@ -578,10 +577,8 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
SystemInformation systemInformation = reqSystemInformation();
Map<String, String> properties = editProperties();
properties.put(Thing.PROPERTY_MODEL_ID, Integer.toString(systemInformation.getModel()));
properties.put(Thing.PROPERTY_FIRMWARE_VERSION,
Integer.toString(systemInformation.getMajor()) + "."
+ Integer.toString(systemInformation.getMinor()) + "."
+ Integer.toString(systemInformation.getRevision()));
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, systemInformation.getMajor() + "."
+ systemInformation.getMinor() + "." + systemInformation.getRevision());
properties.put(THING_PROPERTIES_PHONE_NUMBER, systemInformation.getPhone());
updateProperties(properties);
} catch (OmniInvalidResponseException | OmniUnknownMessageTypeException | BridgeOfflineException e) {
@ -597,8 +594,7 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
private void scheduleReconnectJob() {
ScheduledFuture<?> currentReconnectJob = connectJob;
if (currentReconnectJob == null || currentReconnectJob.isDone()) {
connectJob = super.scheduler.scheduleWithFixedDelay(this::makeOmnilinkConnection, 0, autoReconnectPeriod,
TimeUnit.SECONDS);
connectJob = super.scheduler.scheduleWithFixedDelay(this::makeOmnilinkConnection, 0, 60, TimeUnit.SECONDS);
}
}
@ -647,13 +643,13 @@ public class OmnilinkBridgeHandler extends BaseBridgeHandler implements Notifica
logger.debug("Processing event log message number: {}", logData.getEventNumber());
eventLogNumber = logData.getEventNumber();
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));
}
} while (message.getMessageType() != Message.MESG_TYPE_END_OF_DATA);
} 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) {
logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command);
final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler();
Optional<TemperatureFormat> temperatureFormat = Optional.empty();
Optional<TemperatureFormat> temperatureFormat;
if (command instanceof RefreshType) {
retrieveStatus().ifPresentOrElse(this::updateChannels, () -> updateStatus(ThingStatus.OFFLINE,
@ -118,7 +118,7 @@ public class TempSensorHandler extends AbstractOmnilinkStatusHandler<ExtendedAux
if (bridgeHandler != null) {
temperatureFormat = bridgeHandler.getTemperatureFormat();
if (temperatureFormat.isEmpty()) {
logger.warn("Receieved null temperature format!");
logger.warn("Received null temperature format!");
return;
}
} else {
@ -158,7 +158,7 @@ public class TempSensorHandler extends AbstractOmnilinkStatusHandler<ExtendedAux
temperatureFormat.get().omniToFormat(status.getHeatSetpoint()),
temperatureFormat.get().getFormatNumber() == 1 ? ImperialUnits.FAHRENHEIT : SIUnits.CELSIUS));
} 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 {
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 modeValue;
private ThermostatStatus(int bit, int modeValue) {
ThermostatStatus(int bit, int modeValue) {
this.bit = bit;
this.modeValue = modeValue;
}
@ -122,7 +122,7 @@ public class ThermostatHandler extends AbstractOmnilinkStatusHandler<ExtendedThe
public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command);
final OmnilinkBridgeHandler bridgeHandler = getOmnilinkBridgeHandler();
Optional<TemperatureFormat> temperatureFormat = Optional.empty();
Optional<TemperatureFormat> temperatureFormat;
if (command instanceof RefreshType) {
retrieveStatus().ifPresentOrElse(this::updateChannels, () -> updateStatus(ThingStatus.OFFLINE,
@ -137,7 +137,7 @@ public class ThermostatHandler extends AbstractOmnilinkStatusHandler<ExtendedThe
if (bridgeHandler != null) {
temperatureFormat = bridgeHandler.getTemperatureFormat();
if (temperatureFormat.isEmpty()) {
logger.warn("Receieved null temperature format!");
logger.warn("Received null temperature format!");
return;
}
} else {
@ -226,7 +226,7 @@ public class ThermostatHandler extends AbstractOmnilinkStatusHandler<ExtendedThe
temperatureFormat.get().omniToFormat(status.getHeatSetpoint()),
temperatureFormat.get().getFormatNumber() == 1 ? ImperialUnits.FAHRENHEIT : SIUnits.CELSIUS));
} else {
logger.warn("Receieved null temperature format, could not update Thermostat channels!");
logger.warn("Received null temperature format, could not update Thermostat channels!");
}
} else {
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) {
logger.debug("updateChannels called for Unit status: {}", status);
int unitStatus = status.getStatus();
int level = 0;
int level = Status.UNIT_OFF;
if (unitStatus == Status.UNIT_OFF) {
level = 0;
} else if (unitStatus == Status.UNIT_ON) {
if (unitStatus == Status.UNIT_ON) {
level = 100;
} else if ((unitStatus >= Status.UNIT_SCENE_A) && (unitStatus <= Status.UNIT_SCENE_L)) {
level = 100;
@ -206,7 +204,7 @@ public class UnitHandler extends AbstractOmnilinkStatusHandler<ExtendedUnitStatu
/**
* 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) {
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();
if (areas != null) {
for (AreaProperties areaProperties : areas) {
int areaFilter = super.bitFilterForArea(areaProperties);
int areaFilter = bitFilterForArea(areaProperties);
ObjectPropertyRequest<ZoneProperties> objectPropertyRequest = ObjectPropertyRequest
.builder(bridgeHandler, ObjectPropertyRequests.ZONE, getThingNumber(), 0).selectNamed()
@ -115,16 +115,11 @@ public class ZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedZoneStatu
return;
}
switch (channelUID.getId()) {
case CHANNEL_ZONE_BYPASS:
mode = CommandMessage.CMD_SECURITY_BYPASS_ZONE;
break;
case CHANNEL_ZONE_RESTORE:
mode = CommandMessage.CMD_SECURITY_RESTORE_ZONE;
break;
default:
mode = -1;
}
mode = switch (channelUID.getId()) {
case CHANNEL_ZONE_BYPASS -> CommandMessage.CMD_SECURITY_BYPASS_ZONE;
case CHANNEL_ZONE_RESTORE -> CommandMessage.CMD_SECURITY_RESTORE_ZONE;
default -> -1;
};
logger.debug("mode {} on zone {} with code {}", mode, thingID, command.toFullString());
char[] code = command.toFullString().toCharArray();
if (code.length != 4) {
@ -174,7 +169,7 @@ public class ZoneHandler extends AbstractOmnilinkStatusHandler<ExtendedZoneStatu
@Override
protected void updateChannels(ExtendedZoneStatus zoneStatus) {
// 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
int latched = ((zoneStatus.getStatus() >> 2) & 0x03);
// 0 Disarmed, 1 Armed, 2 Bypass user, 3 Bypass system

View File

@ -49,11 +49,9 @@ public class DimmableUnitHandler extends UnitHandler {
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("handleCommand called for channel: {}, command: {}", channelUID, command);
switch (channelUID.getId()) {
case CHANNEL_UNIT_LEVEL:
if (CHANNEL_UNIT_LEVEL.equals(channelUID.getId())) {
handleUnitLevel(channelUID, command);
break;
default:
} else {
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;
break;
default:
logger.warn("Unexpected UPB Room state: {}", Integer.toString(cmdValue));
logger.warn("Unexpected UPB Room state: {}", cmdValue);
return;
}

View File

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