Closed anil614sagar closed 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.
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.
disarmed
and the two available actions of arm-stay
and arm-away
. arm-away
was pressed. The current state correctly displays armed-away
. However, the only available action should be disarm
but instead we still see the original actions arm-stay
and arm-away
.We will probably want to loop in @mdobson to design the best solution for this issue.
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).
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.
@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?
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 :) ).
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.
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>
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.
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.
Working nicely, thanks @mdobson.
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.