Location.mode subscription

Im subscribing to location.mode, but when the hub is changing modes im also getting HSM events as part of it, its no big deal apart from its causing the app to fire twice for every mode change,

Is there a way to filter the HSM out like with location.mode.hubmode ???

Say what? Please show the Location logs. HSM does not send mode events. It does send location events, but none of these are called mode.

Show the code you are using for subscribe().

It should be one of these two:

subscribe(location, "mode", modeHandler)

subscribe(location, "mode.Day", modeHandler) for example with specific mode.

Mabey not just done a reboot, looks like getting the hub version??


image

void initialize() {
    subscribe(location, "mode", ModeHand)
    log.info "${app.label} Subscribed to Mode $TrigMode delay between commands is $DelayTime milli seconds"
}

def ModeHand(evt){
    if (logEnable == true) log.info "${app.label} mode is ${evt.value} "
    if (TrigMode.contains(evt.value) || evt == 'NOW') {
        short del = DelayTime
        if (logEnable == true) log.info "${app.label} mode is ${TrigMode} doing the business"
        
        if (OffDev !=null){
            for (com.hubitat.app.DeviceWrapper dev in OffDev) { 

Not those logs. Location Events. They show all location events. A separate tab on the logs page.

So there is nothing from HSM relating to mode. Something is pushing your hub to Day mode right after Evening mode, effectively at the same time. This would not be / could not be HSM. What apps are setting mode?

the last two location events was me testing moving it from day to eve and then back

the other triggers in the logs was reboots

the weird thing is the mode 2.3.0.124 being sent on start up
image

The hub doesn't send location.mode events on startup.

but something is sending the hub version on startup and some how the app is picking it up. The only thing its subscribed to is location mode

full code
definition(
    parent: "Mark-C-UK:BulkControl",
	name: "BulkControlChild",
	namespace: "Mark-C-UK",
	author: "Mark C",
	description: "Turn large number of devices on and off using on mode",
	category: "Convenience",
	iconUrl: "",
	iconX2Url: ""
)

preferences {
    section("<h3><u>Set your <b>Trigger Modes(s)</u></h3>"){
        input 'TrigMode', 'mode', title: 'Mode to trigger', multiple: true, required: false
    }
    section("<h3><u>Set your devices to turn <b>ON</b> or <b>OFF</b></u></h3>"){
        input 'OffDev', 'capability.switch', title: 'Device(s) to turn off', required: false, multiple: true
		input 'OnDev', 'capability.switch', title: 'Device(s) to turn on', required: false, multiple: true
        input 'WhatsOn', 'capability.switch', title: 'if you use whats on checker this is that apps trigger switch', required: false, multiple: false
    }
    section("<h3><u>Set your <b>DELAY</b> between commands in milli seconds</u></h3>"){
        input 'DelayTime', 'number', title: 'time between command (recomened Min 500)', required: true
    }
    section("<h3><u><b>LOGGING</b> OPTIONS</u></h3>"){
        input 'logEnable', 'bool', title: 'Enable debug logging', defaultValue: false
        input "testBtn1", "button", title: "Run Test Now"
    }
}

void updated() { 
    unsubscribe()
	initialize()
}

void installed() {
	initialize()
}
void uninstalled(){
    unschedule()
	unsubscribe()
}

void initialize() {
    subscribe(location, "mode", ModeHand)
    log.info "${app.label} Subscribed to Mode $TrigMode delay between commands is $DelayTime milli seconds"
}

def ModeHand(evt){
    if (logEnable == true) log.info "${app.label} mode is ${evt.value} "
    if (TrigMode.contains(evt.value) || evt == 'NOW') {
        short del = DelayTime
        if (logEnable == true) log.info "${app.label} mode is ${TrigMode} doing the business"
        
        if (OffDev !=null){
            for (com.hubitat.app.DeviceWrapper dev in OffDev) { //com.hubitat.app.DeviceWrapper
                if (logEnable == true) log.trace "${app.label} Turning off $dev"
                dev.off()
                pause(del)
            }
        }
        
        if (OnDev != null){
            for (com.hubitat.app.DeviceWrapper dev in OnDev) { //com.hubitat.app.DeviceWrapper 
                if (logEnable == true) log.trace "${app.label} Turning on $dev"
                dev.on()
                pause(del)
            }
        }
        if (WhatsOn != null){
            pause(del*2)
            if (logEnable == true) log.trace "${app.label} Turning on $WhatsOn"
            WhatsOn.on()
        }
    }
    else { 
        if (logEnable == true) log.info "${app.label} mode is NOT ${TrigMode} no action"
    }
}
def appButtonHandler(buttonPressed) {
    log.debug "Run Now test"
    if(buttonPressed == "testBtn1"){
        ModeHand('NOW')
    }
}

soz to waste your time i uninstalled it and reinstalled it, did a reboot and its not done it again, it must have been hanging onto an old subscription when i had omitted "mode"

subscribe(location, ModeHand)

If you never called some form of unsubscribe(), it will hang on to the old subscriptions (for the same installed instance of that app) until you do. Installing a new instance is probably why this addressed that problem.

i have it on my updated handler but thinking back i never went back to the app after i fixed to error in the original subscription