$iif($did(1).state == 0,$did -a $dname 11 off,$did -a $dname 11 off)

maybe, probably won't work but im not the best myself so eh.