How to Limit HTTP (POST/GET) Request?

You already have a ~29 second wait after the get requests now. Adding a delay after the Get's won't get you anything. :wink: hehe But seriously, it would be redundant.

1 Like

For testing I am using a ST Motion Sensor but when I deploy the Raspberry Pi - I will be using Konnected on hard wired motion sensors that donā€™t have any delay (so they will produce lots of events).

So I should put a delay under select actions for false where I have stop action for this rule?

Thanks!

There's not delay timing built into the Konnected board or driver?

1 Like

I donā€™t think so - donā€™t see an option to specify a delay. Perhaps @nate can confirm.

No, there is no delay. Nobody has ever asked for a delay -- typically people want it fast and accurate.

1 Like

You can add the motion device to a Motion Zone using the built in Zone Motion Controllers app. This was how I was able to setup proper motion inactive delays to my Konnected sensors in the past.

Edit: it would need to be the Motion Aggregator type in the app.

1 Like

Thanks for clarifying @nate. I guess delay isnā€™t the right word - for instance when the ST motion sensor detects motion it will become active and then inactive a few seconds after motion has stopped - typically wired sensors become inactive immediately. This will result in significantly more motion events so having it wait a few seconds before reporting inactive could potentially remediate this?

I am not sure if these extra motion events will result in any performance degradation on the Hubitat hub. But I could see it happen in a large install with 20+ motion sensors and multiple rules.

Hopefully my scenario makes sense.

In the false action, just add a ā€œdelay n seconds with cancelā€ before your existing false action. This will prevent the rule from reacting to a chatty motion sensor input.

1 Like

When I had this setup I only had 8 sensors going and it did help fill up my logs quickly but didn't have an impact on my hub performance. This was many f\w revisions ago so I can't speak for the current environment.

1 Like

What you're referring to is known as debouncing. It's not a feature in Konnected currently, but you could add something like this to the Konnected app if you really want.

1 Like

I have probably 10 different versions of the Konnected app and drivers I've messed around with over the last 6 months.

I initially had to do this to get rid of the (in my opinion) ridiculous amount of debug logging @nate put into his drivers and app that can't be disabled... Last thing I need are devices screaming "everything's normal" in my logs tens of thousands of times per day.

I don't have any versions that have contact debounce, but adding that to contacts wouldn't be hard to do either if you really wanted to - just a few lines of code.

1 Like

Thanks for giving permission to share this @nate.

@kamransiddiqi1998 , this is the custom version of the Konnection Motion driver that I use to essentially increase the hardware blind. You can customize how long it will take to send an inactive event by changing the debounce input value.

Edit: updated code to change description from "debounce" to "Inactivity Timeout" so it more accurately reflects what the setting is doing. I wrote this for myself so I didn't really think about proper wording at the time.

/**
 *  Konnected Motion Sensor
 *
 *  Copyright 2018 Konnected Inc (https://konnected.io)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 *    - added ability to increase hardware implemented blind - Stephan Hackett (@stephack)
 *
 */
metadata {
  definition (name: "Konnected Motion Sensor - Custom", namespace: "konnected-io", author: "konnected.io", mnmn: "SmartThings", vid:"generic-motion") {
    capability "Motion Sensor"
    capability "Sensor"
  }

  preferences {
    input name: "normalState", type: "enum", title: "Normal State",
      options: ["Normally Closed", "Normally Open"],
      defaultValue: "Normally Closed",
      description: "Most motion sensors are Normally Closed (NC), meaning that the circuit opens when motion is detected. To reverse this logic, select Normally Open (NO)."
	input name: "blind", type: "number", title: "Inactivity Timeout (Actual Timeout will be this value + H/W blind):"
  }

}

def isClosed() {
  normalState == "Normally Open" ? "active" : "inactive"
}

def isOpen() {
  normalState == "Normally Open" ? "inactive" : "active"
}

// Update state sent from parent app
def setStatus(mystate) {
	def stateValue = mystate == "1" ? isOpen() : isClosed()
	if(stateValue == "active") {
		state.lastActive = now()
		sendEvent(name: "motion", value: "active")
		//log.info device.currentMotion
		if(device.currentMotion != "active") log.debug "$device.label is active"
	}
	else{
		runIn(blind, "calcMe")
	}
}

def calcMe() {
	def delta = (now() - (state.lastActive ?: 0)) / 1000
	//log.debug delta
	if(delta > blind){
		sendEvent(name: "motion", value: "inactive")
		log.debug "$device.label is inactive"
	}
}
1 Like

Awesome! Thanks for sharing this. Where is the debounce variable that we should modify?

Thanks

It is an input on the device page called "debounce". This way you don't need to edit code to change your settings.

1 Like

I updated the code to change description from "debounce" to "Inactivity Timeout" so it more accurately reflects what the setting is doing. I wrote this for myself so I didn't really think about proper wording at the time. It does not change the functionality in any way.

1 Like

Thanks @ogiewon - I added the cancel. Will test it out and will update if all works well.

The delay doesnā€™t seem to be reducing the number of GET requests.

If you sensor goes to inactive in less than 5 seconds, then the delay won't help much. You would need the delay to be the difference between your repeat time and the actual time it takes for you sensor to send an inactive event after motion stops.

So, if your motion sensor send an inactive event 2 seconds after motion stops, then you would need you delay to be at least 28 seconds (30-2).

Have you tried my customized driver? It should at least give you some space to work with by extending your inactivity timeout.

1 Like

I haven't tried it yet as I am still testing everything out so I am using a ST Motion Sensor but when I install everything then I will be using Konnected with your device handler. I think using your handler will do the trick.

1 Like

The ST motion sensor has a timeout if about 20 seconds I believe. How many GET requests are being generated?

2 Likes