When the screen initialize you set global switch value to 1 and following with that. then in the middle how you set the global value to zero? Is it possible? And you didnt mention the rule when it will get zero. Please check one by one.
First you work with global value 1, If it works then try with 2 like wise go on with companion mode @Ultron_Slayer