Dear all,
i’m still using HADashboard because it is supported by old IPAD2 I have around the house (still perfect for this simple use).
I just would like to fix this thing I don’t like:
I made a custom widget switch in order to play an alarm sound when it turns on (I use it for alarms, gas detectors, etc…).
The problem is that I only made it to work by linking to a sound file on the web, no way to refer to a local file saved into the Appdaemon config directory.
How can I achieve this?
My mod:
widget definition:
gas_alarm:
widget_type: switch_sound
title: test
entity: sensor.gas
icon_on: mdi-gas-burner
icon_off: mdi-gas-burner
audio_active: 'alarm.mp3'
js widget mod on the toggle function:
function toggle(self)
{
if (self.state === self.parameters.state_active)
{
self.state = self.parameters.state_inactive;
}
else
{
self.state = self.parameters.state_active;
// play AUDIO file MOD
command = "var audio = new Audio('" + audio_active + "'); audio.play();"
eval(command);
}
set_view(self, self.state)
}
if in the widget the reference to the audio file “audio_active” is set to an internet link it perfectly works, for example
audio_active: ‘https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3’
If I upload the file in the config folder, under www for example or any other folder no way to reference it…
Tried
audio_active: ‘/www/alarm.mp3’
audio_active: ‘/config/www/alarm.mp3’
audio_active: ‘http://homeassistant:5050/local/alarm.mp3’
this last one is the alarm.mp3 in the www folder as per instructions, it is accessible if I put the link directly in a browser but does not work…
Any ideas?