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

MQTT automation light control to template automation

$
0
0

@lionberger wrote:

I currently have the following automation in order to switch on and off a double_garage light in Home Assistant when an on/off message is received via MQTT hub.

automation:
  - id: '11'
    alias: turn on lights
    trigger:
      platform: mqtt
      topic: 'light/double_garage'
      payload: "on"
      encoding: "utf-8"
    action:
      - service: light.turn_on
        data:
          entity_id:
            - light.double_garage
  - id: '12'
    alias: turn off lights
    trigger:
      platform: mqtt
      topic: 'light/double_garage'
      payload: "off"
      encoding: "utf-8"
    action:
      - service: light.turn_off
        data:
          entity_id:
            - light.double_garage

That’s a lot of code for one single light! any way to template the above for any light matching for instance a regex??

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles