Script error for changing thermostat temperature

alias: rack adjust ac setpoint
sequence:

  • condition: state
    entity_id: climate.equipment_closet
    state: ‘on’
  • service: climate.set_temperature
    data_template:
    entity_id: climate.equipment_closet
    temperature: ‘{{ states(’‘sensor.wirelesstag_rack_upper_tag_temperature’’) }}’
    mode: single

I GET THIS ERROR:
Message malformed: expected dict for dictionary value @ data[‘sequence’][1][‘data_template’]

Hey there, please format your code as the big red warning showed you when posting.

The issue is probably the different quotes in temperature.
Try:

temperature: "{{ states('sensor.wirelesstag_rack_upper_tag_temperature') }}"

data_template is no longer supported in 0.118. Change it to just “data”.

It was removed in 0.115 and left deprecated for 2 versions. So now that 0.118 is out, you must change it.

1 Like

I changed to “data:”
and changed:

temperature: "{{ states('sensor.wirelesstag_rack_upper_tag_temperature')  }}"

but still get error:
Message malformed: expected dict for dictionary value @ data[‘sequence’][1][‘data’]

Can you paste the entire script inside a code block?

alias: rack adjust ac setpoint
sequence:
  - condition: state
    entity_id: climate.equipment_closet
    state: 'on'
  - service: climate.set_temperature
    data: 
    entity_id: climate.equipment_closet
    temperature: "{{ states('sensor.wirelesstag_rack_upper_tag_temperature')  }}"
mode: single

There you go, you can’t spot indentation errors without code blocks:

alias: rack adjust ac setpoint
sequence:
  - condition: state
    entity_id: climate.equipment_closet
    state: 'on'
  - service: climate.set_temperature
    data: 
      entity_id: climate.equipment_closet
      temperature: "{{ states('sensor.wirelesstag_rack_upper_tag_temperature')  }}"
mode: single

great! No more error, but for some reason the setpoint on the device isn’t changing via the script execution. It does change if set manually via home assistant.

Hm, what’s the state of the sensor? (Developer Tools - States)
Is it a string instead of an int maybe? If so, this may help:

      temperature: "{{ states('sensor.wirelesstag_rack_upper_tag_temperature')  | int }}"

It’s something in the condition actually. I want it to trigger when its “On” but I only use it in cool mode.

Ah I see, so it works now?
I’m not too familiar with how climate devices are used in Home Assistant, so the state is ‘on’ or ‘off’ and you want to check for the hvac_mode as well?

On or off would be fine, but I’m not sure if there is a attribute for just on off. There is for HVAC mode. Here is what I have that is not true and not allowing the script to fire.

alias: rack adjust ac setpoint
sequence:
  - condition: state
    entity_id: climate.equipment_closet
    attribute: hvac_modes
    state: cool
  - service: climate.set_temperature
    data:
      entity_id: climate.equipment_closet
      temperature: '{{ states(''sensor.wirelesstag_rack_upper_tag_temperature'')  }}'
mode: single

Changing the attribute to hvac_mode might do the trick. (remove the ‘s’)
Reading through the docs, hvac_mode can be off as well, so that might be what you’re looking for

removing the “s” has no effect. I’ve tried “cool” and “on”

Hm, what’s the state of climate.equipment_closet?
As far as I understand it you want the script to only work when the unit is on, right?
So my assumption is that your A/C turns on when you set a temperature even though it remains off? (The docs say it should keep it’s current state) :thinking:

in developer tools, it’s weird that it doesn’t have “current hvac mode”:

hvac_modes:
  - dry
  - heat_cool
  - heat
  - fan_only
  - cool
  - 'off'
min_temp: 62
max_temp: 86
target_temp_step: 1
fan_modes:
  - quiet
  - low
  - medium
  - high
  - auto
  - strong
swing_modes:
  - stopped
  - rangeFull
current_temperature: 71
temperature: 65
current_humidity: 47.5
fan_mode: auto
swing_mode: stopped
battery: null
friendly_name: Equipment closet
supported_features: 41

Alright, what does the ‘state’ field say above the huge textbox?
You could try grabbing the hvac_mode from the template UI maybe? (Developer Tools - Template)
{{ state_attr('climate.equipment_closet', 'hvac_mode') }}
But it may be that your integration doesn’t support getting this :confounded:

it can say “off” or “cool” in the state box

Well then checking for a state of ‘cool’ as a state should work, no?

No. I’m thinking the integration doesn’t actually have an active state or current hvac mode attribute. Is that possible?