Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions switchbotScene
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*

Copyright 2021 - Nick Betcher (@nbetcher)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-------------------------------------------

Change history:
0.1.0 - @nbetcher - Initial release.

*/

metadata
{
definition(name: "SwitchBot Scene", namespace: "tomw", author: "tomw", importUrl: "")
{
capability "Momentary"
}
}

def push() {
def id = getParent()?.getId(device.getDeviceNetworkId())
if(id)
{
def respData = getParent()?.executeScene(id)
runIn(2, refresh)
}
}
16 changes: 15 additions & 1 deletion switchbotSystem
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
-------------------------------------------

Change history:
0.9.7 - @nbetcher - Added Scene device support as a virtual driver.
0.9.6 - @tomw - Added Humidifier support.
0.9.3 - @tomw - Modified child device creation to reduce confusion around grouped Curtain devices.
0.9.0 - @tomw - Initial release.
Expand Down Expand Up @@ -123,6 +124,19 @@ def checkCommStatus()
def createChildDevices()
{
def devices = getDevices()
def scenes = getScenes()

if (scenes)
{
for (it in scenes)
{
logDebug("Scene = ${it}")
if((it.sceneName && it.sceneId) && !findChildDevice(it.sceneId, 'Scene'))
{
createChildDevice(it.sceneName, it.sceneId, 'Scene')
}
}
}

if(!devices)
{
Expand Down Expand Up @@ -205,7 +219,7 @@ def createChildDevice(name, id, deviceType)
def child
try
{
if(!["Bot", "Curtain", "Meter", "IR Device", "Humidifier"].contains(deviceType.toString()))
if(!["Bot", "Curtain", "Meter", "IR Device", "Humidifier", "Scene"].contains(deviceType.toString()))
{
logDebug("createChildDevice: deviceType not supported")
throw new Exception("deviceType not supported")
Expand Down