if (!b.changedSince(now.minusSeconds(1)))
b.sendCommand(OFF)
Also, b cannot be of integer type (for state comparison) and OnOffType (in sendCommand) at the same time
Also, you must be sure that you properly persist the b item on everyChange (which doesn’t work for me). Do debug prints to see if what’s stored in persistence database now and X seconds ago really differ.
I wouldn’t use persistence here anyway but global variables.