Switch where values are in dictionary range

Hi Guys,
apologies for the question, I’ve researched templates and I’ve researched template switches and I thought I understand them but home assistant brought me back down to earth with error messages.

Background: I bought a portable AC unit, it has Tuya compatibility and it slotted straight into HA as a climate entity. I have a Stream deck that allows me to ‘at the touch of a button’ switch devices on and off. To do so, I need a switch entity and the Tuya interface doesn’t provide that. So I walk down the path of using a switch template, however the state of the entity is not on/off. Its ‘cool’ and ‘off’. So the return value of the template doesn’t match its dictionary

Failure Simplified:
value_template {{ is_state ('climate.kogan', 'cool') }}

I was hoping to return a true/false that HA would derive as Boolean on/off
I have not been able to determine the best way to create a template that will return specific values based on another entities values.

Creating a new entity seems the best way:

{{ iif (is_state('climate.kogan.state', 'cool'), 'on', 'off') }}

then converting that entity to a switch, however I was hoping to appeal to collective wisdom…

The template is missing outer quotes. They’re needed when the template is on the same line as the YAML option. In addition, the YAML option is missing a required colon.

value_template: "{{ is_state('climate.kogan', 'cool') }}"

Reference: Important Templating Rules

climate.kogan.state is an invalid entity_id for the is_state() function. As a consequence, is_state() will produce false and so iif() will always report off.

Thanks Taras … it was more about what is the best way rather than the syntax but I appreciate the correction.

{{ iif (is_state('climate.kogan_smarter_hometm_3_5kw_portable_air_conditioner', 'cool'), 'on', 'off') }}

Works fine, I just wanted to be sure there wasn’t a better way.

If the syntax wrong, even the “best” way will fail.

The following is sufficient (and is shown in example found in the Template Switch’s documentation).

value_template: "{{ is_state('climate.kogan_smarter_hometm_3_5kw_portable_air_conditioner', 'cool') }}"