Hi @Andrew2, welcome to SharpTools family and our community, and glad that you have enjoyed SharpTools.
You can create a TEXT variable and a rule to update this variable’s content based on the relay’s on/off state. Add this variable to the dashboard and configure it to open hyperlink when tapped with the $.runRule() syntax to trigger another rule to toggle the relay. (See screenshot below.) The downside of this is you will not be able to change the tile color based on the variable content.
The other approach is to create a custom device handler that reports the state as “SET”/“UNSET” as an additional custom attribute and use Hero Attribute tile to display this custom attribute’s value. And then customize the Hero Attribute tile to display the text attribute value while the active color is based on the On/Off status.
I guess the other option would be leverage the SHM (Smart Home Montor) from the SmartThings classic app, which is probably the easiest option if you have access to SHM in the classic app.
Create a rule that is triggered by SHM changed to Armed Away or Disarmed, and then turn the relay on/off accordingly.
Add SHM tile in the dashboard for SHM status control, which will visually show you the SHM status (icon and text), and you can customize the color too.
You can find more details from the Device Handler guide from the link below, and please note that SmartThings is working on shifting to the new API though.
No worries, I’d be happy to explain the logic in the rule and trigger. So you can decide who you want to create your rules. Keep in mind that there are multiple ways to do so since the Rule Engine is really flexible.
The reason why I had two triggers for each rule is to reduce the number of rules so it’s easier to manage. You can of course break each rule to two rules and have one trigger each, and the related IF_Condition.
Please note that the rule is kicked off to execute the activities in the FLOW when either of the trigger event received. In the first rule, I want the rule to be kicked of when SHM is changed to either armed way or disarmed, and I then used IF_Condition in the FLOW to further check what event (SHM armed away event or disarmed event) it is and if the relay should be changed based on its current status before I send the relay command.
You can also find the fundamentals about Rule Engine with a great intro video made by @Justin_Newbury from SimplySmart in the KB article below.
how can i set up a rule that when one relay is active you cannot activate another (so you cant full set the alarm when it is night set) and vice versa.
i basically want one relay that turns something on, but when this relay is on, you cannot use another relay and vice versa.
See below for a quick rule logic example. In this case, you would want to use an IF_Condition to check other device’s state (the relay 1) and decide if you want it to continue the automation (change mode, alarm state or some other actions) or just ignore it and set the relay (relay 2) back to off.
-Triggers: when Relay 2 is turned on
-Flow: If Relay 1 is on, then do thing but set Relay 2 back to off; else, set the alarm status accordingly
Basically, i have two sets for the alarm A and B - they stay latched.
When you turn A on, it still lets you turn B on, which will confuse the actual alarm panel.
I basically want the software to stop you turning on B when A is already on, and the otherway around, when B is on if you click A on it stops you.
In order to prevent both relays from turning on at the same time, you would have to do something at the device level. If I understand your setup, it sounds like you have two individual relays (A and B) and you only want one or the other to be turned on at one time.
Here’s some options for you, but be sure to note the pros and cons of each:
Reactive Rule: In a SharpTools Rule, you could react to one of the relays being turned on and make sure the other one gets turned back off, but there would be a brief period where both relays are turned on.
Proxy Devices: You could use a Virtual Switch or variable as a ‘proxy’ for turning on your switches, then you could build a rule that reacts to these. This would ensure only one of the relays is on at a time as long as you always controlled the virtual version, but it still leaves the possibility of accidentally controlling the real relays.
Multirelay Hardware: There are some devices that have multiple relays built into them. If their configuration allows turning on just one relay at a time, that would work. Otherwise you would have to modify one of the community drivers to only allow one relay on at a time. You might reach out to Konnected or Zooz (ZEN16) to see if their devices support this.