I’ve made a custom platform sensor which creates multiple sensors for multiple cities around the world, available in my git hub repository.
Based on the data retrieved from the sensors created by the custom platform shabbat_times,
I was able to create two template sensors that shows the value of the start and end attributes in the new sensors based on a designated input_select.
I also thought it would be fun adding a service that allows you to update the long & lat per request,
that way you can update the same sensor according to a device from your device tracker and get the shabbat data based on the location of your device.
Well, you have the Google Geocode custom component. You should be able to look at how it pulls the device tracker info and incorporate that in. But both a fixed and a device one make sense if you consider varying use cases, if you consider submitting it to HA as a more permanent component. One covers the traditional use case…automating your home, which is a fixed location. The other covers the dashboard function.
I don’t have much experience programming in Python…but I had a look at the sunset code, and they include a python library called Astral. It looks straightforward enough to calculate based on location. Alternatively, the current sun component only seems to allow the sun to be calculated for the default location. If it was extended to allow for multiple locations, then there would be a broader use case.
You can get the latitude and longitude from the device state attributes.
But I think the sun component is based on the latitude and longitude from the Home Assistant configuration, I have no idea if you can configure it for a different latitude and longitude.
I haven’t used this component.
You can’t. Using the Home Assistant configuration longitude and latitude is hard-coded and would have to be extended. But the library it uses is already bundled into the package, so it would work if used for another component.
Hi! Thanks for getting this started. I have forked your repository and have been working on many, many improvements locally and have only now gotten back to posting them on github.
Some features I’ve added:
Support for Yom Tov
Reading the English & Hebrew parasha from Hebcal
Support for restoring the state of the sensor upon HA restart (so you don’t constantly have to requery HebCal)
Very detailed handling of many edge cases - it turns out 2018 had a lot of weird exceptional cases, e.g. Shabbat starting in one month and ending in another, two-day Yom Tov starting in September and ending in October, etc.
Simple unit tests (not using tox, just pure python for now) using cached Hebcal data – ensuring the correctness of this if you are relying on it for Shabbat automation is highly important!
Probably some other things I forgot to mention
I also added to the README an example of my template sensor for “Shabbat Mode” as well as a sample automation that runs when Shabbat Mode begins.
Please feel free to check out my github repo to download this. I haven’t tested this on an environment outside my own, so please do let me know if you run into any issues!
@TomerFi - I’d love to start integrating this as a full-fledged component into HA. I saw there was recently a Jewish Calendar sensor added using HDate but that one does not appear to be as robust and full-featured as this version is. WDYT, is it ok with you to go ahead and start integrating it?
Not exactly on topic, but have you worked out a way to incorporate the Red Alert/pikud haoref alarm as a sensor? I’d love to flash the lights in the house when the alarm goes off, in case someone is in the shower or is not sure if they heard the alarm.
Bevakasha One thing to note - part of the configuration of the Shabbat Times sensor includes a setting for minutes-before-candlelighting - so if you set that to 18, your shabbat_start time should actually include the 18 minutes; in that case if you wanted an actual start-of-Shabbat automation you’d need to add 18 minutes to that time.
Your idea for flashing the lights for the Red Alert sounds like a brilliant application, though since I am in the US it hasn’t been applicable. But, looking at Pikud Haoref’s site, it looks like there’s probably a way to do it – if you look at http://www.oref.org.il/11096-en/Pakar.aspx it seems you can at least list out the alerts for a day - there’s got to be a way to access this via URL and parse it. Might require some experimentation, but it’s possible there’s some way of getting that data out…
so sorry for the delayed response… i had tons going on:
I’m attaching my automations file hereautomations.yaml (1.6 KB)
Basically, I create a boolean that trigers when it’s shabbat and yom tov and that should trigger the automation… it configered correctly and hassio doesn’t show any errors but for some reason, it’s not working but at least it’s somewhere to start?