So transitioning from WebCore since support from SmartThings will be removed anytime (story of everyone’s lift at this point I’m sure…).
One thing I do is during Night mode, do a variety of checks to report back. For example, I check the status of my ecobee thermostat in my SHOP. If the thermostat is not in ‘OFF’ mode, it’ll add that to a variable to report on. If then checks my smart outlet I have for my truck’s block heater. If it is on, it will report that too. Basically letting me know the things that I may have left on while working out there for the day.
In order to format the message properly and only add a ’ ; ’ to split the devices up when I have multiple warnings coming back for each check, I need to check the RIGHT most value of the current variable. So example
vSTRShopCheckMessage = ‘SHOP(’ – Would set the starting variable
– Shop’s thermostate is not OFF so need to add it as a warning
IF RIGHT(vSTRShopCheckMessage , 1) != ‘(’ – Check if the right most character is ( and if it isn’t, I know I have another device already started and need to include a ; to separate
THEN vSTRShopCheckMessage = vSTRShopCheckMessage + ’ ; truckblockheater@ON ’
If it does equal (, I know nothing has been put there yet so this would be the first and wouldn’t need to include the ;. I know it is petty but helps my message be formatted very nicely.
So just curious if there is a LEFT/RIGHT functionality to pull a value and check what it is so I know what to do. In WebCore, I was able to do this within the expression code itself. Not sure if it is doable in Sharp Tools or if I would have to actually build out the IF block everytime.
One more quick question that may help me do it a little differently with less code… Arrays.
Can I populate an array with the devices that need to be reported on during NIGHT mode? Then at the end of the checks for ‘SHOP’, I could count the values in the array. If 0, no need to do anything. If I have at least one, anyway to loop through and build out the message?
@Array = { ‘truckblockheater@ON’ , 'tstat@ON } – This would be built and a new array value added for each check (dynamically)
If @Array[count] > 0
For i = 0 to @Array[count]
$ShopMessage = $ShopMessage + @Array[i]
Loop
Just using the syntax above as a generalization to get my point across.
Thanks!