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

confused about setState - can more information be provided? #19

Open
ghost opened this issue Jun 3, 2023 · 2 comments
Open

confused about setState - can more information be provided? #19

ghost opened this issue Jun 3, 2023 · 2 comments
Labels
question Further information is requested

Comments

@ghost
Copy link

ghost commented Jun 3, 2023

Im totally confused about the usage of setState. How do i send an outbound command to the ESP to toggle a switch? The example provided is unfortunately very vague.

I have tried for hours to get it to work in various ways but at best only got all Switches to toggle at the same. I added each entity to an array set as a listener for an event emitter but this never worked properly.

What is the way to send a state change to the ESP board outside of the "entity.on" code block?

can you please provide a functioning example? are event emitters even required for this?

@samhunt
Copy link

samhunt commented Jul 2, 2023

@thwerks setState was not implemented on every entity, so instead I have been using entity.connection.<entityType>CommandService to update the states of my entities.
An example of this would be:

entity.connection.switchCommandService({ key: entity.id, state: true /*on*/ });

which should also translate to the below for your switch (but i don't have a device to test this on)

entity.setState(connection, { key: entity.id, state: true /*on*/ });

@ghost
Copy link
Author

ghost commented Jul 6, 2023

Awesome, Finally, i was really excited to press further with this. Thanks for that, ill check it out next time this comes up in the lab. Much appreciated.

@twocolors twocolors added the question Further information is requested label Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants