How to capture current state of Hue bulb in Rule 4?

I need to refresh Hue hub devices, to update the state of a bulb that is managed outside of HE. Just use HE to control it is not a solution. I force a refresh on the Hub device, and the the refresh works, but I need to wait for the refresh event to complete. How do I wait for the refresh to complete within rule machine, before executing the next event within the rule. Waiting for 1 or 2 seconds is inconsistent, and a much longer delay than necessary.

I have a question...what do you have the refresh rate set to inside the Hue Integration?

image

I never have to manual refresh, mine update within 10 seconds. When you are trying to do a capture, you're trying to capture the change made outside of HE or react to it? I'm confused.

It was set to 1 minute, but I disabled it for testing, and I can issue a refresh, and get the new values. The problem is I need to know when the refresh is completed, because refresh is an async process, and can take varying lengths of time. Most often, it will be completed in less than a second. If it finishes in 10 milliseconds, that is still to slow for the following capture state action, and waiting 1 or 2 seconds, is too much delay.
The trigger is opening a door, and the action is turning on a lights, and setting the color to white. The problem is there are other systems talking to the light when the door is closed, and I need to set the state back where it was. This should be a simple enough action.

If you want the lights white when the door is open, aren't you worried about this other system issuing a command to set it some other way while the door is open?

I appreciate you want to help, but This has nothing to do with answering my question. You are trying to understand the reasoning for the rule, but what I need a answer to the question asked. The reasoning to the rules are sound. We are migrating a system, and these were the same conditions on the old system.

When the door is closed, the light should be whatever the room occupant wants, when it is opened up we capture the state, then set it to white and 100%, when the door is closed, we put the light back. If the occupant changes the light while the door is open, so what? I don’t care. It happens while the door is open, and what happens while the door is open is thrown away, and we restore the state for when the door was closed. For now, must leave this remote system in place, and cannot replace it with HE.
Which goes back to my original question, which really has absolutely nothing to do with Hue, it has to do with the refresh action, and waiting until the refresh is completed.

While not elegant, you could simply add a delay of a second or two after you issue the refresh command. You are absolutely right, it is an asynchronous operation with no feedback. That only leaves you with the time delay path. The downside is that the users might notice these delays

Which is exactly what he said he's doing but doesn't want to do.

Unfortunately what you're trying to do isn't possible. You can't tell when the refreahbia complete. That's why I was trying to help you find an alternative.

Yep, you are right, he said that... I should have a coffee in the morning before I start answering questions....

Edit: The only other option I see is a custom app coded in groovy.

You subscribe to the event of the door contact, send the refresh command to the bulbs and listen to the events of the bulbs. Once you get an event you can capture the states and restore them when you want. It has to be checked though if an event gets send all the time on a refresh or not. This could make this here fail if it doesn’t. You would need to remember in your code when you issued the refresh and are in your routine otherwise you would react to any change of the bulbs. There are quite a few edge cases you need to work out as in not receiving a response at all.

Your use case sounds simple but it really isn’t. Especially having other systems involved. That makes it so much harder.

Your use case sounds simple but it really isn’t

Agreed. I know if I write a custom map that sends the necessary labor quest to generate the refresh event that I could capture when it is complete and then carry out my actions upon completion. This, however, it’s sort of like building a new house because the front door doesn’t work right.

You could always use a different door... or translated.... Use only one system to change colors and that would solve the problem too.

The devil is as always in the details. Rule Machine is powerful but there are occasions where it makes absolutely sense to code a custom app.

Thanks. I am a developer, I understand the issue and and how work around them.

It also would be very simple in the HueBridge driver to produce an event of refeshComplete, then in the rule manager, we could issue a wait for event (refresh complete). ... or it could be there is such a hook already and we just don’t know it.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.