What I’m trying to do is strange, but I wonder if there is a way to do it!
I want to disable a hard wired smart switch based on a time period, so that i.e. between 9 and 10am, pressing on the light switch wont have any effect on the light. (The switch in question is an Aqara switch, but something tells me that if it is possible, the make an model of the switch isn’t relevant)
The make and model of the switch is completely relevant, because most switches do not offer this possibility. Physically pressing on the switch will usually activate the internal relay. That’s to make sure that it can still work as a switch even if the home automation system is not working.
That said, there are a few (only a few) devices, which do have this option, usually as a “child lock“ feature.
What country are you in? The device selection does vary.
The other option is to use an auxiliary switch in that position which doesn’t actually control current, but which operates by sending a network command to a different device which does control the current. If you set it up that way, you could certainly put time range limits, etc. on it. But then you would have the opposite issue that if the home automation system was not working, the switch would not be functional. So I don’t know if that means your requirements or not, but if it does, we could talk about how to do that.
On Aqara it’s possible to decouple a button from a switch. Then you can recouple them via the time-based routine. But model matters, many devices are not comfortable with the ST platform at all, and there might be devices without the required feature.
OK guys. Even before I had checked the detail of the responses, I was blown away by the fact that you kind guys even responded. Thank you all!!!
And now that one of the responses does exactly what I was looking for is fantastic!!!
The answer was indeed the one given by @veonua which was to change the switch settings to decouple mode, or as its called in the settings “detached”. Click on the switch, then on the three dots top right side, settings, and change the button from switch to detached.
Then, create a routine to turn the light on or off based on the switch being pressed. Only thing I couldn’t work out was how to create a “not” based routine, all it was offering me was an “if” option. But I’ve managed to get around that for the time being with a virtual switch which I’ve turned on via a timed routine.
There isn’t a “Not” option in Routines. You need to build your trigger conditions to be true for whatever your not scenario is. For example, “if the switch is not turned on” is “if the switch is off”. For discrete time periods, you can say "If between 8:00am and 9:00am (precondition), switch is toggled up then turn on the switch). Preconditions are state checks like “is something on, is contact sensor open, is it a certain time period, etc” vs trigger conditions which are state changes like "contact sensor closes, time is now 9:00am, door unlocks, presence is not present, etc).