“to” and “state” are the same thing, so no need to duplicate that in your config.
Anyways, looking at your config, change group.devices to group.all_devices and change not home to not_home and it should work. If you made a custom group of group.devices that may work as well, but I’m not sure how groups get their state so I’m not sure.