diff --git a/org.openhab.binding.greeair/ESH-INF/binding/binding.xml b/org.openhab.binding.greeair/ESH-INF/binding/binding.xml index 12b06df..626f55f 100644 --- a/org.openhab.binding.greeair/ESH-INF/binding/binding.xml +++ b/org.openhab.binding.greeair/ESH-INF/binding/binding.xml @@ -1,11 +1,10 @@ - + GreeAir Binding - A binding for Gree Air Conditioners. - John Cunha + This is the binding for GreeAir. + JLLCunha diff --git a/org.openhab.binding.greeair/ESH-INF/i18n/greeair_xx_XX.properties b/org.openhab.binding.greeair/ESH-INF/i18n/greeair_xx_XX.properties index c71e5db..c364932 100644 --- a/org.openhab.binding.greeair/ESH-INF/i18n/greeair_xx_XX.properties +++ b/org.openhab.binding.greeair/ESH-INF/i18n/greeair_xx_XX.properties @@ -10,4 +10,4 @@ thing-type.greeair.sample.description = # channel types channel-type.greeair.sample-channel.label = -channel-type.greeair.sample-channel.description = \ No newline at end of file +channel-type.greeair.sample-channel.description = diff --git a/org.openhab.binding.greeair/ESH-INF/thing/thing-types.xml b/org.openhab.binding.greeair/ESH-INF/thing/thing-types.xml index f6f7336..5c36108 100644 --- a/org.openhab.binding.greeair/ESH-INF/thing/thing-types.xml +++ b/org.openhab.binding.greeair/ESH-INF/thing/thing-types.xml @@ -1,97 +1,32 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0" + xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd"> - - - - Gree AirConditioner + + + + Sample thing for GreeAir Binding - - - - - - - - - - + + - - - Enter the IP address of the Gree Airconditioner - network-address - - - Refresh time interval in seconds. - 1 + + + This is a sample text configuration parameter. - - - Enter the network Broadcast IP for your network - network-address - 255.255.255.255 + + - - - Switch - - Power channel for GreeAir Binding - - - Number - - Mode Channel for Gree Air Binding. Mode: Auto: 0, Cool: 1, Dry: 2, Fan: 3, Heat: 4 - - - Switch - - Turbo Fan Channel for Gree Air Ninding - - - Switch - - Light Channel for Gree Air Binding - - - Number - - Temperature Channel for Gree Air Binding - - - Number - Vertical Swing Channel for Gree Air Binding. Swing: Full: 1, Up: 2, MidUp: 3, Mid: 4, Mid Down: 5, Down : 6 - - - Number - - Fan Speed Channel for Gree Air binding. Auto:0, Low:1, Midlow:2, Mid:3, MidHigh:4, High:5 - - - Switch - - Air Channel for Gree Air Binding - - - Switch - - Dry Channel for Gree Air Binding - - - Switch - - Health Channel for Gree Air Binding - - - Switch - - Pwer Saving Channel for Gree Air Binding + + + greeairItem + + Sample channel for GreeAir Binding diff --git a/org.openhab.binding.greeair/META-INF/MANIFEST.MF b/org.openhab.binding.greeair/META-INF/MANIFEST.MF index fb8bc63..c10e93b 100644 --- a/org.openhab.binding.greeair/META-INF/MANIFEST.MF +++ b/org.openhab.binding.greeair/META-INF/MANIFEST.MF @@ -6,16 +6,14 @@ Bundle-Name: GreeAir Binding Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-SymbolicName: org.openhab.binding.greeair;singleton:=true Bundle-Vendor: openHAB -Bundle-Version: 2.2.0.qualifier +Bundle-Version: 2.3.0.qualifier Export-Package: org.openhab.binding.greeair, org.openhab.binding.greeair.handler Import-Package: com.google.gson, com.google.gson.stream, - org.eclipse.jdt.annotation;resolution:=optional, org.eclipse.smarthome.config.core, - org.eclipse.smarthome.config.discovery, org.eclipse.smarthome.core.library.types, org.eclipse.smarthome.core.thing, org.eclipse.smarthome.core.thing.binding, @@ -24,6 +22,5 @@ Import-Package: org.eclipse.smarthome.core.types, org.openhab.binding.greeair, org.openhab.binding.greeair.handler, - org.osgi.service.component.annotations;resolution:=optional, org.slf4j Service-Component: OSGI-INF/*.xml diff --git a/org.openhab.binding.greeair/about.html b/org.openhab.binding.greeair/about.html index 089907b..aab6abc 100644 --- a/org.openhab.binding.greeair/about.html +++ b/org.openhab.binding.greeair/about.html @@ -30,3 +30,4 @@

License

+ diff --git a/org.openhab.binding.greeair/build.properties b/org.openhab.binding.greeair/build.properties index c67911a..395d5db 100644 --- a/org.openhab.binding.greeair/build.properties +++ b/org.openhab.binding.greeair/build.properties @@ -4,4 +4,5 @@ bin.includes=META-INF/,\ .,\ OSGI-INF/,\ ESH-INF/,\ - about.html + about.html + diff --git a/org.openhab.binding.greeair/pom.xml b/org.openhab.binding.greeair/pom.xml index 745595b..d17ad44 100644 --- a/org.openhab.binding.greeair/pom.xml +++ b/org.openhab.binding.greeair/pom.xml @@ -1,19 +1,17 @@ - + - 4.0.0 + 4.0.0 - - org.openhab.binding - pom - 2.2.0-SNAPSHOT - + + pom + org.openhab.binding + 2.3.0-SNAPSHOT + - org.openhab.binding.greeair - 2.2.0-SNAPSHOT + org.openhab.binding.greeair + eclipse-plugin - GreeAir Binding - eclipse-plugin + GreeAir Binding diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/GreeAirBindingConstants.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/GreeAirBindingConstants.java index e2b1004..81ca1cc 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/GreeAirBindingConstants.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/GreeAirBindingConstants.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,7 +8,8 @@ */ package org.openhab.binding.greeair; -import org.eclipse.jdt.annotation.NonNullByDefault; +//import org.eclipse.jdt.annotation.NonNullByDefault; +//import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.smarthome.core.thing.ThingTypeUID; /** @@ -17,7 +18,7 @@ * * @author John Cunha - Initial contribution */ -@NonNullByDefault +// @NonNullByDefault public class GreeAirBindingConstants { private static final String BINDING_ID = "greeair"; diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/handler/GreeAirHandler.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/handler/GreeAirHandler.java index 0986f81..83ec834 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/handler/GreeAirHandler.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/handler/GreeAirHandler.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -19,7 +19,8 @@ import java.util.concurrent.TimeUnit; import org.eclipse.smarthome.core.library.types.DecimalType; -import org.eclipse.smarthome.core.library.types.StringType; +import org.eclipse.smarthome.core.library.types.OnOffType; +//import org.eclipse.smarthome.core.library.types.StringType; import org.eclipse.smarthome.core.thing.Channel; import org.eclipse.smarthome.core.thing.ChannelUID; import org.eclipse.smarthome.core.thing.Thing; @@ -29,6 +30,7 @@ import org.eclipse.smarthome.core.types.Command; import org.eclipse.smarthome.core.types.RefreshType; import org.eclipse.smarthome.core.types.State; +//import org.eclipse.smarthome.core.types.State; import org.openhab.binding.greeair.internal.GreeAirconConfig; import org.openhab.binding.greeair.internal.discovery.GreeDevice; import org.openhab.binding.greeair.internal.discovery.GreeDeviceFinder; @@ -40,6 +42,7 @@ * sent to one of the channels. * * @author John Cunha - Initial contribution + * Mihai Badea - Switch channel improvements (many thanks!) */ // @NonNullByDefault public class GreeAirHandler extends BaseThingHandler { @@ -49,7 +52,7 @@ public class GreeAirHandler extends BaseThingHandler { private GreeAirconConfig config; private Integer refreshTime; private ScheduledFuture refreshTask; - private boolean firstUpdatefinished = false; + // private boolean firstUpdatefinished = false; private long lastRefreshTime = 0; private String ipAddress = null; private String broadcastAddress = null; @@ -77,7 +80,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printStackTrace(); } } else if (channelUID.getId().equals(MODE_CHANNEL)) { try { @@ -85,7 +88,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { thisDevice.SetDeviceMode(clientSocket, val); } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printStackTrace(); } } else if (channelUID.getId().equals(TURBO_CHANNEL)) { try { @@ -99,7 +102,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printStackTrace(); } } else if (channelUID.getId().equals(LIGHT_CHANNEL)) { try { @@ -113,7 +116,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } } else if (channelUID.getId().equals(TEMP_CHANNEL)) { try { @@ -121,7 +124,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { thisDevice.SetDeviceTempSet(clientSocket, val); } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } } else if (channelUID.getId().equals(SWINGV_CHANNEL)) { try { @@ -129,7 +132,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { thisDevice.SetDeviceSwingVertical(clientSocket, val); } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } } else if (channelUID.getId().equals(WINDSPEED_CHANNEL)) { try { @@ -137,7 +140,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { thisDevice.SetDeviceWindspeed(clientSocket, val); } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } } else if (channelUID.getId().equals(AIR_CHANNEL)) { try { @@ -151,7 +154,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } } else if (channelUID.getId().equals(DRY_CHANNEL)) { try { @@ -165,7 +168,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } } else if (channelUID.getId().equals(HEALTH_CHANNEL)) { try { @@ -179,7 +182,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } } else if (channelUID.getId().equals(PWRSAV_CHANNEL)) { try { @@ -193,7 +196,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { } } catch (Exception e) { logger.debug("Greeair failed to update channel {} due to {} ", channelUID.getId(), e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } } } @@ -246,13 +249,13 @@ public void initialize() { } } catch (UnknownHostException e) { logger.debug("Greeair failed to scan for airconditioners due to {} ", e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } catch (IOException e) { logger.debug("Greeair failed to scan for airconditioners due to {} ", e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } catch (Exception e) { logger.debug("Greeair failed to scan for airconditioners due to {} ", e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } updateStatus(ThingStatus.OFFLINE); } @@ -304,7 +307,7 @@ public void run() { } catch (Exception e) { logger.debug("Greeair failed during automatic update of airconditioner values due to {} ", e.getMessage()); - e.printStackTrace(); + // e.printstackTrace(); } } }; @@ -316,7 +319,8 @@ public void run() { private void publishChannelIfLinked(ChannelUID channelUID) { String channelID = channelUID.getId(); boolean statusChanged = false; - if (channelID != null && isLinked(channelID)) { + // if (channelID != null && isLinked(channelID)) { + if (isLinked(channelID)) { State state = null; Integer stateValue = null; switch (channelID) { @@ -326,9 +330,11 @@ private void publishChannelIfLinked(ChannelUID channelUID) { statusChanged = true; stateValue = thisDevice.GetIntStatusVal("Pow"); if (stateValue.intValue() != 1) { - state = new StringType("OFF"); + state = OnOffType.OFF; + // state = new StringType("OFF"); } else { - state = new StringType("ON"); + state = OnOffType.ON; + // state = new StringType("ON"); } } break; @@ -346,9 +352,11 @@ private void publishChannelIfLinked(ChannelUID channelUID) { statusChanged = true; stateValue = thisDevice.GetIntStatusVal("Tur"); if (stateValue.intValue() != 1) { - state = new StringType("OFF"); + state = OnOffType.OFF; + // state = new StringType("OFF"); } else { - state = new StringType("ON"); + state = OnOffType.ON; + // state = new StringType("ON"); } } break; @@ -358,9 +366,11 @@ private void publishChannelIfLinked(ChannelUID channelUID) { statusChanged = true; stateValue = thisDevice.GetIntStatusVal("Lig"); if (stateValue.intValue() != 1) { - state = new StringType("OFF"); + state = OnOffType.OFF; + // state = new StringType("OFF"); } else { - state = new StringType("ON"); + state = OnOffType.ON; + // state = new StringType("ON"); } } break; @@ -394,9 +404,11 @@ private void publishChannelIfLinked(ChannelUID channelUID) { statusChanged = true; stateValue = thisDevice.GetIntStatusVal("Air"); if (stateValue.intValue() != 1) { - state = new StringType("OFF"); + state = OnOffType.OFF; + // state = new StringType("OFF"); } else { - state = new StringType("ON"); + state = OnOffType.ON; + // state = new StringType("ON"); } } break; @@ -406,9 +418,11 @@ private void publishChannelIfLinked(ChannelUID channelUID) { statusChanged = true; stateValue = thisDevice.GetIntStatusVal("Blo"); if (stateValue.intValue() != 1) { - state = new StringType("OFF"); + state = OnOffType.OFF; + // state = new StringType("OFF"); } else { - state = new StringType("ON"); + state = OnOffType.ON; + // state = new StringType("ON"); } } break; @@ -418,9 +432,11 @@ private void publishChannelIfLinked(ChannelUID channelUID) { statusChanged = true; stateValue = thisDevice.GetIntStatusVal("Health"); if (stateValue.intValue() != 1) { - state = new StringType("OFF"); + state = OnOffType.OFF; + // state = new StringType("OFF"); } else { - state = new StringType("ON"); + state = OnOffType.ON; + // state = new StringType("ON"); } } break; @@ -430,9 +446,11 @@ private void publishChannelIfLinked(ChannelUID channelUID) { statusChanged = true; stateValue = thisDevice.GetIntStatusVal("SvSt"); if (stateValue.intValue() != 1) { - state = new StringType("OFF"); + state = OnOffType.OFF; + // state = new StringType("OFF"); } else { - state = new StringType("ON"); + state = OnOffType.ON; + // state = new StringType("ON"); } } break; diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirBindingConstants.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirBindingConstants.java new file mode 100644 index 0000000..b1bcc39 --- /dev/null +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirBindingConstants.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2010-2018 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.greeair.internal; + +//import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.smarthome.core.thing.ThingTypeUID; + +/** + * The {@link GreeAirBindingConstants} class defines common constants, which are + * used across the whole binding. + * + * @author JLLCunha - Initial contribution + */ +// @NonNullByDefault +public class GreeAirBindingConstants { + + private static final String BINDING_ID = "greeair"; + + // List of all Thing Type UIDs + public static final ThingTypeUID THING_TYPE_SAMPLE = new ThingTypeUID(BINDING_ID, "sample"); + + // List of all Channel ids + public static final String CHANNEL_1 = "channel1"; +} diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirConfiguration.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirConfiguration.java new file mode 100644 index 0000000..d2a5564 --- /dev/null +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirConfiguration.java @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2010-2018 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.greeair.internal; + +/** + * The {@link GreeAirConfiguration} class contains fields mapping thing configuration parameters. + * + * @author JLLCunha - Initial contribution + */ +public class GreeAirConfiguration { + + /** + * Sample configuration parameter. Replace with your own. + */ + public String config1; +} diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirHandler.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirHandler.java new file mode 100644 index 0000000..45831db --- /dev/null +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirHandler.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2010-2018 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.greeair.internal; + +import static org.openhab.binding.greeair.internal.GreeAirBindingConstants.CHANNEL_1; + +//import org.eclipse.jdt.annotation.NonNullByDefault; +//import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.smarthome.core.thing.ChannelUID; +import org.eclipse.smarthome.core.thing.Thing; +import org.eclipse.smarthome.core.thing.ThingStatus; +import org.eclipse.smarthome.core.thing.binding.BaseThingHandler; +import org.eclipse.smarthome.core.types.Command; + +/** + * The {@link GreeAirHandler} is responsible for handling commands, which are + * sent to one of the channels. + * + * @author JLLCunha - Initial contribution + */ +// @NonNullByDefault +public class GreeAirHandler extends BaseThingHandler { + + // private final Logger logger = LoggerFactory.getLogger(GreeAirHandler.class); + + // @Nullable + private GreeAirConfiguration config; + + public GreeAirHandler(Thing thing) { + super(thing); + } + + @Override + public void handleCommand(ChannelUID channelUID, Command command) { + if (channelUID.getId().equals(CHANNEL_1)) { + // TODO: handle command + + // Note: if communication with thing fails for some reason, + // indicate that by setting the status with detail information + // updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, + // "Could not control device at IP address x.x.x.x"); + } + } + + @Override + public void initialize() { + config = getConfigAs(GreeAirConfiguration.class); + + // TODO: Initialize the thing. If done set status to ONLINE to indicate proper working. + // Long running initialization should be done asynchronously in background. + updateStatus(ThingStatus.ONLINE); + + // Note: When initialization can NOT be done set the status with more details for further + // analysis. See also class ThingStatusDetail for all available status details. + // Add a description to give user information to understand why thing does not work + // as expected. E.g. + // updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, + // "Can not access device as username and/or password are invalid"); + } +} diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirHandlerFactory.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirHandlerFactory.java index 20dcd7b..417793e 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirHandlerFactory.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirHandlerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -13,8 +13,8 @@ import java.util.Collections; import java.util.Set; -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; +//import org.eclipse.jdt.annotation.NonNullByDefault; +//import org.eclipse.jdt.annotation.Nullable; import org.eclipse.smarthome.core.thing.Thing; import org.eclipse.smarthome.core.thing.ThingTypeUID; import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory; @@ -30,7 +30,7 @@ * @author John Cunha - Initial contribution */ @Component(service = ThingHandlerFactory.class, immediate = true, configurationPid = "binding.greeair") -@NonNullByDefault +// @NonNullByDefault public class GreeAirHandlerFactory extends BaseThingHandlerFactory { @SuppressWarnings("null") @@ -42,7 +42,8 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { } @Override - protected @Nullable ThingHandler createHandler(Thing thing) { + // protected @Nullable ThingHandler createHandler(Thing thing) { + protected ThingHandler createHandler(Thing thing) { ThingTypeUID thingTypeUID = thing.getThingTypeUID(); if (thingTypeUID.equals(GREE_THING_TYPE)) { diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirconConfig.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirconConfig.java index 48a49f7..de4a8b0 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirconConfig.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/GreeAirconConfig.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/discovery/GreeDevice.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/discovery/GreeDevice.java index b46511a..c5c7de7 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/discovery/GreeDevice.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/discovery/GreeDevice.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/discovery/GreeDeviceFinder.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/discovery/GreeDeviceFinder.java index 2fe5844..22094f6 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/discovery/GreeDeviceFinder.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/discovery/GreeDeviceFinder.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/encryption/CryptoUtil.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/encryption/CryptoUtil.java index d02f0c0..650de87 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/encryption/CryptoUtil.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/encryption/CryptoUtil.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -14,14 +14,19 @@ import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; +import org.openhab.binding.greeair.handler.GreeAirHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * The CryptoUtil class provides functionality for encrypting and decrypting * messages sent to and from the Air Conditioner - * + * * @author John Cunha - Initial contribution */ public class CryptoUtil { + static private final Logger logger = LoggerFactory.getLogger(GreeAirHandler.class); static String AES_General_Key = "a3K8Bx%2r8Y7#xDh"; public static String GetAESGeneralKey() { @@ -48,7 +53,7 @@ public static String decryptPack(byte[] keyarray, String message) throws Excepti descrytpedMessage = new String(bytePlainText); } catch (Exception ex) { - System.out.println(ex); + logger.debug("Greeair failed to decrypt the recieved data due to {} ", ex.getMessage()); } return descrytpedMessage; } @@ -66,7 +71,7 @@ public static String encryptPack(byte[] keyarray, String message) throws Excepti encrytpedMessage = new String(newencoder.encode(bytePlainText)); encrytpedMessage = encrytpedMessage.substring(0, encrytpedMessage.length()); } catch (Exception ex) { - System.out.println(ex); + logger.debug("Greeair failed to encrypt the data to send to device due to {} ", ex.getMessage()); } return encrytpedMessage; } diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindRequest4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindRequest4Gson.java index e7afee3..d0e5f44 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindRequest4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindRequest4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindRequestPack4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindRequestPack4Gson.java index 9a7eced..6d734d2 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindRequestPack4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindRequestPack4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -12,7 +12,7 @@ * * The GreeBindRequestPack4Gson class is used by Gson to hold values to be send to * the Air Conditioner during Binding - * + * * @author John Cunha - Initial contribution */ public class GreeBindRequestPack4Gson { diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindResponse4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindResponse4Gson.java index a883da3..f74582f 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindResponse4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindResponse4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindResponsePack4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindResponsePack4Gson.java index 2cb8a3b..ff58b5b 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindResponsePack4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeBindResponsePack4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecCommand4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecCommand4Gson.java index 7b0b0d4..2731b31 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecCommand4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecCommand4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecResponse4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecResponse4Gson.java index b0128d3..f7da8bf 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecResponse4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecResponse4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecResponsePack4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecResponsePack4Gson.java index b667918..244fa0b 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecResponsePack4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecResponsePack4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecuteCommandPack4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecuteCommandPack4Gson.java index d65fbc1..f60eadb 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecuteCommandPack4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeExecuteCommandPack4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeReqStatus4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeReqStatus4Gson.java index 470f444..0f8e490 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeReqStatus4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeReqStatus4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeReqStatusPack4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeReqStatusPack4Gson.java index 68fbb9f..bc45b5b 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeReqStatusPack4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeReqStatusPack4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanReponsePack4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanReponsePack4Gson.java index 81901cd..1d1ddba 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanReponsePack4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanReponsePack4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanRequest4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanRequest4Gson.java index 267af6a..dc1d89d 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanRequest4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanRequest4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanResponse4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanResponse4Gson.java index 012ea57..eefedd3 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanResponse4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeScanResponse4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeStatusResponse4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeStatusResponse4Gson.java index 92e3061..b6f8ced 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeStatusResponse4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeStatusResponse4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff --git a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeStatusResponsePack4Gson.java b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeStatusResponsePack4Gson.java index 0dd6989..933d44f 100644 --- a/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeStatusResponsePack4Gson.java +++ b/org.openhab.binding.greeair/src/main/java/org/openhab/binding/greeair/internal/gson/GreeStatusResponsePack4Gson.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010-2017 by the respective copyright holders. + * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0