Monitor how many times a switch turning on and off within a time period

Hi, Im quite new in HA automation, i need some help to setup an automation, so basically what i need to do is to monitor a switch On/Off, the automation will trigger when the switch turn on and the condition is within 30minutes if the switch has been turning on and off greater than x number of times then run the action.

Hope someon can help me on this.

Set up a last 30 minute history stats count for your switch.

You can then use this count in a numeric state condition (above x).

1 Like

thanks for the tips. i will look into it.