Trying to get a siren for my burglar alarm via my IKEA speaker (Sonons)

(excuse my English)
Trying to get a siren for my burglar alarm via my IKEA speaker (Sonons).
I can not play a local mp3 file in the Sonos speakers (but works fine on my chromecasts).
I have been trying all possible paths to the file.
both: https://xxxxxxx.duckdns.org:8123
and 192.168.1.205/local/PoliceSiren.mp3
in different variants.
I have also tried:
media-source: //media_source/local/PoliceSiren.mp3
If I run the same path, it works on all my Chromecast
Why does Sonos not want to play?

image


I can play this on Sonos: 
#https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3#
Which is not local.

What's the difference between Sonos and Chromecast?
Where should I start looking for the problem?
# Invändig siren via högtalare      
- alias: 'Siren i högtalare'
  trigger:
    - platform: state
      entity_id: switch.rorelsesensor_altan
      to: 'on'
  action:
    - service: media_player.play_media
      data:
        entity_id: media_player.altan
        media_content_id: 'media-source://media_source/local/PoliceSiren.mp3'
        media_content_type: 'music'

I only have a old sonos play 1 and only play local MP3’s but what is different between your example and mine is I use a http access with port number specified:

  - service: media_player.play_media
    data_template:
      media_content_id: '{% set b = now().strftime("%H") %} http://192.168.2.242:8123/local/sounds/cuckoo/cuckoo-clock-{{b}}.mp3

        '
      entity_id: media_player.living_room
      media_content_type: music

I have tried with :8123.
When I run this I immediately get an error message in the sonos app in the mobile "lost connection to 192.168.1.205:8123.
Why does it look so simple for everyone?
Could it have something to do with SSL?

I have the a siren noise as mp3 in the folder www within the config folder.

This code works on my Sonos:

- id: trigger_alarm at movemement
  alias: Trigger alarm at movement
  initial_state: true
  trigger:
    - platform: state
      entity_id: binary_sensor.0x00158d0002ec0096_occupancy
      to: 'on'
    - platform: state
      entity_id: binary_sensor.0x00158d0002e277a4_occupancy
      to: 'on'
    - platform: state
      entity_id: binary_sensor.0x00158d0002e20ffe_contact
      to: 'on'
    - platform: state
      entity_id: binary_sensor.0x00158d0002e6b4b9_contact
      to: 'on'
  condition:
      condition: state
      entity_id:  input_boolean.alarm
      state: 'on'
  action:
    - service: light.turn_on
      entity_id: light.entrance
    - service: media_player.volume_set
      data:
        entity_id: group.sonos
        volume_level: 0.5
    - service: media_player.play_media
      data:
        entity_id: group.sonos
        media_content_type: MUSIC
        media_content_id: "https://mydomain.duckdns.org:8123/local/Siren_Noise.mp3"

Piggyback
What happens if you insert
#https://mydomain.duckdns.org:8123/local/Siren_Noise.mp3#
into your browser?
If I put mine in, I get
404: Not Found
Could it be a clue?

Hi, I’m not clear on how you are using the sonos app, not sure it should have any factor. you are just sending an mp3 file directly from your HA server to your Sonos device.

Can you get to the mp3 file from a command prompt? If you cannot download the mp3 file from a machine within your network, then your HA server is not going to be able to get the mp3 file to then forward to Sonos. The command below should download the source mp3 to the machine you run curl on. Then you should be able to play that file, if that does not work, then you have to fix access to the source file:

curl http://192.168.2.242:8123/local/sounds/cuckoo/cuckoo-clock-01.mp3 > z.mp3

works fine indeed. It plays the siren.

So grateful for all the help.
Here it looks like I have the problem.
I can not go on to /local/
I can go to /Lovelace.
I can enter via Samba share to /local/
What is the reason for this?


bild tvĂĄ

that indeed seems to be the core of the issue. What kind of install do you have? It might be related to permissions.

For me it gives forbidden:
image

I think it doesn´t work because it is too cold in Sweden :rofl: :rofl:

When it’s cold outside, you sit inside with this, :grinning:
but now it’s a little warmer outside. :wink:
Is this enough?

Been a while, and you guys are doing SSL and this :duck:DNS stuff that I am not. I just used Nabu Casa for my remote access.

Have a look at this setting in configuration.yaml, I have this set in my config:

#  whitelist_external_dirs:
  allowlist_external_dirs:
    - /
    - /tmp

related to these posts:

https://community.home-assistant.io/t/how-to-access-control-files-under-config-www/173398

https://community.home-assistant.io/t/cant-access-www-directory-with-hass-io/34312/16

I’m just hoping no one brings up the whole Norway USA Superbowl battle :grinning:

We seem to be running on the same version and I really cannot think of anything other than somewhere there is an authorization issue…

in terms of configuration.yaml I have the following that could in some way or form be related…

#default configuration 
default_config:

# Enables configuration UI
config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
#  base_url: https://mydomain.duckdns.org:8123
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

I do not have any whitelisting or anything similar.

/René

Have tried so much so I do not know what it was like in the beginning.
This is what my config looks like.

Can you use TTS on your Sonos speaker as well?

Yes, on my config I use both MP3’s and Nabu Casa’s TTS. I just tried Google TTS and it works as well to Sonos.

I doubt this will make a difference by have you tried just putting the raw internal IP address of your home assistant server address in the call. I gotta say, I really am struggling to see why people call an external service from within their private network to lookup an internal address, but that is just me.

Here is another post, as per this guy, are you 100% sure you have your directory structure correct???
In my setup:
/home/user/homeassistant

maps to

/config

so my physical directory location of:

/home/user/homeassistant/www/sounds

looks like

/config/www/sounds

inside and to Home Assistant
and from a URL standpoint that is:

http://192.168.2.242:8123/local/sounds

https://community.home-assistant.io/t/yet-another-sonos-playing-an-mp3-issue/148307

I’m not sure this matters but you do not have port on your internal IP address, looking the HA documentation, a port is specified:

https://www.home-assistant.io/docs/configuration/basic/

A 404 error is a different problem than a 403 error.

I do get a 403 error if I try to browse the raw directory:

http://192.168.2.242:8123/local/sounds

however if go directly to a mp3 file in this directory, it loads in browser correctly:

http://192.168.2.242:8123/local/sounds/its-five-oclock-somewhere.mp3

im sure i read somewhere about a similar issue that was solved by replacing /local/ with /www/

not sure if this will help

The more I read the less I understand.
Can not remember how I installed HA.
The path to the mp3 files in explorer looks like this.
\ HASSIO \ config \ WWW
If I click on the mp3 files after www, they play.
Can I enter this path in a good way?

I have tried “www” instead of “Local” without results.

If I enter
http://192.168.1.205:8123/local/forse.mp3
I get this.