Better Way to Turn Off a bunch of zwave lights/switches at once?

So I have a goodnight app that I execute when I go to bed via an input Boolean. Right now I have a function to turn off all the lights that has about 30 zwave switches in it. When I execute it, it takes a little while before it starts to turn off the lights. What I noticed though is that if I shut off the lights one by one by one manually in HA its very fast, so I was wondering 1) should i have the lights listed like this directly in the app or should I try to use a 'good night light group and 2) should I do something else to try and make this more efficient?

Sample code:

    def turn_off_lights(self, entity, attribute, old, new, kwargs):

I would try a HA scene, which turns off all this entities.

I had something similar that turns off some devices when I go to sleep and it was faster with a scene then turning them off one by one.

I think it will take to group the devices wanted to turn off at once.

I turn off large groups of lights through AppDaemon and I don’t notice any delay.

I don’t use self.turn_off() though. I use self.call_service(‘light/turn_off’,entity_id=‘thing’).

A few things to check/do…

If AppDaemon is connected poorly to Home Assistant, there will be some delay. Probably you have them running on the same server, as most people do. Make sure AppDaemon is not using an external URL to access Home Assistant as this could slow it down.

If you use self.call_service (and maywith with self.turn_off, too, I don’t know) you can pass a list of entities for entity_id. This will allow the lights to turn off in one round trip to Home Assistant instead of one for every light you have. I don’t do this, but it can be done and will effectively be the same speed as you’d get turning off a group from AppDaemon.

I do not, however, turn off large groups of ZWave lights. There may be some additional delays involved with that that I’m not aware of on the Home Assistant side. But, if you’re passing a list of entities to call_service, it’ll be as fast as calling turn_off on the group. The only way you’ll be able to get any faster would be to take AppDaemon out of the equation entirely or find out if there are system/network delays between AppDaemon and Home Assistant.