Homey Community Forum

Read a capability with a dot in the name

I would like to read the current for one of three phases. The capability has a dot in the name so I would like to write something like:

var current = Watty.capabilitiesObj.‘measure_current.L2’.value;

But that is not possible. Giving me error message:
Unexpected string: Unexpected string

Also this isn’t possible:
var current = Watty.capabilitiesObj.measure_current.L2.value;
Give me error message:
“Cannot read property ‘L2’ of undefined”

How is the syntax for reading the capability with . in name?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors

var current = Watty.capabilitiesObj[‘measure_current.L2’].value;

Works perfect, thanks.