Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It all happens too fast! #2

Open
disruptivepatternmaterial opened this issue Jul 25, 2023 · 4 comments
Open

It all happens too fast! #2

disruptivepatternmaterial opened this issue Jul 25, 2023 · 4 comments

Comments

@disruptivepatternmaterial

The signal to ok happen so quickly that if you trigger an automation in HA, the value is no longer in the sensor. I am wondering if there is a way to put a delay in between the signal of the push and the ok message.

@disruptivepatternmaterial
Copy link
Author

disruptivepatternmaterial commented Jul 26, 2023

I made this change...

	console.log(btntopic+"/battery:  \t"+button.batteryStatus);
	sleep(2500);
	mqtt.publish(btntopic + "/action", "ok");
});

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

@id628
Copy link
Owner

id628 commented Jul 27, 2023

Why do you find a delay to be necessary?

My Home Assistant actions are activated on the transitions, so I'm not sure why you would want to check state if it's the state change that caused the event?

@id628
Copy link
Owner

id628 commented Aug 4, 2023

Now that Home Assistant 2023.8 will have UI-enabled Event triggers, I'm thinking of supporting those in the next release. That should hopefully be a better fix than adding delays.

@disruptivepatternmaterial
Copy link
Author

Why I want this is because in my setup it happens so fast that by the time an automation is triggered the value of the button has returned to ok after about 1-2 steps. To make my life easier I created component automations that branch on the value...of it is just "ok" they dont work and it makes my scripts way more complex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants