Hi, I have 2 automatisations and I would like only one with an IF/ELSE
this is one of all mqtt switch :
mqtt:
switch:
- name: "Serveur NGINX"
object_id: server_nginx
unique_id: nabaztag_ztk3o7_nginx
state_topic: "nabaztag/sensor/box-nabaztag/service_nginx/status"
command_topic: "nabaztag/switch/box-nabaztag/service_switch"
payload_on: "start_service_nginx"
payload_off: "stop_service_nginx"
state_on: "online"
state_off: "offline"
icon: "mdi:web"
qos: 0
retain: false
device:
identifiers:
- nabaztag_box_ztk3o7
and my automatisations (on automations.yaml) :
## Nabaztag Service Switch
- alias: Nabaztag Service Switch MQTT
trigger:
platform: mqtt
topic: nabaztag/switch/box-nabaztag/service_switch
condition: "{{ trigger.payload in ['start_service_nginx', 'stop_service_nginx', 'start_service_sql', 'stop_service_sql', 'start_service_php', 'stop_service_php'] }}"
action:
- service: script.nabaztag_service
data_template:
action: "{{ trigger.payload }}"
context_id: "{{ this.context.id }}"
- alias: Nabaztag Service Switch HTTP
trigger:
platform: mqtt
topic: nabaztag/switch/box-nabaztag/service_switch
condition: "{{ trigger.payload not in ['start_service_nginx', 'stop_service_nginx', 'start_service_sql', 'stop_service_sql', 'start_service_php', 'stop_service_php'] }}"
action:
- service: rest_command.nabaztag_httprequest
data_template:
action: "{{ trigger.payload }}"
payload: '{"context_id": "{{ this.context.id }}"}'
So I have 2 automatisations and I would like only one with an IF/ELSE
And it would be even better if the condition could be a list of object_id or, failing that, a unique_id list
object_id list :
- service_php
- server_nginx
- server_sql
unique_id list :
- nabaztag_ztk3o7_php
- nabaztag_ztk3o7_nginx
- nabaztag_ztk3o7_sql
Everything I put works, but I would like something cleaner
and on configuration.yaml (bonus ^^)
rest_command:
nabaztag_httprequest:
url: 'http://nabaztag.local/api/{{ action }}'
method: 'post'
payload: '{{ payload | tojson }}'
content_type: 'application/json'
Thanks for your help