Python_script to save and restore switches and lights

I don’t think all lights support the transition turn_on parameter, but you could try changing:

                if component == 'light' and turn_on and old_state.attributes:
                    service_data.update(old_state.attributes)

to something like:

                if component == 'light' and turn_on:
                    service_data['transition'] = 3
                    if old_state.attributes:
                        service_data.update(old_state.attributes)