Skip to content

Commit

Permalink
Temperature & Humidity sync MQTT to SmartThings
Browse files Browse the repository at this point in the history
  • Loading branch information
JZ-SmartThings committed Aug 31, 2019
1 parent 066d3f4 commit 2d756af
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy
Expand Up @@ -228,7 +228,8 @@ import groovy.transform.Field
capability: "capability.relativeHumidityMeasurement",
attributes: [
"humidity"
]
],
action: "actionHumiditySensors"
],
"relaySwitch": [
name: "Relay Switch",
Expand Down Expand Up @@ -316,7 +317,8 @@ import groovy.transform.Field
capability: "capability.temperatureMeasurement",
attributes: [
"temperature"
]
],
action: "actionTemperatureSensors"
],
"thermostat": [
name: "Thermostat",
Expand Down Expand Up @@ -746,6 +748,26 @@ def actionThermostatMode(device, attribute, value) {
device.setThermostatMode(value)
}

//Temperature Sensors don't have commands but a simulated sensor might hence the hasCommand() check.
def actionTemperatureSensors(device, attribute, value) {
if (device.hasCommand("temperature")) {
device.temperature(value as int)
}
if (device.hasCommand("setTemperature")) {
device.setTemperature(value as int)
}
}

//Humidity Sensors don't have commands but a simulated sensor might hence the hasCommand() check.
def actionHumiditySensors(device, attribute, value) {
if (device.hasCommand("humidity")) {
device.humidity(value as int)
}
if (device.hasCommand("setHumidity")) {
device.setHumidity(value as int)
}
}

def actionTimedSession(device, attribute, value) {
if (attribute == "timeRemaining") {
device.setTimeRemaining(value)
Expand Down

0 comments on commit 2d756af

Please sign in to comment.