It might be possible, but it's not a trivial thing. So you need to understand exactly what you're doing.
Thanks Anton, it's just to temporarily solve a problem I have with a few devices while I find the definitive solution.
Any hints on where to more or less start?
it is possible to set an attribute calculated from the idle state of a device, e.g. if it has 1 hour of inactivity change the power-on state using calculated attribute?