Rule Engine device value to variable

What am I missing here? The flow does trigger, when I test it with manual input in execute the variable changes, so the trigger does see the value. However I want the variable to change to the value of the HomeyDevice. This doesn’t happen. Thanks!

The rule in the screenshot could be interpreted as:

When a 'devicecapabilitiesText' event comes in for 'HomeyDevice (Test 1)'
If the value of the event is 'test'
Then set the SharpTools variable $TestVariable to that value*
Technical caveat on setting variable from device state (tap to expand)

*In your rule, the action sets the variable based on the current device attribute value, so with fast updating attributes, it’s possible the device triggers the rule with one value, but by the time the rule action runs and it queries the device for it’s current value, the attribute state could have changed

It will only trigger when attribute updates and is 'test' thus it will always set the SharpTools variable named $TestVariable to 'test'

Updating Variable From Event

If you wanted to update the variable based on any event value coming in from the device, you could:

  • Update the trigger to a generic changes trigger (with no value specified)
  • In Set Variable, use another variable as the source so you can use the Context Variable > Event Value ($context.event.value)

The context variable approach is particularly unique in that you can access the event value that triggered the rule

Controlling Homey Device

If you want to change the value of the Homey Device, you would need to use a Device Command for your rule action that is capable of updating the device value.

For a normal device like a dimmer, this would be something like setLevel(50), but devices don’t always expose a command to update each attribute as with real devices some things can be actuated (like a light) whereas some things are read only sensors (like temperature).

If it’s a generic settable String value from Homey, you might find a setHomeyString() command that can be used.

1 Like

Thanks for the very detailed reply @josh, solved it using the ($context.event.value ).

1 Like