So I have an air conditioner in my bedroom and living room.
The climate control for these do not have a toggle function and I want to make a button in lovelace to toggle the A/C on or off. The input_boolean does this.
Then I have an automation as follows:
- id: 'toggleacbedroom'
alias: Toggle A/C Bedroom
initial_state: 'true'
trigger:
- entity_id: input_boolean.ac_bedroom
platform: state
condition: []
action:
- service_template: >
'{%- if states.climate.bedroom.state == 'off' -%} climate.turn_on {%- else -%} climate.turn_off {%- endif -%}'
entity_id: climate.bedroom
- id: 'toggleaclivingroom'
alias: Toggle A/C Livingroom
initial_state: 'true'
trigger:
- entity_id: input_boolean.ac_living_room
platform: state
condition: []
action:
- service_template: >
'{%- if states.climate.living_room.state == 'off' -%} climate.turn_on {%- else -%} climate.turn_off {%- endif -%}'
entity_id: climate.living_room
The trigger is working but the action is not working and I get an error:
Error while executing automation automation.toggle_a_c_livingroom. Invalid data for call_service at pos 1: Service 'climate.turn_on' does not match format <domain>.<name>
My Lovelace card triggers the input_boolean and displays the state of the climate entity:
- type: horizontal-stack
cards:
- type: custom:button-card
entity: climate.living_room
icon: mdi:air-conditioner
color: var(--secondary-text-color)
state:
- value: 'off'
color: var(--paper-item-icon-color) # rgb(54, 95, 140)
name: Living Room
show_state: true
tap_action:
action: call-service
service: input_boolean.toggle
service_data:
entity_id: input_boolean.ac_living_room
- type: custom:button-card
entity: climate.bedroom
icon: mdi:air-conditioner
color: var(--secondary-text-color)
state:
- value: 'off'
color: var(--paper-item-icon-color) # rgb(54, 95, 140)
name: Bedoom
show_state: true
tap_action:
action: call-service
service: input_boolean.toggle
service_data:
entity_id: input_boolean.ac_bedroom
Any ideas. @petro @123 in particular as they are template guru’s…
Or any other way to do this?