Is it okay to save data only when user leaving screen?

I'm designing an app that controls a connected object.

In one of the screens of the app, the user can activate or disable a nightlight and set the hours of lightning (e.g. 8pm - 7am).

In the first version, the app developers coded the screen so that the data is sent to the server only when the user has leaved the screen. Thus, if the user wants to switch on the nightlight immediately, he will have to leave the screen to see the nightlight switching on.

enter image description here

In my opinion, the user might think that the object is not correctly connected and that the parameters have not been saved.

What are the best practices for that type of usage? These are the options I was thinking of:

  1. Option currently coded: Saving data when user leaves the screen
  2. Option developers don't like for server consumption considerations: Saving data each time the user change a parameter in the screen (e.g. disable or change the hours)
  3. Adding a button to save the data