I put the switch-Level in it. 1-dim works normally
And I changed the two-switch-level and child-switch-level, and you will find that the icon is normally displayed as a light,and child devices are also displayed as lights, not switches
metadata:
deviceType: Light
ocfDeviceType: oic.d.light
deviceTypeId: Light
and in the upper right corner setting, Create Single to Device Light2 need to be modified
When I change the default to Yes and add the device again, no independent single device is automatically created. I don’t know whether it is my operation problem or other reasons. The multi switch is the same problem
Have you ever tested?
Only the Child device is created in the infoChanged lifecycle, which calls the do_preferences function.
If you want to change it, you have to duplicate the code that calls the function child_devices.create_new_device(driver, device, "switch2",profile_type) or create a function with the code and call it in the added or init and infoChange lifecycles, so that keep working also when you do it from preferences
Thank you. Although I don’t understand what you mean. But I will try to understand and try to modify and test.
Again, thank you very much for your help!
When you install a device these life cycles are generated and in this order and you can use them to call custom functions or those of the default libraries will be executed:
init
added
doConfigure
When you change drivers these life cycles are generated:
init
added
driverSwitched
When you change a preference this life cycles is generated
infoChanged
When you unistall a device from driver this life cycles is generated
removed
So if you want the child device to be created when you install the device you have to call the code that creates the Child device in the function that runs in the init, added or doConfigure lifecycle
child_devices.create_new_device(driver, device, “light2”,profile_type)
Do you mean to add the above function in 2-dim?
Still don’t understand how to add a corresponding number of child devices in multi switch?
I noticed some strange behaviour wherein for every 2 min approx., the lamp switches off and switches on in a second. Is this something you can help fix?
Thanks for your reply Martin but my case is different because it turns off and turns back on in less than a second so I need to wait for Mariano to reply.
If the sequence @montyfert says doesn’t work for you, you can try uninstalling and reinstalling the device, this seems to have worked for @montyfert with similar issue
I have one question. i have sonoff power meter plug, and installed driver zigbee switch power mc. It works ok, just energy consumption i think is little off. I had 1 hour consumption with power around 20W, and my energy consumption for that is 2.0 kwh. Is this really ok? Thanks