So, finally got my hand on the V2 hub and i am trying to modify the ST_Anything_Doors_Multiplexer smartapp to work with my setup. I have modified the number and name of the virtual sensors, this is working fine. However i also wanted to add two more virtual contact sensors, one for a sub-set of doors, and another for all doors, so that i can use these in other smart apps.
However i can’t seem to get the syntax correct, it’s not logging any errors, but the log calls within the allPatioDoorsClosed and allDoorsClosed don’t ever seem to get called.
I am also having issues testing this in the IDE, when i click to install the smartapp it hangs at ‘installing’ and doesn’t get any further. Though this could be unrelated as when i revert the changes back to when it was working fine i am also unable to install it.
Here is the code, any help appreciated!
definition(
name: "ST_Anything Doors Multiplexer",
namespace: "gazzer82",
author: "Gareth Jeanne",
description: "Connects single Arduino with multiple ContactSensor devices to their virtual device counterparts.",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
preferences {
section("Select the House Doors (Virtual Contact Sensor devices)") {
input ("frontdoor", title: "Virtual Contact Sensor for Front Door", "capability.contactSensor")
input ("patioldoor", title: "Virtual Contact Sensor for Left Patio Door", "capability.contactSensor")
input ("patiordoor", title: "Virtual Contact Sensor for Right Patio Door", "capability.contactSensor")
input ("allpatiodoor", title: "Virtual Contact Sensor for all Patio Doors", required: "false", "capability.contactSensor")
input ("alldoor", title: "Virtual Contact Sensor for all Doors", required: "false", "capability.contactSensor")
}
section("Select the Arduino ST_Anything_Doors device") {
input "arduino", "capability.contactSensor"
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
subscribe()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribe()
}
def subscribe() {
subscribe(arduino, "frontDoor.open", frontDoorOpen)
subscribe(arduino, "frontDoor.closed", frontDoorClosed)
subscribe(arduino, "patioLDoor.open", patioLDoorOpen)
subscribe(arduino, "patioLDoor.closed", patioLDoorClosed)
subscribe(arduino, "patioRDoor.open", patioRDoorOpen)
subscribe(arduino, "patioRDoor.closed", patioRDoorClosed)
}
// --- Front Door ---
def frontDoorOpen(evt)
{
if (frontdoor.currentValue("contact") != "open") {
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)"
frontdoor.openme()
allpatiodoor.openme()
alldoor.openme()
}
}
def frontDoorClosed(evt)
{
if (frontdoor.currentValue("contact") != "closed") {
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)"
frontdoor.closeme()
allPatioDoorsClosed()
allDoorsClosed()
}
}
// --- Patio left Door ---
def patioLDoorOpen(evt)
{
if (patioldoor.currentValue("contact") != "open") {
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)"
patioldoor.openme()
allpatiodoor.openme()
alldoor.openme()
}
}
def patioLDoorClosed(evt)
{
if (patioldoor.currentValue("contact") != "closed") {
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)"
patioldoor.closeme()
allPatioDoorsClosed()
allDoorsClosed()
}
}
// --- Patio right Door ---
def patioRDoorOpen(evt)
{
if (patiordoor.currentValue("contact") != "open") {
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)"
patiordoor.openme()
allpatiodoor.openme()
alldoor.openme()
}
}
def patioRDoorClosed(evt)
{
if (patiordoor.currentValue("contact") != "closed") {
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)"
patiordoor.closeme()
allPatioDoorsClosed()
allDoorsClosed()
}
}
def allPatioDoorsClosed()
{
log.debug "All patio doors closed called"
allpatiodoor.closeme()
if(patiordoor.currentValue("contact") == "closed" && patioldoor.currentValue("contact") == "closed"){
allpatiodoor.closeme()
}
}
def allDoorsClosed()
{
log.debug "All doors closed called"
if(patiordoor.currentValue("contact") == "closed" && patioldoor.currentValue("contact") == "closed" && frontdoor.currentValue("contact") == "closed"){
alldoor.closeme()
}
}
def initialize() {
// TODO: subscribe to attributes, devices, locations, etc.
}