Need help understanding how to get my first addon to work

I downloaded this addon called Sox_Play that allows you to trigger a local audio file to play through USB speakers connected to the Home Assistant mini PC.

What I don’t understand is where do I put this code below that is used to call the audio file.

Service: hassio.addon_stdin
data:
addon: local_sox_play
input: “/media/Example.mp3”

You could put it in a script or an automation or in the tap action section of something on a dashboard, such as a button card.

If i saved it as a script then what name would I give it and does that file get saved in the same folder as the addon ?

I assume I would then call the script as a response to a trigger like I did with the lights when a door is opened.

You could name it anything you wanted. It would be saved in the same scripts.yaml file in /config that all scripts are saved to.

What’s happening here is that you are using a service that already exists in HA (hassio.addon_stdin) to communicate with the add on. So where ever you call this service (a script, an automation, from a dashboard) doesn’t really have anything directly to do with the add on.

If you wanted to make the sound play in an automation in response to some trigger, then you wouldn’t necessarily have to put it in a script first. But you could if wanted to play the same sound in a lot of different automations, for instance.

1 Like

Ah got it so I can name it Alert.yaml for example and in the automations when it asks what I want to do in response to a window being opened I can tell it to call the Alert.yaml script that I saved to the scripts folder.

Do I need to include anything else besides the four lines of code used in the example from the addon page ?

Not quite. Go to the scripts page in the UI and choose to create a new script (from scratch). Then click the add action button. From the popup, choose “Call a service”. In the service name field type hassio.addon_stdin and then choose your addon from the drop down that appears. There won’t be a field for input, so you have to add that yourself. From the three dots menu on the right, choose “Edit in YAML”. You’ll see something like this, but with different text in the add on field:

Below the line that starts addon add a new line with the same indentation for the input. Now it will look something like this:

Give the script a name (in the field at the top) and save it. Now you can call the script from automations or a dashboard.

You should probably review the documentation on scripts to increase your understanding of what’s going on.

1 Like