I have this scenario: I would like to play a vocal message 6 times during 8 hours on different hours for 10 minutes like let’s say 10 min at 10 o’clock than 10 minutes at 11:30 and so on for 6 times. The thing is that I would like that the rule to choose some different hours and not to have some certain hours I mean today to have this 6 times message on some hours and next day these message to be played on different hours than yesterday and so on.
Is that possible?
Thanks for any tips.
That is one weird scenario. I think these two threads might help you:
Thanks for the answer but I’m afraid these are related to some kind of burglar alarm simulation and I need something similar but to choose some periods of day between 9 am and 6 pm and to play a sound 6 times on different hours / minutes. It could be 9:31, 10:54, 11:12,13:49 and so on. The catch is that it needs to be different periods on different days.
I read these post and can’t find anything to start with.
I would create a plain text-file with your schedules, read this file within a rule (which runs every minute)…
But to play random during specific hours, I think you might need an external script…
Also if you play 6 times during 8 hours a day, you will have overlapping hours… So I guess you want 1 time per hour but the minutes should be random right?
If you don‘t wanna have the same hour and minute as yesterday, you might use historical data from a persistence binding…
No I don’t want to have same hours lk yesterday, I want different hours on different days. It has to be 1 hour/ day and I thought to split this 1 hour in 6 periods of 10 minutes that will run the announcement on random hours. If the day has 8 hours, 6 times means like the sound needs to be played every 1.5 hours and it needs to be different than previously hour and previously day.
Is there any chance to have rule that will choose by it self 6 times per day 6 different hours to run a sound during 10 minutes?
Of course. You’ll probably have to write it though. You’ll need a means to ‘remember’ yesterdays schedule, and a means to pick semi-random times without duplication.
How much needs to be different? If you play at 0810 and 0930 one day, will 0820 and 0930 be “different” enough the next day?
What if your randomizer picks 0850 and 0900, do you need gaps in between?
If you can select the switching times for each day manually, then look at this
So you have a repeat interval from one week.
Thanks for ur answer. It just need to be different, it doesn’t matter if is 5, 10 or 15 min different than yesterday or the previously hour. I just need this rule to play a message for 10 minutes six times/ day at different hours.
Let’s say it’s 9:00 and the first message will be at 9:50 and it’s gonna stop at 10:00. Next message at 11:30 and it’s stop at 11:40 and so on for six times.
Next day could be at 9:15 to 9:25 and the next could be at 10:05 to 10:15 and so on.
So the fact is these message have play six times / day for 10 min each. Each period / day / week / month should be different than previously ones.
Thanks for the answer. I would prefer to skip the manual switching. It would be better to be automated but it’s a good idea though.
If you really mean that, you will have to keep a record of the pattern each day for the last year. Then each new pattern can be checked against previous runs, and rejected or accepted.
I have not worked out if you can get 365 different daily patterns from your scheme, but I should think so.
Sounds like a lot of work and I doubt that is what you actually need.
If you accept simple random, it gets a lot easier.
Decide your earliest possible time.
Divide your part-day into your roughly hourly big chunks.
Divide each of those into however many ten-minute chunks
At beginning of each day, set a counter to 0 and start a timer due to go off at start-time plus a random number of small-chunks.
When the timer runs, play your sound.
Increment the counter by one.
If the counter > 6, you’re finished for the day.
Otherwise, calculate the next runtime by startime + (counter * big-chunk) + (random * small-chunk) and reschedule the timer.
You can improve the random part by seeing if the time at runtime happens to be the last small-chunk of a big-chunk, and if it was and the new random is 0, then get another random instead. This is to ensure a gap.
Wow, even the easiest part you suggest, for me sounds like impossible. Unfortunately I can’t make rule, I can only understand parts in the rule and I can adapt an existing rule to my needs.
Have you heard of someone here on the forum working on something like this? Maybe I can find something useful and I could start with something.
The thing is that I don’t need something complicated, it has to be simple but most important is to do what I need.
Thanks for the detailed answer man.
No. It sounds like a very annoying feature that isn’t wanted in many homes.
I suppose it would have application as a bird- or cat-scarer, but I’ve seen nothing like that.
Closest similar projects are random lights simulating presence, to discourage burglars, as already suggested by @rpwong
Perhaps review what you do need. “Something random but different to each of the previous 365 days” is lots different to “Something random”.
Is anyone going to notice or care if today is 09:10 10:30 11:15 and yesterday was 09:20 10:30 11:40 ?
Man I have a small shop and I want to do “happy hour” this mean I will have some extra discounts in the shop but I don’t want them to learn the hours in order to come when the discount is active! If the customer is in the shop when the ring bels he will get the discount, if not, I don’t want them to learn the hours and to come in when is good for them. This is all about it, so the system should work by it self and I don’t want to know the exact hours. I want to be fair with all the customers, if is happy hour, let it be.
Okay, so for that purpose a genuinely random sequence would be best. What happened yesterday is immaterial.
That makes it a lot easier for you.
If this is a case of a short “bell ring” at the beginning of something like a ten-minute period, it doesn’t even matter if you do two consecutive periods, does that work?
That too makes it easier for you.
Yes it works ok if there are consecutive periods, it could be like one period of 10 min and the next 15 min or 4 periods of 15 min = 1 hour/ day. The idea is to be splinted during the all day between 9 and 18:00 and to not be same as yesterday.
I need something to start with.
Not doing it for you. There are a lot of moving parts, this is not a beginner project, but of course it can be done, and in more than one way.
I would have settings, so you can play with later.
Number of events.
Size of time slices for periods - 10, 15mins whatever.
A daily set up rule that runs at 4am can -
calculate opening duration, and divide into periods, working out period length.
Set up a overseer timer to be run at start time.
When run, the overseer timer code can -
Divide the current period into slots, by slice duration.
Generate a random slot, add to current period.
Set up an action timer to run at that randomized slot time.
Reschedule itself for next period.
When action timer runs, ring a bell.
Later, the overseer timer runs again to work on next action.
You need something to escape at end of working day - as simple as the overseer checking if next calculated action is later than closing time, and shutting down at that point.
Once the basics are working, you could enhance.
You would probably want to refine the 4am set up rule, so that you can also run it at system startup if there is a reboot during the day.
Instead of blindly setting the overseer timer for start time, it can work out next available period instead (which would often be start time).
It shouldn’t be difficult to leave out Sundays, for example, or have different numbers on other days.
Thanks for the big info, these are indeed relevant information about the project but unfortunately for me I don’t have the necessary skills to make this and I didn’t request you to do de job for me. I only asked for a way to start, maybe a link to a similar discussion but your explanation is definitely one of the ways to to it.
I’ll try to find something here on the forum, maybe something that can be adapted to my need.
Thanks again for the time spent here.
The likely difficult parts for a beginner are going to be doing maths with time, managing timers e.g. rescheduling self, and generating a random selector.
I hope the forum search is fixed soon - there are examples of all of these scattered in different uses.
Just go at it one step at a time.
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.