Picture-elements card: Multipe actions/services on tap_action

Tried almost all posibilities but cannot get both actions working. Each is working individually but when both are without errors only the last one works and the payload is not published to my sonoff. I have tried all kinds of indents, formats and examples but need now humbly ask for advice/suggestions. Any reaction is welkom.
Kind regards Martin J

            - type: image
#             hold_action:
#               action: more-info
              tap_action:
                action: call-service
                service: mqtt.publish
                service_data:
                  topic: "cmnd/sonoff/backlog"
                  payload: "RfSync 12030; RfLow 450; RfHigh 1230; RfCode #400001"

                action: call-service
                service: light.toggle
                service_data:
                  entity_id: light.keukenkast_leds

              entity: light.keukenkast_leds
              state_image:
                "on": /local/resources/keukenkast leds aan.svg
                "off": /local/resources/keukenkast leds uit.svg
              style:
                top: 58%
                left: 35%
                width: 3.5%
1 Like

Maybe use a script with the 2 actions in and call that instead ?

I have tried via automation and trigger mqtt but more or less same problem to fire 2 actions one after antother, only the last one worked.

Something like this ?
Probably change the name (tap_action_sequence) in both to something more relevant
Delay might not be needed

Script:

tap_action_sequence:
  sequence:
	  - service: mqtt.publish
		service_data:
		  topic: "cmnd/sonoff/backlog"
		  payload: "RfSync 12030; RfLow 450; RfHigh 1230; RfCode #400001"
      - delay:
          seconds: 1
	  - service: light.toggle
		service_data:
		  entity_id: light.keukenkast_leds

Image tap action

- type: image
    hold_action:
      action: more-info
    tap_action:
      action: call-service
      service: script.turn_on
      service_data:
		  entity_id: script.tap_action_sequence

Will try tomorrow and let you know asap.
Thanks for sharing your ideas.

@MArtin_br @Holdestmade
That won’t work. You’ll have to make a script and call the script. You can only call 1 service from lovelace, you cannot call multiple services.

@petro That’s what I’ve shown ?

Sorry, was late when I posted. Thought it was inside the lovelace yaml.

Like the idea for the script, unfortulately floowing error is thrown:

Invalid config for [script]: [service_data] is an invalid option for [script]. Check: script->script->keukenkast_leds_script->sequence->0->service_data. (See /config/configuration.yaml, line 36). Please check the docs at https://home-assistant.io/components/script/

I now have script with or without “-” 's

keukenkast_leds_script:
  sequence:
    service: mqtt.publish
    service_data:
      topic: "cmnd/sonoff/backlog"
      payload: "RfSync 12030; RfLow 450; RfHigh 1230; RfCode #400001"
    delay:
      seconds: 1
    service: light.toggle
    service_data:
      entity_id: light.keukenkast_leds

and in ui-lovelace.yaml

            - type: image
              tap_action:
                action: call-service
                service: script.turn_on
                service_data:
                  entity_id: keukenkast_leds_script
                  
              entity: light.keukenkast_leds
              state_image:
                "on": /local/resources/keukenkast leds aan.svg
                "off": /local/resources/keukenkast leds uit.svg
              style:
                top: 58%
                left: 35%
                width: 3.5%

When testing it complains: cannot call script/turn-on. Service not found.

Try this

tap_action_sequence:
  sequence:
    - service: mqtt.publish
      data:
        topic: "cmnd/sonoff/backlog"
        payload: "RfSync 12030; RfLow 450; RfHigh 1230; RfCode #400001"
    - delay:
        seconds: 1
    - service: light.toggle
      data:
        entity_id: light.keukenkast_leds
- type: image
  hold_action:
    action: more-info
  tap_action:
    action: call-service
    service: script.turn_on
    service_data:
      entity_id: script.tap_action_sequence

Missing a few things.

  1. Your sequence isn’t a list of services. That’s what the -'s do. Makes it a list. Sequence is fired top down on the list.

  2. You’re missing the domian in your entity id for the call-service in your lovelace yaml.

  3. you don’t really need to use script.turn_on. You can just call the script directly.

keukenkast_leds_script:
  sequence:
    - service: mqtt.publish
      service_data:
        topic: "cmnd/sonoff/backlog"
        payload: "RfSync 12030; RfLow 450; RfHigh 1230; RfCode #400001"
    - delay:
        seconds: 1
    - service: light.toggle
      service_data:
        entity_id: light.keukenkast_leds
            - type: image
              tap_action:
                action: call-service
                service: script.keukenkast_leds_script
                  
              entity: light.keukenkast_leds
              state_image:
                "on": /local/resources/keukenkast leds aan.svg
                "off": /local/resources/keukenkast leds uit.svg
              style:
                top: 58%
                left: 35%
                width: 3.5%

Working like a charm, thanks to the both of you.

From the 6502/z80 era with limited resources i still tend to write code as compact as possible altough no longer in direct opcodes or mneumonics.

Now I can finallyl focuss on the aparent dead time before the sonoff executes a next command. This is the more a minor because the RF led lights used do not send back their effectif state.

Kind regards and thanks again
Martin

pETRO:
This however doesn’t seem to work:

action: call-service
service: script.keukenkast_leds_script`

It should, I’m using it everywhere in my lovelace.yaml. Either way, if you got it working then no point in changing it.

With your help things are finally moving. From the 6502/Z80 era with forced mneumonics and very limited resources this is a very steep curve and feel like some fuzzy logic.

Blunt enough to throw in another riddle:

Am i thinking to simple now?

in cover.yaml
- platform: mqtt
  name: "vitrage_rechts"
  state_topic: "vitrage_rechts/status"
  command_topic: "cmnd/Sonoff-Bridge_1/backlog"
# Dooya remote 2 up stop down
  payload_open: "rfraw AA B0 35 05 04 1338 0618 0168 0302 22E2 A481A3A3A3B2B2B2A3B2A3A3B2B2A3B2A3B2A3B2A3A3A3A3B2B2A3B2B2B2A3A3B2A3A3A3A3B2B2B2B2 55;rfraw 177"
  payload_close: "rfraw AA B0 35 05 04 131A 0622 0154 0302 222E B481A3A3A3B2B2B2A3B2A3A3B2B2A3B2A3B2A3B2A3A3A3A3B2B2A3B2B2B2A3A3B2A3A3B2A3B2A3B2A3 55;rfraw 177"
  payload_stop: "rfraw AA B0 35 05 04 1338 0618 0168 02F8 22D8 A481A3A3A3B2B2B2A3B2A3A3B2B2A3B2A3B2A3B2A3A3A3A3B2B2A3B2B2B2A3A3B2A3A3A3B2B2B2B2A3 55;rfraw 177"
  set_position_template: "50"
  qos: 1
  optimistic: true
  retain: false

and in scripts:

vitrage_rechts_scripts:

  sequence:
    - service: cover.toggle
      data:
        entity_id: cover.vitrage_rechts

no errors are thrwon but the Sonogg console is not showing the payload beiing sent.

Any ideas for this dilemma?

cover doesn’t have a toggle service. You should look at the cover services and choose the appropriate service

The covers I use don’t send feedback. I try to construct a 1-button control to cycle up-stop-down-stop-. That needs a variable to give the values 0 75 100-25-0 but variable.py is not working. Before trying the im,possible I would like to know if variable/ init.py should still work.
Thanks

Still going strong. I am trying to program for non-feedback covers.
The general idea is that after starting to open or to close a 15 second window is available for a stop command after that delay the postion variable _pos is set.
I have no errors that i am aware off but only the first option is excuted no matter what the current value of the position variable is 0, 75, 100 or 25.
Who can shed a light on this?

scherm_links_script:
  sequence:
    - service: script.turn_on
      data_template:
        entity_id: >
          {% if ("variable.scherm_links_pos", "0") %}
              script.scherm_links_0
          {% elif ("variable.scherm_links_pos", "75") %}
              script.scherm_links_75
          {% elif ("variable.scherm_links_pos", "100") %}
              script.scherm_links_100
          {% elif ("variable.scherm_links_pos", "25") %}
              script.scherm_links_25
          {% else %}
              script.noop_script
          {% endif %}

Sample of the 4 working scripts:

scherm_links_75:
  sequence:
    - service: mqtt.publish
      data:
        topic: "cmnd/Sonoff_Bridge_1/backlog"
        payload: "RfSync 10160; RfLow 300; RfHigh 960; RfCode #ED92A4"
    - service: variable.set_variable
      data:
        variable: scherm_links_pos
        value: 100
    - service: cover.toggle
      data:
        entity_id: cover.scherm_links

need the function calls

{% if is_state("variable.scherm_links_pos", "0") %}
         ^