[RELEASE] [BETA] WATO - When any Attribute Then this cmd Otherwise that cmd

below is my original post from the HE community forum for this app - WATO. after working with automations in the new app … as they stand today … i felt porting this app may be helpful for the community.

ST does not allow selecting from ANY of your devices in the app device selection input. it only allows selecting devices of a specific capability so unlike HE the user will need a specific capability for the device selection list to show for input. only allowed a few capabilities for now.

the intent of the app is simplicity. pick a capability, select a device of that capability and a device attribute from it to match with an user specified value then execute a command on same or different capability and device either on match and/or unmatch.

only tested for presence actions so far to set virtual presence sensor on arrival and departure because ST has chosen not to show phone presence in the new app . so that’s solved now with this … here’s a screenshot of that WATO:

not yet tested executing device commands that require parameters. that obviously works well on HE but will need to work out if any kinks show up in that on ST because of platform differences.

folks on HE use this for a range of simple actions where it may be overkill to use another custom app or automation and/or rules for. hoping folks here on ST will find it equally useful.

save and publish both apps from the IDE … with the edit noted below … but only add the WATO main app from smartapps when creating the first WATO. the WATO child app will be instantiated by the WATO main app for each WATO.

at the top of the WATO child app after the header comment section there are these 3 lines

public static String version()		{  return "v6.0.1"  }

// comment the next line for SmartThings
import hubitat.helper.RMUtils

from the IDE please comment out the import statement then save and publish the code and it will work on ST as well.

all feedback and feature requests are welcome.

if you would like to donate to support my work … donate here.

thank you.

==============================================================================

i was trying to get Rules Machine to check value of any device attribute and trigger an action on match or non-match. didnt find a way to do it. so heres some code that does that.

any device attribute can be compared with an entered value and selected commands can be run either on match or non-match.

the param fields are there for commands that need a parameter to run … like set level on a light.

here is the child app for each new WATO that is defined:

this functionality should probably be embedded in the platform … till then WATO. :slight_smile:

if you would like to donate to support this work … donate here.

2 Likes

the general format of each WATO on ST is:

WHEN [capabilityX]:[deviceA]:[ATTRIBUTE] is comparison operator compared to [user specified value] THEN execute [capabilityY]:[deviceB]:[commandM] OTHERWISE execute [capabilityY]:[deviceB]:[commandN].

where operator is one of the following selected from a pick list:

less than / less than or equals to / equals to / greater than or equals to / greater than / not equals to / rises above / falls below / changes / contains.

heres a few examples of how this is used:

  • WHEN garage tilt or contact sensor is open THEN turn on outdoor lights OTHERWISE turn off outdoor lights.
  • WHEN room humidity is greater than 50% THEN turn on room dehumidifier OTHERWISE turn off room dehumidifier.
  • WHEN kitchen water leak sensor is wet THEN change kitchen lights to blue OTHERWISE do nothing
  • WHEN room temperature is greater than 72°F THEN turn on AC OTHERWISE turn off AC
  • WHEN driveway motion sensor is active THEN ring the indoor chime OTHERWISE do nothing

this is a sampling … the possibilities of what can be done with this small app are endless. :slight_smile:

if this gets adoption will add feature to execute another WATO from the THEN and OTHERWISE branch instead of executing a device command. that would allow more complex IF … THEN … ELSE … conditions which has been requested previously on the HE forum.

feedback welcome.

thank you.

“ startup failed: script_app_metadata_4699b3e9_82d2_402b_a350_7dc1c1ab4488: 45: unable to resolve class hubitat.helper.RMUtils @ line 45, column 1. import hubitat.helper.RMUtils ^ 1 error”

When I tried to add the child app thru IDE

Edit: oh sorry I thought this was for ST. Seems it’s for hubitat

@khan95osu when i ported the code to ST i didnt want another separate copy of the code so yes the same code works on ST and HE. but in making the main posting i forgot to call out one important thing that the user had to do.

at the top of the WATO child app after the header comment section there are these 3 lines

public static String version()		{  return "v6.0.1"  }

// comment the next line for SmartThings
import hubitat.helper.RMUtils

from the IDE please comment out the import statement then save and publish the code and it will work on ST as well.

sorry about that.

perfect, thanks.

sorry i dont have a habit of reading the whole code :slight_smile:

1 Like

and you shouldn’t have to … i should have called that out in my post :slight_smile: