Configuration.yaml saving issues

Hallo everyone, i have home assistant version
core-2021.12.10

supervisor-2021.12.2

i have a problem, i am changing the configuration.yaml and it saves it , there is green flag so all is correct, but if i click on RESTART HASS , it will popup the error “[object Object]” , the changes are saved but not loaded, it happens from several months , the only way to make the changes loaded in the system is to wat for an upgrade … it solved a couple of times…
Even if i manually hardware reset the “home assistant blue” it restart with the old config …
if i go to “server controls” and verify the config it keep thinking and never gives me a reply
If i reboot the server it gives me this error “Invocazione del servizio homeassistant/restart non riuscita. function() argument ‘code’ must be code, not str”
i tried also to REBOOT CORE , SUPERVISOR and nothing happens.
If i REBOOT che CORE, it actually reboot, but the changes in the configuration.yaml are not loaded , it keep the previous settings…
can someone help me ?

I lost my crystal ball, recently.
Could you plainly show your configuration.yaml?

sure,

homeassistant:
  customize: !include customize.yaml
default_config:
cloud:
tts:

- platform: google_translate 
alexa_media:
  accounts:
  - email: !secret alexa_email
    password: !secret alexa_pw
    url: amazon.it
    exclude_devices:
      - "Echo Dot di Mamma"
notify:
  - name: telegram_bot
    platform: telegram
    chat_id: !secret telegrampaoloid

telegram_bot:
  - platform: polling
    api_key: !secret telegrambottoken
    allowed_chat_ids:
      - !secret telegrampaoloid

mqtt:
 broker: core-mosquitto
 discovery: true
 username: !secret mqttuser
 password: !secret mqttpw
 
influxdb:
  host: a0d7b954-influxdb
  port: 8086
  database: homeassistant
  username: homeassistant
  password: test
  max_retries: 3
  default_measurement: state

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

frontend:
  themes: !include_dir_merge_named themes
# Camere Blueiris
camera: !include camera.yaml
    
binary_sensor:
  - platform: mqtt
    name: "Ezvizpollaio Motion"
    device_class: motion
    state_topic: BI/EZvizpollaio
    payload_on: "motion"
    payload_off: "OFF"
    off_delay: 30
  - platform: mqtt
    name: "reolink4x Motion"
    device_class: motion
    state_topic: BI/reolink4x
    payload_on: "motion"
    payload_off: "OFF"
    off_delay: 30
  - platform: mqtt
    name: "front1mp Motion"
    device_class: motion
    state_topic: BI/front1mp
    payload_on: "motion"
    payload_off: "OFF"
    off_delay: 30
  - platform: mqtt
    name: "pollaioext motion"
    device_class: motion
    state_topic: BI/pollaioext
    payload_on: "motion"
    payload_off: "OFF"
    off_delay: 30
  - platform: mqtt
    name: "laghetto motion"
    device_class: motion
    state_topic: BI/laghetto
    payload_on: "motion"
    payload_off: "OFF"
    off_delay: 30
  - platform: mqtt
    name: "v1 motion"
    device_class: motion
    state_topic: BI/v1
    payload_on: "motion"
    payload_off: "OFF"
    off_delay: 30
  - platform: mqtt
    name: "v2 motion"
    device_class: motion
    state_topic: BI/v2
    payload_on: "motion"
    payload_off: "OFF"
    off_delay: 30
  - platform: mqtt
    name: "laterale motion"
    device_class: motion
    state_topic: BI/laterale5mp
    payload_on: "motion"
    payload_off: "OFF"
    off_delay: 30    
    
sensor:
 - platform: emoncms
   api_key: !secret emoncmsapi
   url: http://192.168.1.100/emoncms
   scan_interval: 60
   id: 1
   exclude_feed_id:
    - 32
    - 33
    - 34
    - 35
    - 36
    - 37
    - 39
    - 43
    - 59
    - 62
    - 63
    - 64
    - 65
    - 66
    - 67
    - 68
    - 70
    - 71
    - 77

##    - 4
## - platform: emoncms
##   api_key: !secret emoncmsapi
##   url: http://192.168.1.100/emoncms
##   scan_interval: 60
##   id: 2
##   unit_of_measurement: "W"
##   include_only_feed_id:
##      - 4
##   sensor_names:
##   4: "prova prelievo"
 - platform: systemmonitor
   resources:
      - type: memory_use_percent
      - type: memory_free
      - type: memory_use
      - type: disk_use_percent
        arg: /home
      - type: disk_use
        arg: /home
      - type: disk_free
        arg: /home
      - type: load_1m
      - type: load_5m
      - type: load_15m
      - type: processor_use
      - type: processor_temperature   #  non funziona 
      - type: last_boot
      - type: swap_use_percent
      - type: swap_use
      - type: swap_free





#######################################################################################################################
## Package - Unavailable Entities Sensor - Count and list of entities with state of unavailable, unknown, or none (null)
## NOTE: Home Assistant v0.117+ is required
#######################################################################################################################

## REQUIRED this is the template sensor
## state: number of unavailable entities
## attribute - entities: comma separated list of unavailable entity ids

 - platform: template
   sensors:
      unavailable_entities:
        friendly_name: Unavailable Entities
        unit_of_measurement: entities
        icon_template: "{{ 'mdi:check-circle' if is_state('sensor.unavailable_entities','0') else 'mdi:alert-circle' }}"
        value_template: >
          {{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group')
            |rejectattr('entity_id','in',state_attr('group.ignored_entities','entity_id'))|list|count }}
        attribute_templates:
          entities: >
            {{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group')
              |rejectattr('entity_id','in',state_attr('group.ignored_entities','entity_id'))|map(attribute='entity_id')|join(',') }}

## REQUIRED add any entities you do not want to monitor in this group.
## This group MUST exist even if is empty for sensor template to render.


switch:
  platform: mqtt
  name: "Sonoff Mini"
  command_topic: "cmnd/sonoffmini01/power"
  state_topic: "stat/sonoffmini01/POWER"
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  retain: true

rest_command:
  porta_pollaio_apertura:
    url: 'http://192.168.1.24/go?angle=90&d=1&s=1'
    payload: "apertura"
  porta_pollaio_chiusura:
    url: 'http://192.168.1.24/go?angle=90&d=2&s=1'
    payload: "chiusura"

# xiaomi_aqara:
#   discovery_retry: 5
#   gateways:
#     - key: F58C037458444ED0

# xiaomi_aqara:
#   interface: '192.168.1.172'
#   gateways:
#     - mac: 50EC50C51DB7
#       key: F58C037458444ED0
 
#alarm_control_panel:
#  - platform: manual
#    name: Home Alarm
#    code: 1234
#    pending_time: 30
#    delay_time: 20
#    trigger_time: 4
#    disarmed:
#      trigger_time: 0
#    armed_home:
#      pending_time: 0
#      delay_time: 0
#  alarm_control_panel:
#  - platform: template
#    panels:
#      safe_alarm_panel:
#        value_template: "{{ states('alarm_control_panel.real_alarm') }}"
#        arm_away:
#          service: alarm_control_panel.alarm_arm_away
#          data:
#            entity_id: alarm_control_panel.real_alarm
#            code: !secret alarm_code
#        arm_home:
#          service: alarm_control_panel.alarm_arm_home
#          data:
#            entity_id: alarm_control_panel.real_alarm
#            code: !secret alarm_code
#        disarm:
#          - condition: state
#            entity_id: device_tracker.paulus
#            state: 'home'
#          - service: alarm_control_panel.alarm_arm_home
#            data:
#              entity_id: alarm_control_panel.real_alarm
#              code: !secret alarm_code


climate:
- platform: generic_thermostat
  name: Riscaldamento
  heater: switch.dualthermostat1
  target_sensor: sensor.emoncms_giorno
  min_temp: 19
  max_temp: 25
  ac_mode: false
  target_temp: 22
  cold_tolerance: 0.3
  hot_tolerance: 0.3
  min_cycle_duration:
    seconds: 5

This is not properly indented

thanks, i reconfigured Alexa and now all seems work.