forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added latest models & updated status model (no channels for most devi…
…ces yet though)
- Loading branch information
Showing
18 changed files
with
464 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...witchbot/src/main/java/org/openhab/binding/switchbot/internal/config/ColorBulbConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.openhab.binding.switchbot.internal.config; | ||
|
||
public class ColorBulbConfig { | ||
private String deviceId; | ||
private int refreshInterval; | ||
|
||
public String getDeviceId() { | ||
return deviceId; | ||
} | ||
|
||
public void setDeviceId(String deviceId) { | ||
this.deviceId = deviceId; | ||
} | ||
|
||
public int getRefreshInterval() { | ||
return refreshInterval; | ||
} | ||
|
||
public void setRefreshInterval(int refreshInterval) { | ||
this.refreshInterval = refreshInterval; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HumidifierConfig [deviceId=" + deviceId + ", refreshInterval=" + refreshInterval + "]"; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...hbot/src/main/java/org/openhab/binding/switchbot/internal/config/ContactSensorConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.openhab.binding.switchbot.internal.config; | ||
|
||
public class ContactSensorConfig { | ||
private String deviceId; | ||
private int refreshInterval; | ||
|
||
public String getDeviceId() { | ||
return deviceId; | ||
} | ||
|
||
public void setDeviceId(String deviceId) { | ||
this.deviceId = deviceId; | ||
} | ||
|
||
public int getRefreshInterval() { | ||
return refreshInterval; | ||
} | ||
|
||
public void setRefreshInterval(int refreshInterval) { | ||
this.refreshInterval = refreshInterval; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HumidifierConfig [deviceId=" + deviceId + ", refreshInterval=" + refreshInterval + "]"; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...chbot/src/main/java/org/openhab/binding/switchbot/internal/config/MotionSensorConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.openhab.binding.switchbot.internal.config; | ||
|
||
public class MotionSensorConfig { | ||
private String deviceId; | ||
private int refreshInterval; | ||
|
||
public String getDeviceId() { | ||
return deviceId; | ||
} | ||
|
||
public void setDeviceId(String deviceId) { | ||
this.deviceId = deviceId; | ||
} | ||
|
||
public int getRefreshInterval() { | ||
return refreshInterval; | ||
} | ||
|
||
public void setRefreshInterval(int refreshInterval) { | ||
this.refreshInterval = refreshInterval; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "HumidifierConfig [deviceId=" + deviceId + ", refreshInterval=" + refreshInterval + "]"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...tchbot/src/main/java/org/openhab/binding/switchbot/internal/handler/ColorBulbHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.switchbot.internal.handler; | ||
|
||
import org.openhab.binding.switchbot.internal.config.MeterConfig; | ||
import org.openhab.core.thing.Thing; | ||
import org.openhab.core.thing.ThingStatus; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The {@link ColorBulbHandler} is responsible for handling commands, which are | ||
* sent to one of the channels. It maps the OpenHAB world to the Switchbot world. | ||
* | ||
* @author Arjan Lamers - Initial contribution | ||
*/ | ||
public class ColorBulbHandler extends SwitchbotHandler { | ||
|
||
private Logger logger = LoggerFactory.getLogger(ColorBulbHandler.class); | ||
|
||
public ColorBulbHandler(Thing thing) { | ||
super(thing); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
updateStatus(ThingStatus.UNKNOWN); | ||
logger.debug("Will boot up Switchbot Color Bulb binding"); | ||
|
||
MeterConfig config = getThing().getConfiguration().as(MeterConfig.class); | ||
|
||
logger.debug("Color Bulb Config: {}", config); | ||
|
||
refreshTime = config.getRefreshInterval(); | ||
if (refreshTime < 1) { | ||
logger.warn( | ||
"Refresh time [{}] is not valid. Refresh time must be at least 1 seconds. Setting to minimum of 30 sec", | ||
refreshTime); | ||
config.setRefreshInterval(1); | ||
} | ||
|
||
apiProxy = new SwitchbotApiProxy(config.getDeviceId(), authorizationOpenToken); | ||
startAutomaticRefresh(); | ||
} | ||
|
||
@Override | ||
protected void updateState(SwitchbotApiStatusModel status) { | ||
// TODO Auto-generated method stub | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...ot/src/main/java/org/openhab/binding/switchbot/internal/handler/ContactSensorHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.switchbot.internal.handler; | ||
|
||
import org.openhab.binding.switchbot.internal.config.MeterConfig; | ||
import org.openhab.core.thing.Thing; | ||
import org.openhab.core.thing.ThingStatus; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The {@link ContactSensorHandler} is responsible for handling commands, which are | ||
* sent to one of the channels. It maps the OpenHAB world to the Switchbot world. | ||
* | ||
* @author Arjan Lamers - Initial contribution | ||
*/ | ||
public class ContactSensorHandler extends SwitchbotHandler { | ||
|
||
private Logger logger = LoggerFactory.getLogger(ContactSensorHandler.class); | ||
|
||
public ContactSensorHandler(Thing thing) { | ||
super(thing); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
updateStatus(ThingStatus.UNKNOWN); | ||
logger.debug("Will boot up Switchbot Contact Sensor binding"); | ||
|
||
MeterConfig config = getThing().getConfiguration().as(MeterConfig.class); | ||
|
||
logger.debug("Curtain Config: {}", config); | ||
|
||
refreshTime = config.getRefreshInterval(); | ||
if (refreshTime < 1) { | ||
logger.warn( | ||
"Refresh time [{}] is not valid. Refresh time must be at least 1 second. Setting to minimum of 30 sec", | ||
refreshTime); | ||
config.setRefreshInterval(1); | ||
} | ||
|
||
apiProxy = new SwitchbotApiProxy(config.getDeviceId(), authorizationOpenToken); | ||
startAutomaticRefresh(); | ||
} | ||
|
||
@Override | ||
protected void updateState(SwitchbotApiStatusModel status) { | ||
// TODO Auto-generated method stub | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.