Is there any chance of having PowerOn option on built-in driver Generic Zigbee Dimmer to control state after a power loss?
I believe the answer you will get is that such functionality belongs in the device. If the device doesn't support it, the driver's purpose isn't to add missing functionality.
But that's just my guess.
The point is that the function is there, at least in the tuya hub.
A device might or might not support that command. There would likely have to be drivers for every single device to allow that capability. While that is possible in theory, in reality your supported device list would get smaller as there just isn't enough staff time to write hundreds of new drivers and test every device once a driver is written.
Instead, you can write a rule that checks lamps after the hub boots, and turn on/off things as you wish. You would need a trigger of Location in Rule Machine, and off the top of my head the particular value is SystemStart under the Location trigger.
I have a piston using Hub Ping that detects router power loss and shuts down my Hub. When it reboots I have another piston that runs on system start and turns off all the ZB bulbs as they default to on after a power outage.
So this option is specific per device and not per category?
I'm aware of workarounds, but that's not what I'm searching for.
Ideally every device should fall in the last state after power loss.
Yes. The device has to support the function as when it recovers power it will startup and do certain actions. This is generally a issue with Bulbs, and those devices always have this setting on the bulbs themselves if it is configurable.
Some bulbs like Philips Wiz Connected Bulbs give you the option to have different behaviour when power is restored incase you have them on a power circuit controlled by a dumb switch. So the assertion that they should always go to last state may not be valid for everyone, or for all the time.
The only two categories i think this is ability is important is on switch type devices and bulbs. I think every switch device i have supports this request. The limited smart bulbs i have do as well, but I will admit i don't have many of them.
As I suggested in my comment above, the question is not whether a driver could do this, it is a question of whether it should.
The driver should expose the functionality of the device. If the device itself supports power on state, then the driver should make that functionality available. But it is beyond the scope of a driver to add that functionality if it doesn't exist in the device already. Maybe it could (except how would it necessarily know if the device experienced a power fail, but I digress), but it also could add flashing, turning off at sunset, etc. At that point it isn't a device driver; it's an app. And that's where the apps come in .. you could add this functionality via an app (e.g., Rule Machine).
Never mind. I didn't think I was covering philosophical topics of programming. Thanks for the answers.
maybe, but opinions vary on this topic, and it is device dependent to a certain extent. Take bulbs for example, Most of them default to turning on after power restore, which sort of makes sense from a safety perspective.
In the end you're better off building a rule/app to to with these what you want after power is restored.
I cannot think of other devices besides bulbs (abomination) that requires to be always on, but in any case they are surely a minority. Following the logic of restoring the last state is natural and should be a given.
As I wrote, it was a function present in most of my devices when I used the tuya hub, in this case a led switch/dimmer (FUT036Z)
As for workarounds, my router and hub are under ups, so I cannot use them as variables in the rules. Using a third party driver with the presence variable (also stressing the hub I think), this is not updated frequently enough to intercept the power loss if less than a few seconds (almost always).
you can get a ring range extender which will report battery/mains via the power source capability.
I had this on all my device that supported it but actually when you get a power cut for a number of hours having them turn back on in the middle of the night is not fun. No all bedrooms lights are set to power up to off.
One of the reasons for having the selectable option. But at least the default should still be restoring last state.