How would I create a dynamic context for rules?

I’m interested in how/if OpenHAB can handle dynamic context for rules?

For example, location - so I’d like to have a function which determines where I am exactly and adjust how OpenHAB responds.

So I guess I would have an item, which has its value set based on various inputs such as where I last tapped a NFC tag/if I am ‘at home’ based on Unifi network or which device I issue a command from.

So if I have a reminder set as a rule, or a rule which says something it announces that via the most appropriate Alexa speaker/device for where I am currently.

Is such a concept possible?

Yes you can do this.

I have a string item that changes to where openhab thinks I am.

I use owntracks to update the gps binding with geofences.

So when I leave work and the temp in lounge room is too high turn the aircon on.

This is not something included in OH core for this… and there shouldn’t be. You will need to develop something on your own. I highly recommend not using the legacy rules DSL for this, but use scripted automation. Here is something that I built using Jython, but similar things could be built into their own add-ons (coming soon)…

For playing announcements on speakers in areas that are occupied, where would the announcement play if there were more than one person in the house? You could try playing just in occupied rooms, but in my experience it is better to just play on all speakers, unless a flag has been set to disable the notifications in an area. I don’t recall if the amazonechocontrol binding allows you to play to a group of Alexa devices, but this may be an option. Otherwise, play on all of them. IMO, multiroom audio is one of those “next level” type of things for home automation. I use 9 old Sony SA-NS400s (500s too) that use Homeshare to group speakers together into “parties”. They support UPnP, so when there is an announcement, I start a whole house party for speakers in area that are not silenced. For holidays, I also send sounds to the speaker in an area when it becomes active/inactive. For example, it is near Halloween, so when a motion sensor or door sensor changes state, the speaker in that area plays a random spooky sound, but only during certain times of the day. It can be a little startling at times… especially for guests!

Yes, this is what rules are for.

Beware though … location / occupancy detection is harder than it looks.

To clarify slightly what I’m meaning here.

So I don’t want this to play on all speakers, I’m in a shared house - I would not be popular, and this is not about general occupancy but specific to me personally.

So for example, I have a rule set at 6PM to remind me to file my taxes.

So I guess what I’m looking for, is how to put the logic into decide the output method.

a) I’m outside the house (not connected to wifi) → Phone notification / Email
b) I’m in the house, and last room I ‘tapped into’ with a NFC token is the bedroom → Alexa Say
c) I’m on wifi, but I tapped into the Garden → send me a phone notification

Currently the only way I can see to do this would be to have duplicate rules setup, each with different conditions so effectively the same rule fires 3 times, and the conditions stop 2/3 firing (in theory) - this just seems messy to me and was hoping there was a way to not end up with 1001 rules and having the mess of trying to keep them all up to date when want to adjust the logic etc.

Don’t do it that way, then.
Restructure as a rule that fires when triggering thingy happens, then decides where to route the message depending on the conditions at the time.