EP SmartApp replacement for Shabbat-and-Holiday-Modes!

Interesting thread, for the non techies that were simply using smartthings for lighting and scenes. Is there a straightforward way to be able to have rules based on Shabbas and Yom Tov without knowing how to program?

Would smartthings or ITTT be capable of working with a hebrew calander?

2 Likes

The short answer is yes and you don’t have to be able to program, but you do have to put several different pieces together. And unlike the smartapp covered in this thread, you have to do a lot of the setup work yourself for each new year.

HebCal is calendar software that tracks Shabbat candle lighting times by city.

You save that as a Google calendar, and then you can use that Google calendar for the “if“ part of the third-party “If This than that” service. (IFTTT)

And smartthings has a channel on Ifttt, so you can use smartthings as the “that“ part.

It’s pretty basic, but it’s enough for some people.

Here’s a post explaining the method:

https://www.reddit.com/r/Judaism/comments/3n5hj1/home_automation_using_ifttt_google_calendar_and/

You’ll need to have a different tag word like havdallah for the end of the holidays if you want to also set automations for those. So then that ends up being a second set of Ifttt applets.

If you want to discuss this method further, please start a new topic for it under Projects.:sunglasses:

Just an FYI, myself and other people have been struggling with IFTTT and the new smarthings integrations. I even created new ifttt accounts, and it still doesn’t work great. I’m not sure of the root cause, as ifttt doesn’t have support for free members. It could be you don’t have this root cause, and ifttt is the best approach. Just a heads up…

1 Like

FYI, I did some testing, and it seems to work with TAustin’s virtual switch as well. You just need to make sure the name in the IDE matches your name requirement, not just the label. This way, the routines can be flagged as local. They weren’t for me using the ‘Simulated Switch’ from the IDE.

1 Like

Those routines aren’t really local, as they still require AWS (or your pi) to talk to the smarttthings API.

It would be pretty trivial to update the code to work based on label instead of name, but the instructions would have to be changed and that might confuse people. I could also do some sort of hybrid approach, where either name or label works, but I’m not sure of the ramifications of that, and it introduces unnecessary complexity.

1 Like

Well, my pi is local… :wink:

FYI, the switch trigger didn’t work for me. How can I debug it for next time?

That’s unfortunate. The first thing you should do is add a main('on') or main('off') to the bottom of self_hosting.py. That will test if the program is able to control the shabbos mode switch at all. If it doesn’t work, you can paste this code at the bottom of the file,

which will spit out a complete list of the names of all devices controllable by the program. If Shabbos Mode Switch isn’t there, that means that the switch wasn’t named properly.

I am able to control the device. What other debugging options do I have?

OK. It sounds like either doesn’t have the proper time information, or simply isn’t activating everyday. You can test the timing by completely replacing the last block of the code

if status(0) & (not status(1)):
    location = GeoLocation(place, lat, long, zone, elevation=elevation)
    zmanim = ZmanimCalendar(geo_location=location, date=date.gregorian_date)
    havdallah = zmanim.tzais_72()
    timezone = pytz.timezone(zone)
    now = datetime.now(timezone)
    time.sleep((havdallah - now).total_seconds())
    main('off')

with this:

location = GeoLocation(place, lat, long, zone, elevation=elevation)
zmanim = ZmanimCalendar(geo_location=location, date=date.gregorian_date)
havdallah = zmanim.tzais_72()
timezone = pytz.timezone(zone)
now = datetime.now(timezone)
print(havdallah)
print(now)

It will print out two times, in 24H format. The first is the current time, and the second is havdallah. They will be a timestamp with a timezone. For example, for me it spits out 2023-04-01 20:32:33.831775-04:00 for havdallah, with 2023-04-01 20:32:33.831775 being the time, and -04:00 is the timezone. Make sure that they’re both accurate.

I get:
2023-04-01 20:32:42.199637-04:00
2023-04-01 23:31:33.917215-04:00

seems to be working as well. What else can we try?

It seems likely, then, that the program isn’t set up to run properly with cron. I’m not a linux expert, but you should be able to see all crontab tasks by typing crontab -l in the terminal, and see if the self_hosting.py task is there. The problem is probably somewhere in the setup. If you can’t figure out how to get the cron to work, then there’s always 3rd party task scheduling software like GNOME Schedule (not really a recommendation, I just found it with a quick google search) or others that can be used to set up a scheduled task through a GUI. I would set up a test task with main('off') or main('on') on the bottom of the code. Schedule it to run a few minutes ahead.

It looks like it was setup OK.

and that CRON did run it:

I’ll need to see if there are logs and do the tests you suggested.

Alright. Let me know how it works out. Also, If you haven’t already, make sure you’re using the latest version from github, as some of the older versions had bugs.

1 Like

So here is what I learned. My RaspberriPi was initially running an older version of Python. Your code needed a newer version. In order for me to get it running, I needed to install the latest. However, it seems like you can’t necessarily upgrade the Python version on a Pi easily and it ends up creating another install side-by-side. Even when the system defaulted to the newer version, Thonny wanted to use the older one, until I changed the location.
During testing, I specified the command to be “Python 3.11 …Self-Hosting.py”, which worked fine from the LXTerminal. However, when I added “2>&1 | logger -t mycmd” to the end of the cronjob, I saw an error in the logs which said “mycmd: /bin/sh: 1: python3.11: not found”. So I changed the cronjob to just say “python” instead of “python3.11”. It seems to work now! Let’s see how it performs on Wednesday!
If you can end up making it easy to edit the havdallah time, that would be great!

Glad you got it working! I’ve noticed myself that sometimes getting the correct python to run can be difficult. Have a great pesach!

OK. So it worked. However, Hebcal and my shul havdallah was 8:18. Smartthings switch went off at 8:40. Most likely due to the 72 minute hard coded in. Any options around this?

Thanks!

Excellent! I’ve patched in support for custom havdallah times. You can find the updated files on the github.

2 Likes

Awesome! What is the best process to update my files on a Pi?

You might have to just delete the old one and start over. I don’t know if it’s possible to swap in this file without redoing the whole crontask.