SendEvent not updating

I am using sendEvent to load json data to a series of attributes. The SendEvent command grabs the correct json value and updates my current states, but the attributes remain empty (null) in the driver.

In the code below, the log shows the json value as 0 and the attribute as null. The device's current state also shows the attribute correctly at 0.

From the log file:
USBOutput_Enabled=null
json=0

What is going on - should I be using a different command like ProcessEvent to load the attributes?

Do you have these custom attributes defined somewhere? Also, I'm not sure spaced are valid (convention is camelCase, though underscores like you have also work), but that is unlikely to be this particular problem.

It seems like it's my lack of understanding of what the sendEvent is doing or not doing in my situation. If I add another line of code to set the attribute directly, as shown below, I can use the attribute in my code.

USBOutput_Enabled = jsonpl.data.quotaMap."pd.dcOutState"

So, I need a sendEvent line to update the device status AND a "set equal to" line to define the variable in my driver if I want to use it in my code.

No, variables are not the same as (not do they get automatically created as fields or similar from) attributes. Attributes must be accessed on the device in a way like currentValue("attributeName"). These are the same attributes you'd be updating with sendEvent(name: "attributeName",...). If that is not what you're doing, that could alao explain the problem.

Yup - I'm all set now. I was not making a distinction between variables and attributes. All part of the learning experience. Thanks!

1 Like

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