Invalid data for call_service at pos 1: Service does not match format <domain>.<name> in log but automation work..?

templates
automation
Tags: #<Tag:0x00007fd076f65650> #<Tag:0x00007fd076f651f0>

#1

hello,

i have an error when trying to service_template in automation.

my automatiom is triggered by mqtt,

when i hit unused buttons of my tv remote it activate corresponding script.

the automation work as is but i got that error in log :
Invalid data for call_service at pos 1: Service does not match format .

please help me finding the problem…here the code

- id: irremote
alias: 'irremote'
trigger:
  - platform: mqtt
    topic: ir_server/received
action:
  - service_template: >-
       {% if states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF8877"  %}
       script.num1
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF48B7"  %}
       script.num2
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DFC837"  %}
       script.num3
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF28D7"  %}
       script.num4
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DFA857"  %}
       script.num5
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF6897"  %}
       script.num6
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DFE817"  %}
       script.num7
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF18E7"  %}
       script.num8
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF9867"  %}
       script.num9
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF00FF"  %}
       script.cablehaut
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF807F"  %}
       script.cablebas
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF02FD"  %}
       script.kodihaut
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF827D"  %}
       script.kodibas
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DFE01F"  %}
       script.kodigauche
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF609F"  %}
       script.kodidroit
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF22DD"  %}
       script.kodiok
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF14EB"  %}
       script.kodiback
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF55AA"  %}
       script.kodic
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF7887"  %}
       script.kodihome
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF8679"  %}
       script.kodisouris
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF4EB1"  %}
       script.hdmi1
       {% elif states.sensor.ircode.state|regex_replace(find='3,', replace='', ignorecase=False)|regex_replace(find=',32', replace='', ignorecase=False) == "20DF8E71"  %}
       script.hdmi2
       {% endif %}

#2

Your if statement has no else clause. If none of the tests evaluate to true, then the result of the template is an empty string, which is not a valid service name. Try creating a script.dummy that does nothing, and then add an else clause to returns script.dummy.


#3

problem solved

thank you