Safety devices for primary or secondary batteries