]> git.basschouten.com Git - openhab-addons.git/blob
9010e2a0f5ef9af96504dfcf13c25ff9a3e6cb08
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.konnected.internal.handler;
14
15 import static org.openhab.binding.konnected.internal.KonnectedBindingConstants.*;
16
17 import java.math.BigDecimal;
18 import java.util.Map;
19 import java.util.Map.Entry;
20 import java.util.concurrent.TimeUnit;
21
22 import org.openhab.binding.konnected.internal.KonnectedConfiguration;
23 import org.openhab.binding.konnected.internal.KonnectedHTTPUtils;
24 import org.openhab.binding.konnected.internal.KonnectedHttpRetryExceeded;
25 import org.openhab.binding.konnected.internal.gson.KonnectedModuleGson;
26 import org.openhab.binding.konnected.internal.gson.KonnectedModulePayload;
27 import org.openhab.core.config.core.Configuration;
28 import org.openhab.core.config.core.validation.ConfigValidationException;
29 import org.openhab.core.library.types.OnOffType;
30 import org.openhab.core.library.types.QuantityType;
31 import org.openhab.core.library.unit.SIUnits;
32 import org.openhab.core.library.unit.Units;
33 import org.openhab.core.thing.Channel;
34 import org.openhab.core.thing.ChannelUID;
35 import org.openhab.core.thing.Thing;
36 import org.openhab.core.thing.ThingStatus;
37 import org.openhab.core.thing.ThingStatusDetail;
38 import org.openhab.core.thing.binding.BaseThingHandler;
39 import org.openhab.core.types.Command;
40 import org.openhab.core.types.RefreshType;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43
44 import com.google.gson.Gson;
45 import com.google.gson.GsonBuilder;
46
47 /**
48  * The {@link KonnectedHandler} is responsible for handling commands, which are
49  * sent to one of the channels.
50  *
51  * @author Zachary Christiansen - Initial contribution
52  */
53 public class KonnectedHandler extends BaseThingHandler {
54     private final Logger logger = LoggerFactory.getLogger(KonnectedHandler.class);
55     private KonnectedConfiguration config;
56     private final KonnectedHTTPUtils http = new KonnectedHTTPUtils(30);
57     private String callbackUrl;
58     private String baseUrl;
59     private final Gson gson = new GsonBuilder().create();
60     private int retryCount;
61     private final String thingID;
62     public String authToken;
63
64     /**
65      * This is the constructor of the Konnected Handler.
66      *
67      * @param thing the instance of the Konnected thing
68      * @param webHookServlet the instance of the callback servlet that is running for communication with the Konnected
69      *            Module
70      * @param hostAddress the webaddress of the openHAB server instance obtained by the runtime
71      * @param port the port on which the openHAB instance is running that was obtained by the runtime.
72      */
73     public KonnectedHandler(Thing thing, String callbackUrl) {
74         super(thing);
75         this.callbackUrl = callbackUrl;
76         logger.debug("The auto discovered callback URL is: {}", this.callbackUrl);
77         retryCount = 2;
78         thingID = getThing().getThingTypeUID().getId();
79         authToken = getThing().getUID().getAsString();
80     }
81
82     @Override
83     public void handleCommand(ChannelUID channelUID, Command command) {
84         // get the zone number in integer form
85         Channel channel = this.getThing().getChannel(channelUID.getId());
86         String channelType = channel.getChannelTypeUID().getAsString();
87         String zone = (String) channel.getConfiguration().get(CHANNEL_ZONE);
88         logger.debug("The channelUID is: {} and the zone is : {}", channelUID.getAsString(), zone);
89         // if the command is OnOfftype
90         if (command instanceof OnOffType) {
91             if (channelType.contains(CHANNEL_SWITCH)) {
92                 logger.debug("A command was sent to a sensor type so we are ignoring the command");
93             } else {
94                 int sendCommand = (OnOffType.OFF.compareTo((OnOffType) command));
95                 logger.debug("The command being sent to zone {} for channel:{}  is {}", zone, channelUID.getAsString(),
96                         sendCommand);
97                 sendActuatorCommand(Integer.toString(sendCommand), zone, channelUID);
98             }
99         } else if (command instanceof RefreshType) {
100             // check to see if handler has been initialized before attempting to get state of pin, else wait one minute
101             if (this.isInitialized()) {
102                 getSwitchState(zone, channelUID);
103             } else {
104                 scheduler.schedule(() -> {
105                     handleCommand(channelUID, command);
106                 }, 1, TimeUnit.MINUTES);
107             }
108         }
109     }
110
111     /**
112      * Process a {@link WebHookEvent} that has been received by the Servlet from a Konnected module with respect to a
113      * sensor event or status update request
114      *
115      * @param event the {@link KonnectedModuleGson} event that contains the state and pin information to be processed
116      */
117     public void handleWebHookEvent(KonnectedModuleGson event) {
118         // if we receive a command update the thing status to being online
119         updateStatus(ThingStatus.ONLINE);
120         // get the zone number based off of the index location of the pin value
121         // String sentZone = Integer.toString(Arrays.asList(PIN_TO_ZONE).indexOf(event.getPin()));
122         String zone = event.getZone(thingID);
123         // check that the zone number is in one of the channelUID definitions
124         logger.debug("Looping Through all channels on thing: {} to find a match for {}", thing.getUID().getAsString(),
125                 zone);
126         getThing().getChannels().forEach(channel -> {
127             ChannelUID channelId = channel.getUID();
128             String zoneNumber = (String) channel.getConfiguration().get(CHANNEL_ZONE);
129             // if the string zone that was sent equals the last digit of the channelId found process it as the
130             // channelId else do nothing
131             if (zone.equalsIgnoreCase(zoneNumber)) {
132                 logger.debug(
133                         "The configrued zone of channelID: {}  was a match for the zone sent by the alarm panel: {} on thing: {}",
134                         channelId, zone, this.getThing().getUID().getId());
135                 String channelType = channel.getChannelTypeUID().getAsString();
136                 logger.debug("The channeltypeID is: {}", channelType);
137                 // check if the itemType has been defined for the zone received
138                 // check the itemType of the Zone, if Contact, send the State if Temp send Temp, etc.
139                 if (channelType.contains(CHANNEL_SWITCH) || channelType.contains(CHANNEL_ACTUATOR)) {
140                     OnOffType onOffType = event.getState().equalsIgnoreCase(getOnState(channel)) ? OnOffType.ON
141                             : OnOffType.OFF;
142                     updateState(channelId, onOffType);
143                 } else if (channelType.contains(CHANNEL_HUMIDITY)) {
144                     // if the state is of type number then this means it is the humidity channel of the dht22
145                     updateState(channelId, new QuantityType<>(Double.parseDouble(event.getHumi()), Units.PERCENT));
146                 } else if (channelType.contains(CHANNEL_TEMPERATURE)) {
147                     Configuration configuration = channel.getConfiguration();
148                     if (((Boolean) configuration.get(CHANNEL_TEMPERATURE_TYPE))) {
149                         updateState(channelId,
150                                 new QuantityType<>(Double.parseDouble(event.getTemp()), SIUnits.CELSIUS));
151                     } else {
152                         // need to check to make sure right dsb1820 address
153                         logger.debug("The address of the DSB1820 sensor received from modeule {} is: {}",
154                                 this.thing.getUID(), event.getAddr());
155                         if (event.getAddr()
156                                 .equalsIgnoreCase((String) (configuration.get(CHANNEL_TEMPERATURE_DS18B20_ADDRESS)))) {
157                             updateState(channelId,
158                                     new QuantityType<>(Double.parseDouble(event.getTemp()), SIUnits.CELSIUS));
159                         } else {
160                             logger.debug("The address of {} does not match {} not updating this channel",
161                                     event.getAddr(), (configuration.get(CHANNEL_TEMPERATURE_DS18B20_ADDRESS)));
162                         }
163                     }
164                 }
165             } else {
166                 logger.trace(
167                         "The zone number sent by the alarm panel: {} was not a match the configured zone for channelId: {} for thing {}",
168                         zone, channelId, getThing().getThingTypeUID().toString());
169             }
170         });
171     }
172
173     private void checkConfiguration() throws ConfigValidationException {
174         logger.debug("Checking configuration on thing {}", this.getThing().getUID().getAsString());
175         Configuration testConfig = this.getConfig();
176         String testRetryCount = testConfig.get(RETRY_COUNT).toString();
177         String testRequestTimeout = testConfig.get(REQUEST_TIMEOUT).toString();
178         baseUrl = testConfig.get(BASE_URL).toString();
179         String configuredCallbackUrl = (String) getThing().getConfiguration().get(CALLBACK_URL);
180         if (configuredCallbackUrl != null) {
181             callbackUrl = configuredCallbackUrl;
182         } else {
183             getThing().getConfiguration().put(CALLBACK_URL, callbackUrl);
184         }
185         logger.debug("The RequestTimeout Parameter is Configured as: {}", testRequestTimeout);
186         logger.debug("The Retry Count Parameter is Configured as: {}", testRetryCount);
187         logger.debug("Base URL is Configured as: {}", baseUrl);
188         logger.debug("The callback URL is: {}", callbackUrl);
189         try {
190             this.retryCount = Integer.parseInt(testRetryCount);
191         } catch (NumberFormatException e) {
192             logger.debug(
193                     "Please check your configuration of the Retry Count as it is not an Integer. It is configured as: {}, will contintue to configure the binding with the default of 2",
194                     testRetryCount);
195             this.retryCount = 2;
196         }
197         try {
198             this.http.setRequestTimeout(Integer.parseInt(testRequestTimeout));
199         } catch (NumberFormatException e) {
200             logger.debug(
201                     "Please check your configuration of the Request Timeout as it is not an Integer. It is configured as: {}, will contintue to configure the binding with the default of 30",
202                     testRequestTimeout);
203         }
204
205         if ((callbackUrl == null)) {
206             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Unable to obtain callback URL");
207         }
208
209         else {
210             this.config = getConfigAs(KonnectedConfiguration.class);
211         }
212     }
213
214     @Override
215     public void handleConfigurationUpdate(Map<String, Object> configurationParameters)
216             throws ConfigValidationException {
217         this.validateConfigurationParameters(configurationParameters);
218         for (Entry<String, Object> configurationParameter : configurationParameters.entrySet()) {
219             Object value = configurationParameter.getValue();
220             logger.debug("Controller Configuration update {} to {}", configurationParameter.getKey(), value);
221
222             if (value == null) {
223                 continue;
224             }
225             // this is a nonstandard implementation to to address the configuration of the konnected alarm panel (as
226             // opposed to the handler) until
227             // https://github.com/eclipse/smarthome/issues/3484 has been implemented in the framework
228             String[] cfg = configurationParameter.getKey().split("_");
229             if ("controller".equals(cfg[0])) {
230                 if (cfg[1].equals("softreset") && value instanceof Boolean && (Boolean) value) {
231                     scheduler.execute(() -> {
232                         try {
233                             http.doGet(baseUrl + "/settings?restart=true", null, retryCount);
234                         } catch (KonnectedHttpRetryExceeded e) {
235                             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
236                         }
237                     });
238                     value = false;
239                 } else if (cfg[1].equals("removewifi") && value instanceof Boolean && (Boolean) value) {
240                     scheduler.execute(() -> {
241                         try {
242                             http.doGet(baseUrl + "/settings?restore=true", null, retryCount);
243                         } catch (KonnectedHttpRetryExceeded e) {
244                             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
245                         }
246                     });
247                     value = false;
248                 } else if (cfg[1].equals("sendConfig") && value instanceof Boolean && (Boolean) value) {
249                     scheduler.execute(() -> {
250                         try {
251                             String response = updateKonnectedModule();
252                             logger.trace("The response from the konnected module with thingID {} was {}",
253                                     getThing().getUID().toString(), response);
254                             if (response == null) {
255                                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
256                                         "Unable to communicate with Konnected Module.");
257                             } else {
258                                 updateStatus(ThingStatus.ONLINE);
259                             }
260                         } catch (KonnectedHttpRetryExceeded e) {
261                             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
262                         }
263                     });
264                     value = false;
265                 }
266             }
267         }
268
269         super.handleConfigurationUpdate(configurationParameters);
270         try
271
272         {
273             String response = updateKonnectedModule();
274             logger.trace("The response from the konnected module with thingID {} was {}",
275                     getThing().getUID().toString(), response);
276             if (response == null) {
277                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
278                         "Unable to communicate with Konnected Module confirm settings.");
279             } else {
280                 updateStatus(ThingStatus.ONLINE);
281             }
282         } catch (KonnectedHttpRetryExceeded e) {
283             logger.trace("The number of retries was exceeeded during the HandleConfigurationUpdate(): {}",
284                     e.getMessage());
285             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
286         }
287     }
288
289     @Override
290     public void initialize() {
291         updateStatus(ThingStatus.UNKNOWN);
292         try {
293             checkConfiguration();
294         } catch (ConfigValidationException e) {
295             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
296         }
297         scheduler.execute(() -> {
298             try {
299                 String response = updateKonnectedModule();
300                 if (response == null) {
301                     updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
302                             "Unable to communicate with Konnected Module confirm settings or readd thing.");
303                 } else {
304                     updateStatus(ThingStatus.ONLINE);
305                 }
306             } catch (KonnectedHttpRetryExceeded e) {
307                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
308             }
309         });
310     }
311
312     @Override
313     public void dispose() {
314         logger.debug("Running dispose()");
315         super.dispose();
316     }
317
318     /**
319      * This method constructs the payload that will be sent
320      * to the Konnected module via the put request
321      * it adds the appropriate sensors and actuators to the {@link KonnectedModulePayload}
322      * as well as the location of the callback {@link KonnectedJTTPServlet}
323      * and auth_token which can be used for validation
324      *
325      * @return a json settings payload which can be sent to the Konnected Module based on the Thing
326      */
327     private String constructSettingsPayload() {
328         logger.debug("The Auth_Token is: {}", authToken);
329         KonnectedModulePayload payload = new KonnectedModulePayload(authToken, callbackUrl);
330         payload.setBlink(config.blink);
331         payload.setDiscovery(config.discovery);
332         this.getThing().getChannels().forEach(channel -> {
333             // ChannelUID channelId = channel.getUID();
334             if (isLinked(channel.getUID())) {
335                 // adds linked channels to list based on last value of Channel ID
336                 // which is set to a number
337                 // get the zone number in integer form
338                 String zone = (String) channel.getConfiguration().get(CHANNEL_ZONE);
339                 // if the pin is an actuator add to actuator string
340                 // else add to sensor string
341                 // This is determined based off of the accepted item type, contact types are sensors
342                 // switch types are actuators
343                 String channelType = channel.getChannelTypeUID().getAsString();
344                 logger.debug("The channeltypeID is: {}", channelType);
345                 KonnectedModuleGson module = new KonnectedModuleGson();
346                 module.setZone(thingID, zone);
347                 if (channelType.contains(CHANNEL_SWITCH)) {
348                     payload.addSensor(module);
349                     logger.trace("Channel {} will be configured on the konnected alarm panel as a switch",
350                             channel.toString());
351                 } else if (channelType.contains(CHANNEL_ACTUATOR)) {
352                     payload.addActuators(module);
353                     logger.trace("Channel {} will be configured on the konnected alarm panel as an actuator",
354                             channel.toString());
355                 } else if (channelType.contains(CHANNEL_HUMIDITY)) {
356                     // the humidity channels do not need to be added because the supported sensor (dht22) is added under
357                     // the temp sensor
358                     logger.trace("Channel {} is a humidity channel.", channel.toString());
359                 } else if (channelType.contains(CHANNEL_TEMPERATURE)) {
360                     logger.trace("Channel {} will be configured on the konnected alarm panel as a temperature sensor",
361                             channel.toString());
362                     Configuration configuration = channel.getConfiguration();
363                     if (configuration.get(CHANNEL_TEMPERATRUE_POLL) == null) {
364                         module.setPollInterval(3);
365                     } else {
366                         module.setPollInterval(((BigDecimal) configuration.get(CHANNEL_TEMPERATRUE_POLL)).intValue());
367                     }
368                     logger.trace("The Temperature Sensor Type is: {} ",
369                             configuration.get(CHANNEL_TEMPERATURE_TYPE).toString());
370                     if ((boolean) configuration.get(CHANNEL_TEMPERATURE_TYPE)) {
371                         // add it as a dht22 module
372                         payload.addDht22(module);
373                         logger.trace(
374                                 "Channel {} will be configured on the konnected alarm panel as a DHT22 temperature sensor",
375                                 channel.toString());
376                     } else {
377                         // add to payload as a DS18B20 module if the parameter is false
378                         payload.addDs18b20(module);
379                         logger.trace(
380                                 "Channel {} will be configured on the konnected alarm panel as a DS18B20 temperature sensor",
381                                 channel.toString());
382                     }
383                 } else {
384                     logger.debug("Channel {} is of type {} which is not supported by the konnected binding",
385                             channel.toString(), channelType);
386                 }
387             } else {
388                 logger.debug("The Channel {} is not linked to an item", channel.getUID());
389             }
390         });
391         // Create Json to Send to Konnected Module
392
393         String payloadString = gson.toJson(payload);
394         logger.debug("The payload is: {}", payloadString);
395         return payloadString;
396     }
397
398     /*
399      * Prepares and sends the {@link KonnectedModulePayload} via the {@link KonnectedHttpUtils}
400      *
401      * @return response obtained from sending the settings payload to Konnected module defined by the thing
402      *
403      * @throws KonnectedHttpRetryExceeded if unable to communicate with the Konnected module defined by the Thing
404      */
405     private String updateKonnectedModule() throws KonnectedHttpRetryExceeded {
406         String payload = constructSettingsPayload();
407         String response = http.doPut(baseUrl + "/settings", payload, retryCount);
408         logger.debug("The response of the put request was: {}", response);
409         return response;
410     }
411
412     /**
413      * Sends a command to the module via {@link KonnectedHTTPUtils}
414      *
415      * @param scommand the string command, either 0 or 1 to send to the actutor pin on the Konnected module
416      * @param zone the zone to send the command to on the Konnected Module
417      */
418     private void sendActuatorCommand(String scommand, String zone, ChannelUID channelId) {
419         try {
420             Channel channel = getThing().getChannel(channelId.getId());
421             if (!(channel == null)) {
422                 logger.debug("getasstring: {} getID: {} getGroupId: {} toString:{}", channelId.getAsString(),
423                         channelId.getId(), channelId.getGroupId(), channelId.toString());
424                 Configuration configuration = channel.getConfiguration();
425                 KonnectedModuleGson payload = new KonnectedModuleGson();
426                 payload.setState(scommand);
427
428                 payload.setZone(thingID, zone);
429
430                 // check to see if this is an On Command type, if so add the momentary, pause, times to the payload if
431                 // they exist on the configuration.
432                 if (scommand.equals(getOnState(channel))) {
433                     if (configuration.get(CHANNEL_ACTUATOR_TIMES) == null) {
434                         logger.debug(
435                                 "The times configuration was not set for channelID: {}, not adding it to the payload.",
436                                 channelId.toString());
437                     } else {
438                         payload.setTimes(configuration.get(CHANNEL_ACTUATOR_TIMES).toString());
439                         logger.debug("The times configuration was set to: {} for channelID: {}.",
440                                 configuration.get(CHANNEL_ACTUATOR_TIMES).toString(), channelId.toString());
441                     }
442                     if (configuration.get(CHANNEL_ACTUATOR_MOMENTARY) == null) {
443                         logger.debug(
444                                 "The momentary configuration was not set for channelID: {}, not adding it to the payload.",
445                                 channelId.toString());
446                     } else {
447                         payload.setMomentary(configuration.get(CHANNEL_ACTUATOR_MOMENTARY).toString());
448                         logger.debug("The momentary configuration set to: {} channelID: {}.",
449                                 configuration.get(CHANNEL_ACTUATOR_MOMENTARY).toString(), channelId.toString());
450                     }
451                     if (configuration.get(CHANNEL_ACTUATOR_PAUSE) == null) {
452                         logger.debug(
453                                 "The pause configuration was not set for channelID: {}, not adding it to the payload.",
454                                 channelId.toString());
455                     } else {
456                         payload.setPause(configuration.get(CHANNEL_ACTUATOR_PAUSE).toString());
457                         logger.debug("The pause configuration was set to: {} for channelID: {}.",
458                                 configuration.get(CHANNEL_ACTUATOR_PAUSE).toString(), channelId.toString());
459                     }
460                 }
461                 String payloadString = gson.toJson(payload);
462                 logger.debug("The command payload  is: {}", payloadString);
463                 String path = "";
464                 switch (this.thingID) {
465                     case PRO_MODULE:
466                         path = "/zone";
467                         break;
468                     case WIFI_MODULE:
469                         path = "/device";
470                         break;
471                 }
472                 http.doPut(baseUrl + path, payloadString, retryCount);
473             } else {
474                 logger.debug("The channel {} returned null for channelId.getID(): {}", channelId.toString(),
475                         channelId.getId());
476             }
477         } catch (KonnectedHttpRetryExceeded e) {
478             logger.debug("Attempting to set the state of the actuator on thing {} failed: {}",
479                     this.thing.getUID().getId(), e.getMessage());
480             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
481                     "Unable to communicate with Konnected Alarm Panel confirm settings, and that module is online.");
482         }
483     }
484
485     private void getSwitchState(String zone, ChannelUID channelId) {
486         Channel channel = getThing().getChannel(channelId.getId());
487         if (!(channel == null)) {
488             logger.debug("getasstring: {} getID: {} getGroupId: {} toString:{}", channelId.getAsString(),
489                     channelId.getId(), channelId.getGroupId(), channelId.toString());
490             KonnectedModuleGson payload = new KonnectedModuleGson();
491             payload.setZone(thingID, zone);
492             String payloadString = gson.toJson(payload);
493             logger.debug("The command payload  is: {}", payloadString);
494             try {
495                 sendSetSwitchState(thingID, payloadString);
496             } catch (KonnectedHttpRetryExceeded e) {
497                 // try to get the state of the device one more time 30 seconds later. This way it can be confirmed if
498                 // the device was simply in a reboot loop when device state was attempted the first time
499                 scheduler.schedule(() -> {
500                     try {
501                         sendSetSwitchState(thingID, payloadString);
502                     } catch (KonnectedHttpRetryExceeded ex) {
503                         updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
504                                 "Unable to communicate with Konnected Alarm Panel confirm settings, and that module is online.");
505                         logger.debug("Attempting to get the state of the zone on thing {} failed for channel: {} : {}",
506                                 this.thing.getUID().getId(), channelId.getAsString(), ex.getMessage());
507                     }
508                 }, 2, TimeUnit.MINUTES);
509             }
510         } else {
511             logger.debug("The channel {} returned null for channelId.getID(): {}", channelId.toString(),
512                     channelId.getId());
513         }
514     }
515
516     private void sendSetSwitchState(String thingId, String payloadString) throws KonnectedHttpRetryExceeded {
517         String path = thingId.equals(WIFI_MODULE) ? "/device" : "/zone";
518         String response = http.doGet(baseUrl + path, payloadString, retryCount);
519         KonnectedModuleGson[] events = gson.fromJson(response, KonnectedModuleGson[].class);
520         for (KonnectedModuleGson event : events) {
521             this.handleWebHookEvent(event);
522         }
523     }
524
525     private String getOnState(Channel channel) {
526         String config = (String) channel.getConfiguration().get(CHANNEL_ONVALUE);
527         if (config == null) {
528             return "1";
529         } else {
530             return config;
531         }
532     }
533 }