# Activating a scene from code?

**URL:** <https://community.smartthings.com/t/activating-a-scene-from-code/127270>\
**Category:** Writing SmartApps\
**Created:** [May 26, 2018, 10:00pm UTC](https://community.smartthings.com/t/activating-a-scene-from-code/127270 "2018-05-26T22:00:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![coroy](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@coroy](https://community.smartthings.com/u/coroy)\
**Post date:** [May 26, 2018, 10:00pm UTC](https://community.smartthings.com/t/activating-a-scene-from-code/127270/1 "2018-05-26T22:00:21Z")

</div>

I apologize if this is somehow obvious but I cant find any code examples for running SmartThings Scenes. I keep finding older posts about Scene Machine but nothing about running SmartThing defined scenes.

---

<div class="post-metadata">

**Author:** ![tgauchat](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/tgauchat/32/49516_2.png) [@tgauchat](https://community.smartthings.com/u/tgauchat)\
**Post date:** [May 26, 2018, 10:37pm UTC](https://community.smartthings.com/t/activating-a-scene-from-code/127270/3 "2018-05-26T22:37:25Z")

</div>

You can’t call a Classic Scene directly (there is, but you can no published API), but you can call a Routine; so you just need a Routine (which can activate a Scene) for each Scene.

---

<div class="post-metadata">

**Author:** ![hyeyoung\_jung](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@hyeyoung\_jung](https://community.smartthings.com/u/hyeyoung_jung)\
**Post date:** [June 18, 2018, 11:50pm UTC](https://community.smartthings.com/t/activating-a-scene-from-code/127270/4 "2018-06-18T23:50:43Z")

</div>

Scenes API is released and you can add it in your smartapp.

- [Scenes Basics](https://smartthings.developer.samsung.com/develop/guides/smartapps/scenes-basics.html)
- [Working with Scenes](https://smartthings.developer.samsung.com/develop/guides/smartapps/working-with-scenes.html)
- [Scenes API](https://smartthings.developer.samsung.com/develop/api-ref/st-api.html#tag/scenes)

---

<div class="post-metadata">

**Author:** ![bangali](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/bangali/32/83401_2.png) [@bangali](https://community.smartthings.com/u/bangali)\
**Post date:** [August 24, 2018, 6:10am UTC](https://community.smartthings.com/t/activating-a-scene-from-code/127270/5 "2018-08-24T06:10:45Z")

</div>

so only way to get scenes list and execute a scene is thru POST … there is no groovy method like location.getScene(…) or location.executeScene(…)?

thank you.

---

<div class="post-metadata">

**Author:** ![tgauchat](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/tgauchat/32/49516_2.png) [@tgauchat](https://community.smartthings.com/u/tgauchat)\
**Post date:** [August 24, 2018, 6:31am UTC](https://community.smartthings.com/t/activating-a-scene-from-code/127270/6 "2018-08-24T06:31:27Z")

</div>

> [@bangali](#):
>
> there is no groovy method like location.getScene(…) or location.executeScene(…)?

Only for Classic **Routines** (aka “Phrases”), not Scenes.

Routines are deprecated in the new App (and new API, I presume). But you’re using the classic Groovy API…

Since many customers still use the Classic App, my advice to you is to make your SmartApp compatible with Routines, since the customer can trivially have a Routine call a Scene.

---

<div class="post-metadata">

**Author:** ![bangali](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/bangali/32/83401_2.png) [@bangali](https://community.smartthings.com/u/bangali)\
**Post date:** [August 24, 2018, 6:33am UTC](https://community.smartthings.com/t/activating-a-scene-from-code/127270/7 "2018-08-24T06:33:41Z")

</div>

thank you.

yes my rooms app already supports executing routines … just checking to make sure i wasnt missing anything in invoking scenes directly.
