Switches Call service does not fire correctly

hello everybody,
I have written a piece of code inside appDaemon that should align HA from another system to avoid misalignments in case of reboots and so on.
the strange thing is that it seems to do nothing when code call service for turning switches on or off.

I use the developer tools to set the state of a test switch to xx but nothing change when I run the code even if from the log it (apparently) seems to be a correct flow.

Can anyone help?
here the python code:

for HAswitch_id, HAswitch_info in all_HAswitches.items():
    if HAswitch_id == "switch.sw_ave_" + AveidLuce:
        HAswitch_state = HAswitch_info['state']
        if HAswitch_state != AveStato: 
            self.log(f"AVEidLuce {AveidLuce};  AVEstato {AveStato}")
            self.log(f"HAswitch.id {HAswitch_id};  HAState {HAswitch_state}")
            if AveStato == "on":
                self.turn_on(HAswitch_id)
                self.log("called turn_on service")  
            else:  
                self.turn_off(HAswitch_id)
                self.log("called turn_off service")  

the log :

2023-11-02 17:19:21.108963 INFO synch_ha_from_ave: AVEidLuce 22;  AVEstato off
2023-11-02 17:19:21.117495 INFO synch_ha_from_ave: HAswitch.id switch.sw_ave_22;  HAState xxx
2023-11-02 17:19:21.129058 INFO synch_ha_from_ave: called turn_off service