In my home automation (nodered) there is a device that is sending it’s actual state. Within this state there is a property ‘switch’. I.e.: myDevice.state.switch.
‘switch’ is a key word in javascript, so I cannot access it in the normal way. Furthermore I’m not able to change the property’s name, because it is implemented in the device.
As a work around I can access this property by accessing it as an array element, similar to ‘Object.elements(myDevice.state)[1][1])’. This gives me the expected value.
I also can access the property ‘switch’ as a string this way, but I’m not able to change this string in order to change the property’s name.
But is this the only way to access such a (stupid) property? The access MUST be possible without using ‘switch’.