Cannot get "switch.turn_on" to work in a script configured in a Packages YAML file

I have what seems a simple problem but I have spent hours on it without success! I have a script in YAML:

    swimmingpool_start_filtering:
      alias: Swimming Pool Start Filtering
      sequence:
        - service: notify.persistent_notification
          data:
            title: "FILTERING"
            message: "{{ 'cycle_count' }}"
        - service: input_text.set_value
          entity_id: input_text.swimmingpool_cleaning_status
          data:
            value: "Filtering"
        - service: switch.turn_on
          entity_id: switch.swimmingpool_filter
        - service: switch.turn_on
          entity_id: switch.swimmingpool_floor_jets
        - delay:
            seconds: 20

The two service calls “switch.turn_on” do not work. No errors are reported but nothing happens.
I am sure the script is executing OK because I see a Notification like:
Screenshot 2024-06-10 231404

I can operate the device from a dashboard configured like this:


That is, the switch turns on when operated from the dashboard but not when the script is invoked. The log records the operation from the dashboard, but shows nothing from the script activity.
The device is an ESP8266 flashed with Tasmota nad is intended to operate 6 relays.

The entity settings are:

Any help towards solving this issue will be gratefully accepted.

Your service call configs are incomplete. The entity_id variable needs to be under target or data. You can also just list the two entities in a single switch.turn_on.

 - service: input_text.set_value
   target:
     entity_id: input_text.swimmingpool_cleaning_status
   data:
     value: "Filtering"
 - service: switch.turn_on
   target:
     entity_id: 
       - switch.swimming_pool_filter
       - switch.swimming_pool_floor_jets

EDIT: See Below

I have many service calls without this. Legacy from before “target” was introduced. They still work.

2 Likes

Your entity IDs are wrong. Compare:

        - service: switch.turn_on
          entity_id: switch.swimmingpool_filter

and:

image

Missing a pool_; my guess is that you have the same problem for the floor jets…

Hi Troon, Thanks.
Yes, a simple misspelling.
All fixed now!!!

1 Like