Check out the two methods I added at the end of the file and search for their usage. onAlarmSystemStatus is called whenever the Smart Home Monitor setting is changed and updates Smart Alarm (SHM -> SA). setAlarmMode is called whenever Smart Alarm changes its status and updates Smart Home Alarm (SA -> SHM). I can explain in more detail if you need, just let me know.