Jump to content
🌟 NEW Shelly Products Reveal Video! 🌟 NEUE Shelly-Produkte-Enthüllungsvideo! 🌟 ×
NOTICE / HINWEIS: iOS 18 Update and Today Widgets ×

Voice notification from the Wall Display: playing any MP3 if the gate remains open for a certain period


Recommended Posts

The new firmware (2.10 Beta) of the Wall Display allows us to attach an MP3 playback to any event!

LOCAL ACTIONS

This can be most easily implemented as a local action: for example, when a device is turned on, add to the device's actions that if it is on, it should execute this URL:

http://10.10.40.10/rpc/Media.MediaPlayer.PlayAudioClip?id=1&volume=10 Where:

  • 10.10.40.10 is the IP address of the Wall Display
  • id=1 is the identifier of the uploaded MP3 file
  • volume=10 is the volume level

local-action-for-wall-display.thumb.JPG.78a12d7c763e35c985657556fe3016d1.JPG

 

UPLOAD MP3

Of course, we will need to upload the appropriate MP3 file to the Wall Display. This can be done through the WD local interface.

media-library-wd-upload-and-id.thumb.JPG.4513e349a97222622cf840ef353a531f.JPG

After uploading, the MP3, the ID will appear, allowing us to reference it - it is id 17 in the upper example.

 

Use TEXT-TO-SPEECH to make the voice

I use https://app.fliki.ai to create text-to-speech messages because it supports Hungarian, but any text-to-speech program can be used to generate the appropriate message, or we can play music. However, I believe clear human voice messages are more useful.

 

USE SCRIPT TO CONTROL VOICE

Of course, there are some things we can't solve with local actions, but for those, we can write a script. The following script does the following:

  • Monitors the state of a reed relay connected to a Shelly Add-on (whether the door is open or not)
  • Checks every 5 seconds if the door is open
  • If the door is open for 30 seconds, it plays a message that the door is open, then repeats this message every 30 seconds until the door is closed

We need this at the company (http://www.anrodiszlec.hu) to avoid energy loss if we are heating or cooling and doors are left open. This way, we notify colleagues to close the damn door because we can't heat the whole yard 🙂

Here is the script, don't forget to change the ip address of the Wall Display, and input ID, and anything you want on the volume and timer section.

let off_counter = 0;
const check_interval = 5000; // 5 seconds
const off_duration = 30000; // 30 seconds
let input_id = 100; // ID for the input
let audio_id = 16; // ID for the audio clip
let audio_volume = 8; // Volume for the audio clip

// Monitor the state of the door Input(100) every 5 seconds
Timer.set(check_interval, true, function () {
    Shelly.call("input.getstatus", { id: input_id }, function (result, error_code, error_message) {
        if (error_code !== 0) {
            print("Error occurred during input.getstatus call: " + error_message);
        } else {
            if (result && typeof result.state !== 'undefined') {
                if (result.state === true) {
                    off_counter += check_interval;
                    print("Input(" + input_id + ") is OFF. Incrementing counter: " + off_counter + " ms");

                    if (off_counter >= off_duration) { // OFF for 30 seconds
                        // Execute the URL
                        let url = "http://10.10.40.10/rpc/Media.MediaPlayer.PlayAudioClip?id=" + audio_id + "&volume=" + audio_volume;
                        Shelly.call("HTTP.GET", { url: url }, function (http_result, http_error_code, http_error_message) {
                            if (http_error_code !== 0) {
                                print("Error occurred during the URL call: " + http_error_message);
                            } else {
                                print("URL executed successfully.");
                                off_counter = 0; // Reset counter after notification
                            }
                        });
                    }
                } else {
                    print("Input(" + input_id + ") is ON.");
                    off_counter = 0; // Reset counter if state is ON
                }
            } else {
                print("The result object is undefined or missing the state property.");
            }
        }
    });
});

  • Like 2
Link to comment
Share on other sites

@Gábor Tályai Hi.

Fun thing to get audio to the display, great idea!

I would like to incorporate a sound to a button press in a virtual device (on the display), but i get an error.

I have changed the id to 1 (as it is my clip ID) but i get this error:

[21:25:47] [Webhooks]: Error executing webhook: com.android.volley.NoConnectionError: java.net.ConnectException: Connection refused

 

Viritualbutton.thumb.png.dbba1dda9f5f00faa6d8bd09a0e384ef.png

 

I could not find the API / manual for the Display to get further.

Edited by Martin_
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Erstelle neue...