Author Topic: Play sound when door is opened (chime)  (Read 585 times)

Offline spud1502

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Play sound when door is opened (chime)
« on: December 31, 2017, 11:31:34 pm »
Hi, does anyone know how to make imperihome chime when the door is opened, I know how to send speech to the android device but not to trigger a sound file? Thanks in advance.

Offline treetop777

  • Full Member
  • ***
  • Posts: 204
  • Karma: +3/-5
Re: Play sound when door is opened (chime)
« Reply #1 on: January 06, 2018, 01:23:29 am »
Interesting..

Offline ninkasi

  • Full Member
  • ***
  • Posts: 188
  • Karma: +10/-0
Re: Play sound when door is opened (chime)
« Reply #2 on: January 06, 2018, 05:55:54 am »
Maybe tasker & autovera?
Home Automation veteran. Rolled own, then MisterHouse and X10, now Vera - mysensor arduino and ESP8266 network - zwave lights, locks, switches - milights - yeelights - google home(s) - Broadlink RM - raspberry pi(s) with various scripts for power and weather station - Logitech Harmony - Imperihome

Offline metricowl

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Play sound when door is opened (chime)
« Reply #3 on: January 06, 2018, 09:04:13 am »
the imperihome api has POST /sound/phone/{type}, you can do notification, ringtone, or alert, which works from the api documentation screen http://ip:port/api/rest/help/, but I cannot seem to get it to work anywhere else?

Offline Drcashman

  • Sr. Newbie
  • *
  • Posts: 26
  • Karma: +3/-0
Re: Play sound when door is opened (chime)
« Reply #4 on: January 06, 2018, 09:30:25 am »
To get it working just use the following lua code in a scene:


local url = require("socket.url")
local socket = require("socket")
local http = require("socket.http")
http.TIMEOUT = 5

--
-- Execute the resulting URL
--

local status, statusMsg = http.request{
   url = "http://xxx.xxx.xxx.xxx:8080/api/rest/sound/phone/alert?duration=2&volume=100",
    method = "POST",
   
}

Just change the red text to your Imperihome  IP  and sound location or type.

Examples of urls are:

http://xxx.xxx.xxx.xxx:8080/api/rest/sound/phone/alert?duration=2&volume=100   
http://xxx.xxx.xxx.xxx:8080/api/rest/sound/phone/ringtone?duration=2&volume=100

You can also play mp3's from an online resource just change the url to the location of the mp3 file.

Offline spud1502

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Play sound when door is opened (chime)
« Reply #5 on: February 24, 2018, 11:58:57 am »
I don't understand, I have managed to get the sound file to play from the API section but how do I add this into a scene?

Thanks