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

Document connecting, open, close, error, states_loaded, services_loaded events. #75

Closed
Swamp-Ig opened this issue Jan 13, 2019 · 5 comments

Comments

@Swamp-Ig
Copy link

Swamp-Ig commented Jan 13, 2019

When node red first boots up, sometimes it's good to set up some state in HA. There's a delay however between node red firing up and HA being ready.

One example of how this would be used is to set up stuff based on the time of day, where you'd want to initialise everything on connection.

Describe the solution you'd like
A connection state node, outputs topic.connected when connected, and topic.disconnected when disconnected. Each of these messages could possibly be optional.

It might also be an idea to have a list of entities that have to have their state available before the connected gets fired. This would work well for example with z-wave entities that can take a little while to boot up.

I can possibly contribute this myself, I've got some time off work coming up in a few weeks.

@Swamp-Ig
Copy link
Author

Swamp-Ig commented Jan 13, 2019

I just had a poke through the source code, I realise now that there's connecting/open/error/close events, plus states_loaded and services_loaded as well.

I guess these could be documented better. I can see a use case for a specific node for these messages maybe.

@zachowj
Copy link
Owner

zachowj commented Jan 14, 2019

One example of how this would be used is to set up stuff based on the time of day, where you'd want to initialise everything on connection.

I'm not totally following what you mean here.

A connection state node, outputs topic.connected when connected, and topic.disconnected when disconnected. Each of these messages could possibly be optional.

Right now it's pretty easy to set up the connecting/open/close events using a status node. Handling the states_loaded could be done with any dummy entity connected to an event-state node. Not really that user-friendly but it could get the job done.

If you wanted to do this I would like to see it work for all the current and future event types. That way we're just not adding a node that can be replicated with a couple already existing nodes.

@Swamp-Ig Swamp-Ig changed the title Node that fires on connection/disconnection to HA. Document connecting/open/close/error/states_loaded/services_loaded events. Jan 14, 2019
@Swamp-Ig Swamp-Ig changed the title Document connecting/open/close/error/states_loaded/services_loaded events. Document connecting, open, close, error, states_loaded, services_loaded events. Jan 14, 2019
@Swamp-Ig
Copy link
Author

I'm not totally following what you mean here.

Just in general: once the HA connection is up and running, then do certain actions. Basically initialisation for the flow.

I'll use an example: I've got an aircon unit that I want to be set a certain way at particular times of the day. I can wait for the time to change using something like a cron node, but say HA goes down past the transition time then I'd want to set it up when we boot up again.

I think you're right that the existing nodes will do the job, although how to do this wasn't documented and it wasn't until I looked through the source code that I found those messages being generated.

Happy to do the work for you in a couple of weeks if you want.

@Swamp-Ig
Copy link
Author

Swamp-Ig commented Jan 14, 2019

I checked it, the events-all node won't pick up open events, I haven't tested close or error specifically however I don't expect those will work either. If you specifically request services_loaded the message that gets sent doesn't contain a topic, only the data. You can use the status like you suggested, this works if you check the status of an events-all node and set it's event to some dummy value.

This is easy enough to encapsulate in a subflow I guess.

@stale
Copy link

stale bot commented Feb 28, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 28, 2019
@stale stale bot closed this as completed Mar 7, 2019
@zachowj zachowj reopened this Mar 9, 2019
@stale stale bot removed the stale label Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants