How can I use a string as an attribute.
Posted: Saturday 11 August 2018 16:50
Hi,
I started working with dcVents a couple of days ago. I love it, but I want to do something with reading a devices attributes and don't know how to.
In a function, I parse through a variable with the names of devices I want to read. That works well, but from some devices I want to read the state and from others I like to read a value like current or color or whatever.
So, I read the devices description and in the first line, I wrote the name of the attribute I need to read.
Lets assume I have a switch named Switch1, of which I want to read the nValue.
I can turn the string 'Switch1' into a device with MyDevice = domoticz.devices('Switch1')
When I read the descriptiption I can put the desired attribute into another string like MyAttrib = MyDevice.description. That works fine, but MyAttrib is not a real attribute, so MyValue=MyDevice.MyAttrib does not work.
Is this possible at all?
Thanks,
Bert
I started working with dcVents a couple of days ago. I love it, but I want to do something with reading a devices attributes and don't know how to.
In a function, I parse through a variable with the names of devices I want to read. That works well, but from some devices I want to read the state and from others I like to read a value like current or color or whatever.
So, I read the devices description and in the first line, I wrote the name of the attribute I need to read.
Lets assume I have a switch named Switch1, of which I want to read the nValue.
I can turn the string 'Switch1' into a device with MyDevice = domoticz.devices('Switch1')
When I read the descriptiption I can put the desired attribute into another string like MyAttrib = MyDevice.description. That works fine, but MyAttrib is not a real attribute, so MyValue=MyDevice.MyAttrib does not work.
Is this possible at all?
Thanks,
Bert