slashback100 / presence_simulation

Home Assistant Presence Simulation
420 stars 21 forks source link

Simulate weekend days on public holidays #78

Open wigster opened 1 year ago

wigster commented 1 year ago

This is a bit of an edge case, but...

Frequently we're away from home for an extended period when there is a public holiday during the vacation. It's a bit strange when e.g. on Xmas day which happens to be a Wednesday the lights follow a standard Wednesday schedule instead of a weekend one.

For this sort of thing I am using the binary sensors from the workday platform, where you can have a sensor saying that in your jurisdiction you have a holiday today or there will be one tomorrow.

It would be great if the presence simulator had an option to simulate particular days of the week depending on the status of whether today is a holiday or tomorrow is a holiday -- usually some combination of last week's Friday/Saturday/Sunday.

slashback100 commented 4 months ago

What I propose would be to add a parameter in the presence_simulation.start that would be the date (yyyy-mm-dd) to repeat, that way you can choose a weekday or a week-end day depending on what you want. Would that suit your need?

wigster commented 3 months ago

In principle this is fine for a one-off, but I think this could difficult to automate for a general set up. The fiducial case for me is a week's vacation with a public holiday say on Wednesday. Currently I flip the vacation mode on and presence_simulation runs with a delta of 7 days, taking care of weekdays/weekends correctly.

In the proposed solution, I would also have an automation which would check if today is a public holiday (I have a binary_sensor for that), I guess stop the running presence simulation and start a new one for the next 24 hours with the date parameter. The only way of automating that would I guess be a template which would pick the date of e,g, the previous Sunday, since a hard-coded date would not work in general.

Could you possibly do that calculation inside your integration, i.e. have a day of the week parameter, which would rerun the history of the last instance of some particular weekday? This would make automating easier for the end user.