Assistance with state change in automation

First a little warning about using device ids instead of entity ids.

Next you can see in the trigger section that you have from and to keys.
If you look at the state trigger in the automation trigger documentation for HA you will see that there is an option to use not_from and not_to also. There is also an example of using it with the unknown/unavailable states.