athombv / homey-apps-sdk-issues

This issue tracker is for Homey Developers using the Apps SDK.
20 stars 4 forks source link

Tag is value is not available as argument in trigger #204

Closed magtimmermans closed 1 year ago

magtimmermans commented 3 years ago

Hi, I have a trigger card and someone entered a tag as an argument. So the state.offset (in my case) get's an object and how can I retrieve the value behind this?? let rainStartTrigger = new Homey.FlowCardTrigger('rain_start'); rainStartTrigger .registerRunListener(( args, state ) => { args, this is the user input the state parameter, as passed in trigger() // If true, this flow should run return Promise.resolve( args.offset === state.offset); }) .register() I get as state.offset : '[[homey:manager:logic|034e762c-da6f-4345-8a31-0508f9ae37b9]]'? but I expect a number... Is this a bug as I expect that homey will parse this? (SDK-2 by the way)

RobinBol commented 3 years ago

Hi @magtimmermans, thank you for reporting this issues. It indeed seems to be a bug. Could you please provide some more information about how and when this bug seems to occur? Perhaps you could share your Flow.

WeeJeWel commented 3 years ago

@RobinBol I think this happens when the Logic Variable has been deleted, but the variable's tag is still used in the Flow card's argument. Should be easy to reproduce.

RobinBol commented 3 years ago

Yes tried that but could not reproduce, in my test case the Flow card action is not executed but gives an error (flowtoken_not_found).

magtimmermans commented 3 years ago

Hi,

The flow token was their. It was from the logic and was used in my Sunevents app. Sdk 2 homey 6 release.

image

This logic var was not a number when getting it as state back.

RobinBol commented 3 years ago

@magtimmermans could you share the exact Flow with which you have experienced this issue?

magtimmermans commented 3 years ago

It is whenever I use a trigger with a tag value. This is for example with the sunevents app.

tjallingt commented 3 years ago

I'm going to close this because we currently don't have enough information to reproduce this issue. If you are still experiencing this please open another issue with a description of the specific apps, devices and Flows that trigger this issue for you.

magtimmermans commented 3 years ago

Please re-open. I am using the function of FlowCardTrigger object: https://apps-sdk-v2.developer.athom.com/FlowCardTrigger.html#getArgumentValues

Walking to the arguments gives me and object instead of the value.

tjallingt commented 3 years ago

Can you share a complete code example? The one you've shared before doesn't include getArgumentValues()

tjallingt commented 3 years ago

Okay I managed to reproduce the behaviour, but this is a very tricky issue.

In some ways this behaviour is intended: FlowCard#getArgumentValues() works together with FlowCard.on('update') so that you can retrieve the values that are passed to your Flow card. However if you are using a token this value can change without an "update" event to notify your app of this change.

Additionally there are "local Flow tokens" where the actual value is only known when the Flow is run. So there is no way FlowCard#getArgumentValues() can return a value in that case.

This is somewhat problematic because Apps may expect getArgumentValues() to always return the actual values and not the "Token URI". Especially if the argument is a string this can cause unexpected behaviour that would be very difficult to work around.

This is something we will discuss further internally, thank you for reporting and your patience 🙂

magtimmermans commented 3 years ago

Great you found it. I am also happy with another function that can get the details on the result of getArgumentValues().

Joost2 commented 2 years ago

I encountered this issue (a valid variable is not taken into account by the Solar Events app) and it's a real limit... The Flow I generated is the following: WHEN event "nadir" with offset (variable in minutes, entered as 780 without any other flow calculating it, for test-purpose) THEN send a notification Won't work. If instead of (variable in minutes) I directly enter the same value, it works fine

image
magtimmermans commented 1 year ago

Why is it closed? In which release is this fixed?

jeroenwienk commented 1 year ago

Why is it closed? In which release is this fixed?

This is the way it works some tokens have runtime values so you would never get a value from that in getArgumentValues and this is not something we can fix.

If it was a logic var how would your app even update if the var changed?

magtimmermans commented 1 year ago

2 years ago it I defined as a bug. Abd suddenly it works as expected?? I expect that when I use thi function I got the current state of this tag.

If this isn't working it should also not be possible in the ui.