New to using scripts

I’ve never been a user of scripts before and I’m trying to get the hang of it to no avail.

Specifically I am trying to setup a Broadlink RM4 mini to control my a/c. I’ve got it working in the Broadlink app and I even created the file in the .storage folder with all the learned codes.

I tried to then create scripts but something has gone amiss. Here is an example. Does it seem correct?

turn_on_ac:
  sequence:
    - service: remote.send_command
      target:
        entity_id: remote.rm_mini_4_remote
      data:
        device: midea
        command: Turn_on

Assuming I have the corresponding code in the file in .storage, this should work, or am I way off?

Where did you read to do this? The Broadlink file is created when you learn commands within HA. You shouldn’t need to do this manually.

You don’t (can’t) reference the codes within that file from the script. That file is merely a list of codes learned. You need to take the data from there and use it in the command in your script (not what seems like a label that you’ve used), the bit that’s a very long string (normally).

sorry let me clarify, the Broadlink integration created the file with the codes, I was just trying to say it worked.

In fact, after much frustration, I discovered the scripts work as well, via the Scripts page in the Configuration section. I just now can’t seem to get them to trigger via a button in my frontend.

Here’s my code in Lovelace for the button.

            - type: button
              entity_id: script.mode_ac
              icon: mdi:white-balance-sunny
              name: 'Mode'
              tap_action:
                action: call_service
                service: script.mode_ac

But that doesn’t seem to actually trigger the script. I’ve tried it with and without an entity_id for the button as it really isn’t required is it? You just have the correct service being called in the tap action.

Try:

action: call-service  # - instead of _

I was wrong here – it seems you can (I just happen to still do it the initial/old way). And as you’ve confirmed, it works.

A ha, you are absolutely correct, I had it wrong.

Should be ‘call-service’ not ‘call_service’

All the buttons work now.

Thank you for pointing out the glaringly obvious mistake I had made.

1 Like