Float conversion?

Hi

I’m trying to implement first in basic version the Generic Thermostat component but I have an issue with it about Float variable for target_temp setting:

  climate:
  - platform: generic_thermostat
    name: Appartement
    heater: switch.chauffage
    target_sensor: sensor.salon_temp_bmp
    min_temp: 15
    max_temp: 30
    target_temp: input_number.temp_confort|float
    tolerance: 0.8
    min_cycle_duration:
      seconds: 30

Very confused here how to use the float command (I have checked multiple threads here but still not sure of correct syntax !!) or should I change the variable genre created by the input_number slider ??

Thanks for help,

Vincèn

target_temp: '{{ input_number.temp_confort | float }}'

Tried that syntax but refused too :frowning:

No one on this ??

Thanks

I think you might need to use templating and https://home-assistant.io/components/sensor.template

Thanks for your message but very confused here about link between my cast problem on variables and templating ?? My goal here is to be able to setup in frontend a slider for heater temperature !! I created an input slider and wants to pass value of that input slider at the generic_thermostat automation :wink:

I’m saying I don’t think you can do {{ math stuff }} on a platform: generic_thermostat. I think you need to use platform: template with the value_template to get the value.

“I think” because I’ve done this maybe once. These yaml files aren’t exactly code, it’s more like configuration data with some code-like attributes available in some cases. That’s how I think of it.

oki so I tried to use sensor template but nothing really better :frowning: Is it me or it’s really missing somewhere a basic cookbook about how all these parts work together ? as it’s very confusing which way to go even for basic automations like heating system :frowning:

So I created an input number on frontend to be able to adjust temperature I want in configuration.yaml

input_number:
  temp_confort:
    name: Température Confort
    initial: 20
    min: 15
    max: 30
    step: 1
    icon: mdi:thermometer-lines

I did that them to convert to float my input number:

- platform: template
  sensors:
    temp_confort:
      friendly_name: 'Température Confort'
      value_template: "{{ input_number.temp_confort | float }}"

And finally that to handle the heat logic itself:

- platform: generic_thermostat
  name: Appartement
  heater: switch.relais_chauffage
  target_sensor: sensor.salon_temp_bmp
  min_temp: 15
  max_temp: 30
  target_temp: "{{ sensor.temp_confort | float }}"
  tolerance: 0.8

But HA always complain about Float type for generic_thermostat so completely lost and disappointed here by all the hassle it is just to get basic features to work :confused:

I noticed also that my sensor code to convert to float is not working, the “float” variable never gets any value whatever I move the input number slider in front office…

Vincèn

1 Like

You actually can’t use a template in the platform: generic_thermostat initial config but you can get the behavior you want as part of automations. What you want to do is adjust the target temperature whenever the input_number is moved. So you want to just set the target_temp initially to some default value (e.g. 22) and then use an automation like:

- alias: Adjust temperature
     trigger:
       platform: state
       entity_id: input_number.temp_confort

  action: 
  - service: climate.set_temperature 
    data_template: 
      entity_id: climate.Appartement 
      temperature: "{{ states('input_number.temp_confort') | float }}" 

Then every time the slider is adjusted the target temperature of the thermostat will be updated.

2 Likes

Thanks for your late answer but good advice :wink:

hi, I have a similar question and another one, I am trying to make the light brightness adjustment through the query. now value rezulirovki I have under climate slider is changing and in status I read roughly so 100.0 and forth, I think that I correctly made okruzlenie and on izmenniyu, as in example higher. But did I do the right thing how to concatenate the query and the value to change the brightness of " input_number.hall_main_pwm_temp". You can tell me how best to do it. Or maybe there’s another way?
switch:

and

light:

  • platform: switch
    name: hall_main_pwm
    entity_id: switch.hall_main_temp

if necessary, I will give the parameters of the script …
thank you very much, translate rulit )))