Subscribing to a location event works the same way as subscribing to a device event so need to create the handler method the same way you would for any other device.
If you find that the mode change handler isn’t executing, check the documentation because I’m not sure that I gave you the correct syntax.
Installed and Updated Method Explanation
The only time the “installed” method executes is when the SmartApp is first installed. The “updated” method gets executed when the SmartApp is installed and every time you click the SmartApp’s “Done” button.
(I think it’s every time, but it might just be when you exit the SmartApp by tapping the “Done” button)
Recommended Solution for Mode Issue
I’m using “process” as a general term for the code that checks if changes like turning things on/off need to be made and makes them when needed.
Goal 1: Immediately start process when mode is in the selectedModes list and the settings are changed.
You already achieved this goal by adding “handleTemperature(tempSensor.currentTemperature)” to the “updated()” method.
Goal 2: Immediately start the process when mode becomes one of the modes in the selectedModes list.
You can achieve this goal by implementing the “modeChangeHandler(evt)” method and adding the line “handleTemperature(tempSensor.currentTemperature)” to it.
Goal 3: Prevent the process from starting when mode is not in the selectedModes list.
The Updated, modeChangedHandler, and temperatureHandler methods all execute the handleTemperature method so the easiest way to prevent them from starting the process is by wrapping the contents of the handleTemperature method with “if(currentModeAllowed(settings.selectedModes)){”.
If you also want to prevent the temperature change log entries, you can wrap the temperatureHandler method contents, but otherwise it’s not needed.
When motion is detected, it does more than just execute the handleTemperature method so the easiest way to prevent the process from being started is by wrapping the contents of the motionHandler method with “if(currentModeAllowed(settings.selectedModes)){”.
I’m pretty sure that adding the mode checks to the handleTemperature and motionHandler methods and adding calling handleTemperature method from the new motionChangedHandler, as described above, with solve all your problems.