Broadlink RM4 - trying to learn IR and RF codes via script

Hi all, an absolute noob here needing help.
I have a Broadlink RM4 which is working fine as stand-alone and it is integrated to HA and I have tried to learn the IR codes for my gas heater using the scripting instructions (adding to configuration.yaml) but I keep getting an error when I click ‘CHECK CONFIGURATION’:

Configuration invalid!
Integration error: learn_gas_heater_on - Integration ‘learn_gas_heater_on’ not found.

Here is what my configuration.yaml looks like:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
**script:**
**learn_gas_heater_on:**
**  - sequence:**
**  - service: remote.learn_command**
**    target:**
**      entity_id: remote.wi_fi_universal_remote_remote**
**    data:**
**      device: gas_heater**
**      command: on**
scene: !include scenes.yaml

This is my first attempt doing something useful with HA so I hope to get this working and learn from this. But I cannot do this without your help, please help. I have no where else to turn.

Post your yaml as it was when you got the error - it looks like you have and indentation issue but hard to tell or if you did it when commenting out.

Hi, this is exactly what it looks like. Just had the error and copied the contents. Please let me know if it still looks wrong.
Thank you so much for helping with this.

Configure a default setup of Home Assistant (frontend, api, etc)

default_config:

Text to speech

tts:

  • platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script:
learn_gas_heater_on:

  • sequence:
  • service: remote.learn_command
    target:
    entity_id: remote.wi_fi_universal_remote_remote
    data:
    device: gas_heater
    command: on
    scene: !include scenes.yaml

discovery: !include broadlink

At first glance I would say your indentation is all shot, but it’s hard to tell because you haven’t posted in a code block. Take a look at the example on the Broadlink page, format your indents correctly and see how that goes.

script:
  learn_gas_heater_on:
    sequence:
      - service: remote.learn_command
        target:
          entity_id: remote.wi_fi_universal_remote_remote
        data:
          device: gas_heater
          command: on

I think you’re right.

Now looks like this and I get ‘CONFIGURATION VALID’:
My next question is; how do I make that part of the script run so I can test if it is working? I mean to say, it should only run while learning and once learnt, the codes should be saved and stored. Is that correct?

Text to speech

tts:

  • platform: google_translate

group: !include groups.yaml

automation: !include automations.yaml

script:

learn_gas_heater_on:

sequence:

  - service: remote.learn_command

    target:

      entity_id: remote.wi_fi_universal_remote_remote

    data:

      device: gas_heater

      command: on

scene: !include scenes.yaml

discovery: !include broadlink

To be honest - these days the HA UI is so good you should just use it to capture the codes. The codes are saved just the same and it saves writing a bunch of repetitive scripts.

See the Services tab on the HA Developer Tools page:

Thanks, understood. I didn’t realise that existed. For this Broadlink, I will use that instead.
Still, I want to learn more about the scripting, gives me options. I just want to know invoke/call a script.

Scripts are called manually - from the page I screen shot above, or from within and automation started by a trigger.

Have a read of the doco and the included examples - it’s not difficult once you get started.

Read the above first - then think about running scripts (via a service call or directly) from an action in an automation.

This is an example from the Scripts page:

# Example configuration.yaml entry
automation:
  trigger:
    platform: state
    entity_id: light.bedroom
    from: "off"
    to: "on"
  action:
    service: script.notify_pushover
    data:
      title: "State change"
      message: "The light is on!"

Also please read this:

You will find a lot more people will jump in to assist if you have provided the info properly. Read the whole post - not just the section I linked. :slight_smile:

Will do, thanks.