diff --git a/app.json b/app.json index 459173b..fcad5e9 100644 --- a/app.json +++ b/app.json @@ -1001,6 +1001,21 @@ } ] } + ], + "conditions": [ + { + "id": "samsung_washer_job_running", + "title": { + "en": "Samsung Washer !{{is|isn't}} running" + }, + "args": [ + { + "type": "device", + "name": "device", + "filter": "driver_id=washer" + } + ] + } ] }, "drivers": [ diff --git a/drivers/washer/driver.flow.compose.json b/drivers/washer/driver.flow.compose.json index 93e19e6..5ba0105 100644 --- a/drivers/washer/driver.flow.compose.json +++ b/drivers/washer/driver.flow.compose.json @@ -125,5 +125,13 @@ "capabilities": "alarm_samsung_washer_addwash_door_open" } } + ], + "conditions": [ + { + "id": "samsung_washer_job_running", + "title": { + "en": "Samsung Washer !{{is|isn't}} running" + } + } ] } \ No newline at end of file diff --git a/drivers/washer/driver.js b/drivers/washer/driver.js index 58fcaa0..08830d6 100644 --- a/drivers/washer/driver.js +++ b/drivers/washer/driver.js @@ -4,6 +4,22 @@ const SmartThingsDriver = require('../../lib/SmartThingsDriver'); module.exports = class SmartThingsDriverWasher extends SmartThingsDriver { + async onOAuth2Init() { + await super.onOAuth2Init(); + + // Register condition card for checking if washer is running + this.homey.flow + .getConditionCard('samsung_washer_job_running') + .registerRunListener(async ({ device }) => { + // Get the current job state from the device + const currentJobState = device.getCapabilityValue('samsung_washer_current_job_state'); + + // Return true if washer is running (not in idle/finished/none state) + const idleStates = ['finished', 'idle', 'none', null, undefined]; + return currentJobState && !idleStates.includes(currentJobState); + }); + } + onPairFilterDevice(device) { this.log('onPairFilterDevice', device.deviceTypeName);