zettaios / zetta

0 stars 1 forks source link

Actions on Device Screen doesn't get updated if state changes through external client action. #11

Closed anil614sagar closed 8 years ago

anil614sagar commented 8 years ago

For example, if you use zetta browser to change the state then state gets changed in App but not Action which results in broken experience.

benpackard commented 8 years ago

I think this is related to the enhancement we discussed on our call. The stream gets a new signal from ZettaKit, but it only contains the new value for the updated property, not the full device state.

landlessness commented 8 years ago

The available actions for a device depend on its current state. If a light is in state off then the only available action would be turn-on. Once turn-on is pushed and the state changes to on then the only available action button should be turn-off.

Here is a scenario I am experiencing with a security system on the iOS app. The security system has three states: disarmed, armed-stay and armed-away. If the current state is disarmed then the available actions should be arm-stay and arm-away. If the current state is armed-stay or armed-away then the only available action should be disarm. Whenever an action is pressed and the state changes the available actions should change accordingly.

We will probably want to loop in @mdobson to design the best solution for this issue.

img_1409 img_1410

benpackard commented 8 years ago

Thanks, I'll take a look. I think I get a full updated version of the device in the call back after sending an action, so I'll try that first. I was missing that the device's actions can change not only state, but might be removed or supplemented after a chance.

This won't help with changes initiated from elsewhere though since in that case I only get from ZettaKit the new value for the updated stream, and not the full device state (as we discussed).

mdobson commented 8 years ago

Ben,

The streaming interface should include new actions for devices along with their inputs. I've added this into the SDK drop that will happen sometime tomorrow. This should solve the problem.

-Matt

-- Matthew Dobson | apigee https://apigee.com/ | m: +1.734.634.5472 | twitter @mdobs http://twitter.com/mdobs @apigee https://twitter.com/apigee | Apigee Community http://community.apigee.com/ for answers, ideas and support!

On Thu, Feb 25, 2016 at 2:36 PM, Ben Packard notifications@github.com wrote:

Thanks, I'll take a look. I think I get a full updated version of the device in the call back after sending an action, so I'll try that first. I was missing that the device's actions can change not only state, but might be removed or supplemented after a chance.

This won't help with changes initiated from elsewhere though since in that case I only get from ZettaKit the new value for the updated stream, and not the full device state (as we discussed).

— Reply to this email directly or view it on GitHub https://github.com/zettaios/zetta/issues/11#issuecomment-188945933.

benpackard commented 8 years ago

@mdobson Can you give a little more info about how to get the new actions from the received ZIKStreamEntry? Does it similarly include the updated device properties (I need these for the new state icon)?

When an ZIKTransition is fired, the callback returns a fully updated ZIKDevice - does the ZIKStreamEntry operate in the same way?

landlessness commented 8 years ago

fwiw, the actions are now updating when I fire the transition using the button in the app. but the actions are not updating in the iOS app when i fire the transition from, say, the Zetta browser. so the original intent of @anil614sagar's issue still stands. whereas my comment above has been addressed (by me remembering to call the callback :) ).

mdobson commented 8 years ago

Ben,

This was a gap in the SDK. In the latest drop (0.0.8) being pushed out as we speak I've added a method on ZIKDevice that will allow you to provide a log stream entry, and have a devices actions and properties updated. Method signature below.

-(void)refreshWithLogEntry:(ZIKLogStreamEntry * _Nonnull)entry;

-Matt

-- Matthew Dobson | apigee https://apigee.com/ | m: +1.734.634.5472 | twitter @mdobs http://twitter.com/mdobs @apigee https://twitter.com/apigee | Apigee Community http://community.apigee.com/ for answers, ideas and support!

On Fri, Mar 4, 2016 at 12:51 PM, brian mulloy notifications@github.com wrote:

fwiw, the actions are now updating when I fire the transition using the button in the app. but the actions are not updating in the iOS app when i fire the transition from, say, the Zetta browser. so the original intent of @anil614sagar https://github.com/anil614sagar's issue still stands. whereas my comment above has been addressed.

— Reply to this email directly or view it on GitHub https://github.com/zettaios/zetta/issues/11#issuecomment-192378753.

benpackard commented 8 years ago

Very cool, thanks. But it seems like the stream updates are arriving via the ZIKStreamEntry, not the ZIKLogStreamEntry. For example, from the photocell:

stream.signal.subscribeNext({ [weak self] (streamEntry) -> Void in
    print(streamEntry)
})
stream.resume()
<ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0>
<ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0.0340741737097473>
<ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0.1339745962179103>
<ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0.2928932188027525>
<ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0.4999999999949269>
mdobson commented 8 years ago

That looks like a custom zetta stream for the intensity property. Actions won't come from this stream. Only the intensity value comes down this stream. They will come down the logs stream every time a transition happens. Is a method needed for updating the device for custom streams like the intensity stream?

-Matt

-- Matthew Dobson | apigee https://apigee.com/ | m: +1.734.634.5472 | twitter @mdobs http://twitter.com/mdobs @apigee https://twitter.com/apigee | Apigee Community http://community.apigee.com/ for answers, ideas and support!

On Fri, Mar 4, 2016 at 2:28 PM, Ben Packard notifications@github.com wrote:

Very cool, thanks. But it seems like the stream updates are arriving via the ZIKStreamEntry, not the ZIKLogStreamEntry. For example, from the photocell:

stream.signal.subscribeNext({ weak self -> Void in print(streamEntry) }) stream.resume()

<ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0> <ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0.0340741737097473> <ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0.1339745962179103> <ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0.2928932188027525> <ZIKStreamEntry: photocell/df676540-f126-4c06-bb0b-8a80e7d34982/intensity = 0.4999999999949269>

— Reply to this email directly or view it on GitHub https://github.com/zettaios/zetta/issues/11#issuecomment-192428924.

benpackard commented 8 years ago

No I don't think so right now. I just fired up a Hue Bulb and I'm seeing a log stream come through to the app when I fire an action on the browser, so I think we're good. Going to try updating the device with these streams shortly.

benpackard commented 8 years ago

Working nicely, thanks @mdobson.