Capabilities / Attributes access at onPoll()

I am trying to update some capabilities/attributes of a device only one time at the onPoll() and avoid reloading them in subsequent calls by cheking whether these are undefined or null, but I always get null (see PowerSource or Temprature), even when they are set by the first onPoll() run. This does not happen with id or name for example? Am I doing something wrong? Are they available? I cannot (or do not know how to) use a variable because I have several devices in the same device source. I attach an image of the code:

Your character casing is wrong. It’s ShellyCloud.Id & ShellyCloud.Name. I don’t see anywhere in this screenshot of you checking if ShellyCloud.PowerSource is null before calling console.log.

Bill, thanks for your reply!

Actually I have an attribute which is “name” I should probably rename it, or just erase it (it is the name of the device in the device itself)…

My point is that PowerSource (which I still use as an attrbute) and Temperature (capability) are always null. Although an attribute I have called “last_time” the first run is undefined and then it is filled. This is why I print them before checking, because they should be filled after the first onPoll call!

This is an example of the console.log::
1st run:
Id = c8b4bd , Name = FloodEra , PowerSource = null , Temperature = null , last_time = undefined

next runs:
Id = c8b4bd , Name = FloodEra , PowerSource = null , Temperature = null , last_time = day 29, 18:03

Many thanks Bill!!

Set it above your console.log line of code.

ShellyCloud.PowerSource = "Mains";
console.log("PowerSource  = " + ShellyCloud.PowerSource);

Bill, I found the problem and actually your initial comment put me on the track…
Apparently HR did not like at all to have an attribute called “name”. As soon as I changed the name of the attribute, PowerSource and Temperature started to work… That was quite strange, but it is good to you know…

I just finished a version of the ShellyCloud plugin which is quite efficient, and it uses one device source instead of a device source for each device…

Now I will do the same implementation for the ShellyHTTP plugin and see if it is even faster…

I will post them when I will be done.
Many thanks Bill, as always :wink:

1 Like