Read slider temperature

Hello,
I created a slider temperature with shell command for AC and I created an autmation. When I moved the slider I saw that the automation triggered but I created a file to test if the input data is written in the file but nothing happened.
it’s the configuration.yaml:

input_number:
  ac_temperature:
     name: A/C Setting
     initial: 24
     min: 18
     max: 32
     step: 1

shell_command:
  set_ac_to_slider: echo {{ states("input_number.ac_temperature") }} >  /home/docker/homeassistant/hass_config/kuku.txt

And it’s the automations.yaml file:

- id: 'ac_config'
  alias: 'Apply A/C Configuration'
  trigger:
    platform: state
    entity_id: input_number.ac_temperature
  action:
    service: shell_command.set_ac_to_slider

What I am doing wrong?
Thanks

You could try using the file notification service instead.

instead of what?

The shell command.

It didn’t work

Do you have permission to write to /home/docker/homeassistant/hass_config/?

yes i have.
I think that the problem is in the way I am writing the shell command.

Not if the file notification service didn’t work either. That works for me. Any related errors in the log?

Have you tried quoting the shell command?

shell_command:
  set_ac_to_slider: 'echo {{ states("input_number.ac_temperature") }} >  /home/docker/homeassistant/hass_config/kuku.txt'

Where is the log file?
How I can use the file notification service? I have to delete the shell_command and add this:

# Example configuration.yaml entry
sensor:
  - platform: file
    name: Temperature
    file_path: /home/user/.homeassistant/sensor.json
    value_template: '{{ value_json.temperature }}'
    unit_of_measurement: '°C'

Or I have to add this instead:

# Example configuration.yaml entry
notify:
  - name: NOTIFIER_NAME
    platform: file
    filename: FILENAME

Add the notification service with the correct file path.

Then instead of calling your shell command call the notification service instead.

How I read the data from the slider in the notification service?
There are only 3 parameters in the notification: name, platform and file name

You don’t put it in the notification service config. When you call the notification service you put your sensor state template in the message.

Also the log is in the developer tools.

After I put the notification service, the configuration.yaml looks like this:

input_number:
  ac_temperature:
     name: A/C Setting
     initial: 24
     min: 18
     max: 32
     step: 1

# Example configuration.yaml entry
notify:
  - name: AC tempertaure notification
    platform: file
    filename: AC

What I have to add to the configuartion.yaml file?
Do I have to change something in the automations.yaml?

First you should specify a path for the file In the notification config then change your automation to:

- id: 'ac_config'
  alias: 'Apply A/C Configuration'
  trigger:
    platform: state
    entity_id: input_number.ac_temperature
  action:
    service: notify.ac_temperature_notification
    data_template:
      message: '{{ states("input_number.ac_temperature") }}'

Where i should specify a path? I have to add file_path parameter? Or in the filename?

As there is no file_path parameter it has to be the file_name. But leave it for now and just look for the file in your configuration folder.

I tried without specify a path and nothing happened

Check that this entity id is correct in the developer tools states menu:

notify.ac_temperature_notification

Thank you, It worked for me.
Now I have another question: I want to send in mqtt , messages with codes of my air conditioner. I want that the codes that I am sending will be like the temperature in the slider that I created. How can I do this?
For example, I have the codes of 16 celsius temp for my air conditiner but its a lot of codes that I have to send. I want that when I put the slider on 16, It will send the right code.

You need to map the values of your slider to the codes then send the mapped codes in a template in the mqtt publish service. Have a read of this topic for some ideas about mapping values: