Groovy: Routines VS Scenes

I just started to dwell into the new app and realized that Routines and Scenes were two different animals albeit they appear to do the same thing. Within the new ST App I renamed several Scenes. When I fired up my own (old) Smartapp which includes the line location.helloHome?.getPhrases() , a list of available Routines is shown The recently renamed Scenes did not appear here.

Does anyone know how I can get a list Scenes within the groovy app? What do I need to change withi location.helloHome?.getPhrases() to get an updated list of Scenes?

You have a couple different things going on.

They were supposed to be two different things in the past and yes you’re correct in that they had a very mixed metaphor. In the new world order Scenes are collections of settings, and Automations are triggers that cause thigs to happen, that can be acting on a device or a scene (a collection of settings) so its very much more cut and dried now.

SO… When you went into newapp and renamed a scene, it also upgraded that scene to the newapp schema and pulled it out of the Groovy API. This is actually one of the activities that ‘migration’ automatically does for a user. It opens each scene and saves it in the new schema. This activity is one-way and irreversible, BTW.

The net effect is what you see: ANY SCENE SAVED IN THE NEW SCHEMA IS NO LONGER REFERENCEABLE AT ALL BY THE GROOVY API, they are also read-only in the SmartThings Classic app. This is the root cause of ActionTiles, SharpTools, WebCoRE etc. not having direct access to new format scenes. Considering you’re referencing code methods here’s how you adapt:

Here’s the link to the new dev documentation. You will need to use the REST API to access scenes programmatically:

I’m actually using a variant of this in a WebCoREpiston to trigger new format scenes directly from WebCoRE.


One of the interesting things I noticed is that when Routines are migrated to Scenes, they remain ‘linked’.

When I first saw the announcement and the associated support article, it read as if the routines would be completely removed in the backend. But instead, they are migrated to Scenes and remain linked. The net effect of this is the existing routines still seem to be accessible via the Groovy phrases API and if you execute one of those routines it will trigger the associated Scene that was automatically created.

The cool thing about this is you can still make minor tweaks to the actions in the automatically created scene and it still gets run when the routine is executed.

That being said, it’s really just a transitional thing and I would effectively consider routines dead once you complete the migration. The UI for managing them disappears from the mobile app and newly created Scenes don’t get backported/linked to routines.

Alternatives include using the new REST API which includes support for Scenes or use a virtual switch or location mode to trigger the Scene.