Hi lads,
I’ve been experimenting with making my own view as a climate card,
I’d like to make a simple button to increase the temperature:
type: custom:mushroom-template-card
primary: Set temp
secondary: ''
icon: mdi:plus
entity: climate.airco_beneden
tap_action:
action: perform-action
perform_action: climate.set_temperature
target:
entity_id: climate.airco_beneden
data:
temperature: '{{ states.climate.airco_beneden.attributes.temperature +1 | float }}'
layout: vertical
card_mod:
style: |
ha-card {
height: 100% !important;
font-variant: small-caps;
--icon-size: 125px;
}
it looks like i want it to but I keep receiving
Failed to perform the action climate/set_temperature. expected float for dictionary value @ data[‘temperature’]
which has me confused since I am converting to a float?
it also shows the correct vallue in the template testing…
so does anyone know how to correct this yaml?
A am not using mushrooms - but the template itself is not OK.
States are strings, convert it to float first - and then do math.
Besides,
even withouth math and just doing the | float gives the same error
{{ state_attr('climate.airco_beneden', "temperature") | float + 1 }}
shows the correct value in tools but doesn’t work as action
Hellis81
(Hellis81)
September 18, 2024, 11:56am
5
In this code you use both single and double quotes.
You need to use one.
data:
temperature: "{{ state_attr('climate.airco_beneden', 'temperature') | float + 1 }}"
jeroenvdd89:
doesn’t work as action
Then try this call with a corrected template in Dev tools → Actions.
I have no idea about THIS particular service call as well as about calling services from mushrooms.
It depends on whether a whole template string is placed in quotes or not.
For instance, this does work as well:
xxxx: >-
{{ state_attr('sensor.xxx', "yyyy") }}
action: climate.set_temperature
target:
entity_id: climate.airco_beneden
data:
temperature: '{{ state_attr("climate.airco_beneden", "temperature") | float + 1 }}'
this action works perfectly,
now I’m hoping I don’t have to make extra script per function and call that instead