-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Chris Jackson <[email protected]>
- Loading branch information
Showing
95 changed files
with
887 additions
and
995 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
bin/ | ||
target/ | ||
**/.settings/org.eclipse.* | ||
*.sh |
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
37 changes: 37 additions & 0 deletions
37
...ee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/handler/TuyaBlindsThingHandler.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,37 @@ | ||
package org.openhab.binding.zigbee.tuya.handler; | ||
|
||
import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; | ||
import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; | ||
import org.openhab.binding.zigbee.handler.ZigBeeIsAliveTracker; | ||
import org.openhab.core.thing.Thing; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.zsmartsystems.zigbee.ZigBeeEndpoint; | ||
import com.zsmartsystems.zigbee.ZigBeeNode; | ||
|
||
/** | ||
* Handler for Tuya AM25 blinds | ||
* | ||
* @author Chris Jackson - Initial Contribution | ||
* | ||
*/ | ||
public class TuyaBlindsThingHandler extends ZigBeeBaseThingHandler { | ||
private Logger logger = LoggerFactory.getLogger(TuyaBlindsThingHandler.class); | ||
|
||
public TuyaBlindsThingHandler(Thing zigbeeDevice, ZigBeeChannelConverterFactory channelFactory, | ||
ZigBeeIsAliveTracker zigbeeIsAliveTracker) { | ||
super(zigbeeDevice, channelFactory, zigbeeIsAliveTracker); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
@Override | ||
protected void doNodeInitialisation(ZigBeeNode node) { | ||
ZigBeeEndpoint endpoint = node.getEndpoint(1); | ||
if (endpoint == null) { | ||
logger.error("{}: Tuya blinds handler couldn't find endpoint 1", node.getIeeeAddress()); | ||
return; | ||
} | ||
} | ||
|
||
} |
93 changes: 93 additions & 0 deletions
93
...igbee.tuya/src/main/java/org/openhab/binding/zigbee/tuya/internal/TuyaHandlerFactory.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,93 @@ | ||
/** | ||
* 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.zigbee.tuya.internal; | ||
|
||
import java.util.Hashtable; | ||
|
||
import org.openhab.binding.zigbee.converter.ZigBeeChannelConverterFactory; | ||
import org.openhab.binding.zigbee.discovery.ZigBeeThingTypeMatcher; | ||
import org.openhab.binding.zigbee.handler.ZigBeeBaseThingHandler; | ||
import org.openhab.binding.zigbee.handler.ZigBeeGenericThingHandler; | ||
import org.openhab.binding.zigbee.handler.ZigBeeIsAliveTracker; | ||
import org.openhab.binding.zigbee.tuya.TuyaBindingConstants; | ||
import org.openhab.binding.zigbee.tuya.handler.TuyaBlindsThingHandler; | ||
import org.openhab.core.config.core.ConfigDescriptionProvider; | ||
import org.openhab.core.thing.Thing; | ||
import org.openhab.core.thing.ThingTypeUID; | ||
import org.openhab.core.thing.binding.BaseThingHandlerFactory; | ||
import org.openhab.core.thing.binding.ThingHandler; | ||
import org.openhab.core.thing.binding.ThingHandlerFactory; | ||
import org.openhab.core.thing.type.DynamicStateDescriptionProvider; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Reference; | ||
|
||
/** | ||
* The {@link TuyaHandlerFactory} is responsible for creating things and thing | ||
* handlers for Tuya devices. | ||
* | ||
* @author Chris Jackson - Initial contribution | ||
*/ | ||
@Component(service = ThingHandlerFactory.class) | ||
public class TuyaHandlerFactory extends BaseThingHandlerFactory { | ||
|
||
private final ZigBeeThingTypeMatcher matcher = new ZigBeeThingTypeMatcher(); | ||
|
||
private ZigBeeChannelConverterFactory zigbeeChannelConverterFactory; | ||
private ZigBeeIsAliveTracker zigbeeIsAliveTracker; | ||
|
||
@Override | ||
public boolean supportsThingType(ThingTypeUID thingTypeUID) { | ||
return matcher.getSupportedThingTypeUIDs().contains(thingTypeUID); | ||
} | ||
|
||
@Override | ||
protected ThingHandler createHandler(Thing thing) { | ||
if (!supportsThingType(thing.getThingTypeUID())) { | ||
return null; | ||
} | ||
|
||
ZigBeeBaseThingHandler handler; | ||
|
||
// Check for thing types with a custom thing handler | ||
if (thing.getThingTypeUID().equals(TuyaBindingConstants.THING_TYPE_TUYA_BLIND_AM25)) { | ||
handler = new TuyaBlindsThingHandler(thing, zigbeeChannelConverterFactory, zigbeeIsAliveTracker); | ||
} else { | ||
handler = new ZigBeeGenericThingHandler(thing, zigbeeChannelConverterFactory, zigbeeIsAliveTracker); | ||
} | ||
|
||
bundleContext.registerService(ConfigDescriptionProvider.class.getName(), handler, | ||
new Hashtable<String, Object>()); | ||
bundleContext.registerService(DynamicStateDescriptionProvider.class.getName(), handler, | ||
new Hashtable<String, Object>()); | ||
|
||
return handler; | ||
} | ||
|
||
@Reference | ||
protected void setZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) { | ||
this.zigbeeChannelConverterFactory = zigbeeChannelConverterFactory; | ||
} | ||
|
||
protected void unsetZigBeeChannelConverterFactory(ZigBeeChannelConverterFactory zigbeeChannelConverterFactory) { | ||
this.zigbeeChannelConverterFactory = null; | ||
} | ||
|
||
@Reference | ||
protected void setZigbeeIsAliveTracker(ZigBeeIsAliveTracker zigbeeIsAliveTracker) { | ||
this.zigbeeIsAliveTracker = zigbeeIsAliveTracker; | ||
} | ||
|
||
protected void unsetZigbeeIsAliveTracker(ZigBeeIsAliveTracker zigbeeIsAliveTracker) { | ||
this.zigbeeIsAliveTracker = null; | ||
} | ||
} |
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
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.