]> git.basschouten.com Git - openhab-addons.git/blob
d5cbcba257706a268acaf18746d71b95540b130d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.souliss.internal.handler;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.souliss.internal.protocol.CommonCommands;
18 import org.openhab.core.thing.Bridge;
19
20 /**
21  * @author Tonino Fazio - Initial contribution
22  * @author Luca Calcaterra - Refactor for OH3
23  */
24
25 @NonNullByDefault
26 public class SoulissGatewayJobHealthy implements Runnable {
27
28     private @Nullable SoulissGatewayHandler gwHandler;
29
30     private final CommonCommands commonCommands = new CommonCommands();
31
32     public SoulissGatewayJobHealthy(Bridge bridge) {
33         this.gwHandler = (SoulissGatewayHandler) bridge.getHandler();
34     }
35
36     @Override
37     public void run() {
38         sendHealthyRequest();
39     }
40
41     private void sendHealthyRequest() {
42         var localGwHandler = this.gwHandler;
43         // sending healthy packet
44         if ((localGwHandler != null) && (localGwHandler.getGwConfig().gatewayLanAddress.length() > 0)) {
45             commonCommands.sendHealthyRequestFrame(localGwHandler.getGwConfig(), localGwHandler.getNodes());
46             // healthy packet sent
47         }
48     }
49 }