Hi,
I would like to press a button to increase a variable and when this variable equal 2 launch and automation.
How can I do that ?
thank
Hi,
I would like to press a button to increase a variable and when this variable equal 2 launch and automation.
How can I do that ?
thank
What is the button connected too? Wifi / mqtt / gpio
the button is a dummy in hassio.
you have a switch entity on the front end through lovelace?
there is a short and long press in lovelace that might work
Yes I would like to have a switch/button in Lovelace and when someone push it increment a variable / counter.
Then when the variable get a specific value launch an automation
Exemple:
People 1 click - nothing
People 2 click - nothing
People 3 click - send notifications
Reset the variable to 0
You can use the counter component to count the number of clicks with an automation
counter:
my_custom_counter:
trigger:
#this will change, I have no idea how you see the clicks.
- platform: state
entity_id: whatever.whatever
state: 'click'
action:
- service: counter.increment
entity_id: counter.my_custom_counter
#this condition will only move forward if the counter is above 2.
- condition: numeric_state
entity_id: counter.my_custom_counter
above: 2
- service: notify.notify
data:
message: '3rd click'
- service: counter.reset
entity_id: counter.my_custom_counter
Thank your for your helps.
I came from domoticz.
I domoticz you have dummy bouton for your UI.
Your code seen ok for what I need but I don’t know how to see the click. Should have a script to increment the counter and if the counter have a certain value launch an automation ?
thank again.
is it easier with mqtt ? but how to create a dummy to publish on topic ?
Oh, you just want a UI dummy interface item that does this?
Thank for your help! It’s working
Sorry if my initial demand was not clear
Configuration.yaml
#counter
counter:
yep_counter:
initial: 0
step: 1
script.yalm
yep:
sequence:
- service: counter.increment
entity_id: counter.yep_counter
and an automation:
- alias: 'Yep ON'
trigger:
platform: numeric_state
entity_id: counter.yep_counter
above: 2
action:
- service: notify.pushbullet_lionel
data_template:
title: "YEP"
message: "YEP"
- service: counter.reset
entity_id: counter.yep_counter