[esphome] Slider to select a value

Hello. I’m completely new to Esphome, as well as to any programming language. In general, I just can’t find information on how to create a slider in the device interface so that I can select the value I need live, so to speak, and not rewrite the firmware hundreds of times with a new value.

For example, I simply control an LED strip via “monochromatic”, I want to select the value “gamma_correct”.
Or I control a PC fan depending on the temperature from the Dallas sensor and, for example, I want to select two values ​​within which it will turn on…

In general, we need some very basic example of creating a slider and passing this value. This is an example, not a specific solution for a specific situation.

Take a look at the template number component in ESPHome.

Do you think I didn’t see this? I’m asking for an example of a working slider that does something with another sensor, device, etc., and not just how to create it, if I write this I’ll just get a slider that does NOTHING.

I was on my phone and didn’t have an example ready. I’m not going to give you one now though. Not with that attitude.

5 Likes

You have to tell it what happens when the slider is moved. It explains how to do this is the documentation for the link you were given. It also gives you examples to visually see how. You have to read through it and what configuration options are available and what they do.

Right here is a very simple example that shows you how to take the number and use it to set a lights color and brightness.

Sometimes there isnt always an example that 100% matches what you want to do and thats why its critical to read the docs, not just scroll through it looking for a copy/paste example. Its just not realistic to have an example for every possibility.

1 Like

You know, it’s a lot of fun to sort through a bunch of different pages in a language that I don’t know at all. English is not my native language, I have to translate each page from the beginning, and then try to understand what was originally written there, because… The translator often breaks a lot of words.
Considering that I am still completely unfamiliar with ymal coding, my task becomes simply impossible. Is it really so difficult to just tell me how to change the value using the slider (gamma_correct: 1.4), I at least understood what to look for and what to base myself on.

You said you could not find the information, the answer was where you could find the information. Why do you respond in anger?

Then someone tries to gives you a generic example how to use the value. Like you asked. You even asked not to give a solution for a specific problem. But then you seem to expect a tailor made piece of code for your use case.

It is also (not) a lot of fun to put time in answering a question, and get an angry response in return. The people here are honestly trying to help. They do not get payed for their time here. They do not know how well you understand English either. They to are probably not native English speakers. I am Dutch myself.

It is ok to ask followup questions if the first answer is not clear enough, but please do so without capital letters (they are interpreted as yelling), and be understanding if it is not exactly what you hoped for on the first answer.

3 Likes

I’m just asking for an example where there is a slider that does something, as I understand it, its value should be written to some variable, I don’t understand how to do this and how to pass this value to another object whose value I want to change, Is it really impossible to write an example that would help me understand what to grab hold of and what to look for in Google? Why should I post links to a wiki in which in 99.9% of cases there is no example, the maximum that is there is a description of the basic parameters, the rest is not clear where to look.

alias: Water Plant pump 1
sequence:
  - service: mqtt.publish
    data:
      topic: solarplantwatering/ota_mode
      payload: "ON"
      qos: "1"
      retain: true
  - service: mqtt.publish
    data:
      topic: solarplantwatering/sleepearly
      payload: "OFF"
      qos: "1"
      retain: true
  - wait_for_trigger:
      - platform: mqtt
        topic: solarplantwatering/available_mode
        payload: online
    continue_on_timeout: false
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.solarplantwatering_plant_watering1
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - delay:
      hours: 0
      minutes: 0
      seconds: "{{ states('input_number.solar_pump_1_time') | int }}"
      milliseconds: 0
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.plant_watering1
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 100
  - service: mqtt.publish
    data:
      topic: solarplantwatering/ota_mode
      payload: "OFF"
      qos: "2"
      retain: true
  - service: mqtt.publish
    data:
      topic: solarplantwatering/sleepearly
      payload: "ON"
      qos: "2"
      retain: true
mode: single

OK, here is an automation that uses the sliding bar. When triggered the automation turns on a switch. Depending on how low the bar is set to how long before the automation turns off the switch again.

Screenshot 2024-07-23 232641

I’m pretty sure they’re looking for an ESPHome config example…

The switch is one esphome device. The slider has to be shown in HA in a card.

honestly… yes))) I expected to see at least something similar to this
Changing ESPHome slider value in frontend
I don’t even see the word “slider” here. There’s just some kind of automation logic.
This topic is the only thing I could find that is more or less similar to my task, but I still don’t understand how the value is transferred from the slider to some device to change brightness, speed or some other basic values.

slider is just one of the options for a number’s display mode. It can be found in the configuration of the number entity at the mode variable:

image

“Automation logic” is exactly how the value is transferred from the number entity to other components of the device to change brightness, speed, etc.


Oh, that’s what was meant. Turned out to be much easier than I thought.

Not only did I show you one of the examples that does EXACTLY that but, you’ve been given the link which has many more examples to look through.

Im not 100% positive but I don’t think gamma_correct is even able to be variable like other configuration options are. What exactly are you trying to achieve by having a variable gamma correct? It’s not a very common configuration that needs to adjusted in my experience. Are you absolutely sure it’s gamma correct that you need to change to get the light effect you want?

In the very first message I wrote that I need to select the frequency and gamma correction, but I want to do this in real time, and not rewrite the firmware many times and wait for the device to reboot.
scr_25_07_2024_21_48_15

I don’t know why the default gamma correction is 2.8, for a long time I couldn’t understand why my feed was already turned off by 15%, and most of the slider didn’t change brightness at all, until I decided to add a correction, after rebooting 10 times I figured out that 1.4 is the right number , but I would like to pick it up to perfection.
The situation is the same with the frequency, 60Hz is noticeable that the tape flickers, 100Hz already seems good… well, see above, the same thing.

For frequency you would use something like the following:

number:
  - platform: template
    name: 'Frequency'
    id: pwm_freq
    max_value: 40000
    min_value: 100
    step: 100
    mode: slider
    initial_value: 1000
    optimistic: true
    on_value:    
      - output.esp8266_pwm.set_frequency:
          id: pwm_output
          frequency: !lambda "return x;"

There is not an existing Action to adjust Gamma.

Thank you. This really works and it seems that 100Hz, which I stopped at, is quite enough to prevent the tape from flickering at low brightness. And the fact that the gamma cannot be changed is insulting. But from this example and your previous example, I now at least see in which direction I should look for solutions to other similar problems. :+1:

I don’t have any leds controlled by an ESP8266 to test it on…
but you can try the following:

#number:
  - platform: template
    name: 'Gamma'
    id: gamma_setting
    max_value: 3
    min_value: 0
    step: 0.1
    mode: slider
    initial_value: 1.4
    optimistic: true
    on_value:
      then:
        - lambda: |-
            id(pwm_output).set_gamma_correct(x);