SmartApp replacement for Shabbat-and-Holiday-Modes!

Just tried your suggestion and it threw an error and didn’t change the switch status. Here is the traceback.

/usr/NAS/Smartthings-Shabbos-Mode/ DeprecationWarning: There is no current event loop     
  loop = asyncio.get_event_loop()                                                                            
Traceback (most recent call last):                                                                           
  File "/usr/NAS/Smartthings-Shabbos-Mode/", line 74, in <module>                             
  File "/usr/NAS/Smartthings-Shabbos-Mode/", line 49, in main                                 
  File "/usr/lib/python3.10/asyncio/", line 646, in run_until_complete                         
    return future.result()                                                                                   
  File "/usr/NAS/Smartthings-Shabbos-Mode/", line 38, in update_shabbos_switch                
    while devices[i].name.lower() != 'shabbos mode switch':                                                  
IndexError: list index out of range             

@Ephrayim that error indicates that your simulated switch is not being detected by the program. Is it possible that it is not named ‘Shabbos Mode Switch’ (apostrophes excluded)? You can paste & run this code at the bottom of the program to spit out a list of all devices that can be detected:

async def test():
    async with aiohttp.ClientSession() as session:
        api = pysmartthings.SmartThings(session, token)
        devices = await api.devices()
        for i in range(len(devices)):
loop = asyncio.get_event_loop()
1 Like

Thanks got it working! Looks like your program is using the device name rather than label. You are unable to modify the device name from the Smartthings app so perhaps you might consider using that instead especially since the ability to create virtual devices through the IDE will soon no longer be possible. Moreover, the virtual switch using the edge drivers runs locally unlike the simulated switch which runs in the cloud and creating the virtual switch in app you are unable to modify the device name.


@Ephrayim, but you can add a device label in-app? If that’s true, perhaps I’ll update it to work using that.

1 Like

When you rename a device in-app you are just rename the label not the actual device name which stays the same. Another thing to remember is that you can have multiple devices with the same device name but I think label needs to be unique.

1 Like

First off thank you for your work on this. As a non programmer I am getting stuck at the Amazon EventBridge instructions. When you say create a trigger, is that a rule in amazon parlance? Could you assist with more detailed instructions for the programming challenged? Next could you provide a sample " valid cron() expression" we could use? Thanks again.

@ari, I’m working on a video tutorial for the aws setup. In the meantime, yes, by trigger I mean a ‘rule’. A usable cron argument could be 0 12 * * ? * (runs at 12 noon everyday).

1 Like

After much trial and error I have it working. Thank you again. This will definitely see more prevalent usage with detailed instructions or a video.

Just to confirm, for self hosting the cron only needs to run once per day and then it will take the proper action at shkia? Or should I set the cron to run more often?

Also, it would be useful if you could set an offset for prior to shkia, to allow the switch to turn on, say, 1 hour prior to shkia.

@JacobRosenfeld , the self-hosting cron should only run once per day. After it runs, the program will wait until shkia to change the switch. Therefore, the cron should be set to run slightly before the earliest shkia in your location (to minimize the amount of time it just sits there waiting).
I may try in the future to set it to change to shabbos mode at candlelighting.

Ok thanks. In theory other Zmanim should be easy enough using the library. I may try to adjust to minchaketana or something and see how that goes