Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95294

Template Switch not working

$
0
0

@michelde wrote:

Hi,

I want to achieve to play my Sonos speaker when I turn on a switch. Using an automation is working fine, but I don’t understand why it’s not working with a template switch. So my automation which works looks:

- id: '1572181424930'
  alias: Sonos Kitchen
  description: ''
  trigger:
  - entity_id: switch.sonos_kuche_switch
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: media_player.kuche
    service: media_player.media_play

Now I disabled this automation and created a template switch as follows:

- platform: template
  switches:
    sonos_kuche_switch_template:
      friendly_name: "Kitchen Radio Switch"
      value_template: "{{ is_state('switch.sonos_kuche_switch', 'on') }}"
      turn_on:
      - data:
          entity_id: media_player.kuche
        service: media_player.media_play
      turn_off:
      - data:
          entity_id: media_player.kuche
        service: media_player.media_pause

Using the developer tools I can see that the state of the new template switch is evaluated correct using the value template. But for some reason my turn_on and turn_off actions are not working.

Does anyone what I’m making wrong?

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95294

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>