Trigger SmartThings scene from MacroDroid [Please scroll to see Sept 2023 updates]

kroma3

New member
I've reassembled everything and still no luck. Strangely, my configuration screen for the 'if' statement looks different to yours with no option to configure as 'string' (although this may already be in place).
 

tstancat

New member
The way I did it was a bit convoluted as my coding skills are rather limited. Here are the steps I took...

Tap on the if statement
Tap "Configure" from the menu
Tap the + sign in the top right corner of the "Conditions" window
Tap "MacroDroid Specific"
Tap "Compare Values"
Change Type to String
Next to Value 1, tap the button with 3 dots
Tap "LocalVar: entry_scene_name", then tap OK
Next to Value 2, tap the button with 3 dots
Tap "LocalVar: scene_name", then tap OK
Make sure the equals option is selected, then tap OK
You should now see 2 conditions in the "Conditions" window... the old condition and the new one you just created
Tap on the old condition and tap "Delete"

Good luck
 

tstancat

New member
One more thing... after setting Value 2, scroll to the bottom of the window and make sure "Case insensitive" is checked.
 

kroma3

New member
Thank you for your detailed help but, no luck I'm afraid. I've tried rebuilding everything from the bottom up but I'm still getting "no such scene".
 

tstancat

New member
Sorry to hear. One thing I did during debugging was insert Display Dialog commands to see what the values were for the entry_scene_name and scene_name variables. That's when I realized the if statement was wonky. You may want to give that a try.
 

kroma3

New member
I gave this a go. One of my 2 Smarttthings macros had identical entry_scene_name and scene_name variables. The other repeated the scene_name variable (so the two entries didn't match). Neither worked.

I've clearly messed something up with my tinkering. I've deleted the lot now and will start again at the weekend (but I fear I'm not going to succeed).

I'll let you know.

Thanks for your help!
 

kroma3

New member
I got impatient... I've started from the beginning and still no luck.

I await with interest to see what's happened and, fingers crossed, I can get it working again.

Thanks again for your help.
 

eshroom

New member
The way I did it was a bit convoluted as my coding skills are rather limited. Here are the steps I took...

Tap on the if statement
Tap "Configure" from the menu
Tap the + sign in the top right corner of the "Conditions" window
Tap "MacroDroid Specific"
Tap "Compare Values"
Change Type to String
Next to Value 1, tap the button with 3 dots
Tap "LocalVar: entry_scene_name", then tap OK
Next to Value 2, tap the button with 3 dots
Tap "LocalVar: scene_name", then tap OK
Make sure the equals option is selected, then tap OK
You should now see 2 conditions in the "Conditions" window... the old condition and the new one you just created
Tap on the old condition and tap "Delete"

Good luck

Worked for me, thanks! Wonder how it broke in the first place?
 

Endercraft

Moderator (& bug finder :D)
It you updated to MacroDroid v5.36.9 there was a fix in how plugins worked so that may have affected your macro.
 

kroma3

New member
Hooray - with your help, I've fixed it! I must have tinkered a step too far for the fix to work initially. Then, when I started from scratch, I forgot to apply the fix. But all sorted now.

Thank you!

I think I can see the problem... on the original action block, plain 'entry_scene_name' no longer works for matching. Instead, the option must be 'lv=entry_scene_name' (which seems to be the option now available if recreating the 'if' command).

I've attached the dialogue box with the old and new 'if' statements on view.

Thanks again for your input and help and, of course, to RSF for setting things up in the first place!

Kroma3
 

Attachments

  • Screenshot_20230923-165002.png
    Screenshot_20230923-165002.png
    199.9 KB · Views: 13
Last edited:

RSF

Well-known member
I'm back. I don't know what changed, but as @tstancat noted, there was an IF statement that somehow stopped working (perhaps a glitch in MacroDroid relative to local variables in Action Blocks??).

In any event, please see attached an updated "Smart Things - Trigger Scene" action block, which contains the fix identified by @tstancat, and which should be downloaded/imported nstead of the one from the original post.

Also thanks to @Endercraft for highlighting that Action Blocks can be uploaded with their own extension now, so there's no need to download and rename it.
 

Attachments

  • SmartThings-_Trigger_scene.ablock
    22.1 KB · Views: 26

Bicca

New member
Over the past day or so, my scenes have suddenly stopped working as they should, and I'm receiving a popup message that says "no such scene." I haven't made any alterations to the scene names. Do you have any recommendations or suggestions?
 

RSF

Well-known member
@Bicca - Have you downloaded and imported the updated Action Block from 9/28 (above)? That addressed an issue that appears to have been introduced in a recent update to MacroDroid, which resulted in that "No such scene" error.
 

siebenzehn

New member
Steps to set up MacroDroid to trigger a scene in SmartThings:
  1. Go to the Samsung SmartThings API "Personal Access Tokens" page, log in using your SmartThings user ID and password, and click "Generate New Token". Give your token a name, and the permissions you need (I just gave it everything listed here*, but you could be more selective if you want). and make note of the token value.
  2. Create a global variable in MacroDroid called smartthings_auth_token and set its value to "Bearer " plus the token value above (noting that the word Bearer has to have a space after it, before the token value)
  3. Import the attached action blocks -- renaming each from *.txt to *.ablock (the forum doesn't allow for .ablock files to be uploaded)
  4. Edit the "Get Locations" action block. Tap the HTTP Request (Get) action (the only action in the block), then tap "Test action". Check the value of the http_response_code and http_response variables. The response code should be 200, and the response should be a JSON structure showing your account's location(s). Make note of the location ID you want to control.
    (If your response code was 401 it means there's something wrong with your personal access token; double-check that you copied it into the global variable prefixed with "Bearer " correctly.)
  5. Edit the first action in the "Trigger Scene" action block to set the value of the location_id variable to the location ID you got in the step above. Save the action block.
  6. Call that "Trigger Scene" action block (from a macro, or another action block), passing in the name of a SmartThings scene you want to trigger. SmartThings should then run that scene... The action block returns the http_response_code as well, which should be 200 if all went well.
If you have multiple houses/locations, of course you could expand the "Get Locations" action block to take the name of a house as an argument and return its ID, vs. hard-coding the ID in the "Trigger Scene" action block.

The full SmartThings API documentation is here. You could define new scenes, control devices directly, etc.

* - i.e.: r:locations:*, x:rules:*, r:rules:*, r:scenes:*, x:devices:*, l:devices, w:rules:*, w:locations:*, r:devices:*, w:devices:*, x:locations:*, x:scenes:*
My many thanks, Sir! Your solution worked like a charm!
 
Top