fix onstate on sensors