Page 1 of 1

Playing Doorbell Sound on Xiaomi Gateway

Posted: Tuesday 14 November 2017 16:51
by nettworker
Hello

i am trying to play the doorbell sound on the Gateway if a Switch is tapped. I tried the following code, but nothing happens:

Code: Select all

local sensor = 'Dual Wall Switch'
local schalter = 'Xiaomi Gateway Esszimmer Doorbell'

commandArray = {}

    if (devicechanged[sensor]) then
        commandArray['Xiaomi Gateway Esszimmer Volume']='Set Level 25'
        commandArray[schalter] = 'Set level 40'
        commandArray[schalter] = 'On'
        print('-- Schaltvorgang festgestellt--')
        print(otherdevices[sensor])
    end


return commandArray
Someone a solution?

Re: Playing Doorbell Sound on Xiaomi Gateway

Posted: Wednesday 15 November 2017 14:25
by nettworker
Tried the following after deleting all items and setup new:

Code: Select all

commandArray = {}

-- loop through all the changed devices
for deviceName,deviceValue in pairs(devicechanged) do

    print ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'")
    
    -- Auswertung des Mi Schalters ( links ) für die Abendlichter 
    if (deviceName == 'Mi GW Schalter' and deviceValue  == 'Switch 1') then
        if ( uservariables['Szenario_Abendlichter'] == 'Off' ) then
            print('Abendlichter sind aus, schalte ein...')
            commandArray['Scene:Abendlichter'] = "On"
            commandArray['Variable:Szenario_Abendlichter'] = 'On'
        elseif  ( uservariables['Szenario_Abendlichter'] == 'On' ) then
            print('Abendlichter sind an, schalte aus...')
            commandArray['Scene:Abendlichter'] = "Off"
            commandArray['Variable:Szenario_Abendlichter'] = 'Off'           
        end 
   elseif ( deviceName == 'Mi GW Schalter' and deviceValue  == 'Switch 2') then
        print('-- KLingel sollte angehen --')
        --commandArray['Mi GW Klingel'] = 'Set level 40'
        commandArray['Mi GW Klingel'] = 'On'
    end
end

return commandArray

First If Block works with the Scene, but why is the Last Event fired if i set the 'Mi GW Klingel' to 'On'? Don't understand this....

2017-11-15 14:18:19.312 LUA: Device based event fired on 'Mi GW Schalter', value 'Switch 2'
2017-11-15 14:18:19.312 LUA: -- KLingel sollte angehen --
2017-11-15 14:18:19.312 EventSystem: Script event triggered: Switch_Test
2017-11-15 14:18:19.513 LUA: Device based event fired on 'Mi GW Klingel', value 'Off'

commandArray['Mi GW Esszimmer'] = 'On' works and the Light at the Gateway is on......

Re: Playing Doorbell Sound on Xiaomi Gateway

Posted: Tuesday 21 November 2017 14:15
by nettworker
Noone a Idea?

No Solution from the Developers?

Cant understand that playing sound from the Website ( the automatic generated Icon ) works and if i try it from the Lua Code it will not work and on commandArray['Mi GW Klingel'] = 'Doorbell ring tone' the Event 'Device based event fired on 'Mi GW Klingel', value 'Off'' is fired and nothing works.....

Re: Playing Doorbell Sound on Xiaomi Gateway

Posted: Tuesday 21 November 2017 14:41
by jimicek
Hi,
this is a portion of code which works in my Domoticz:

Code: Select all

commandArray = {}

-- sound values:
-- 10 = Doorbell
-- 20 = Knock
-- 30 = Hilarious
-- 40 = Alarm clock

sound = 10
volume = 10

if devicechanged['Zvonek Xiaomi'] == 'Closed' then
	commandArray['Xiaomi Gateway Volume']='Set Level '..tostring(volume)
	commandArray['Xiaomi Gateway Doorbell']='Set Level '..tostring(sound)
end

return commandArray
-Jimicek

Re: Playing Doorbell Sound on Xiaomi Gateway

Posted: Tuesday 21 November 2017 19:58
by nettworker
THX, now it works. Seems it was the missing Gateway Volume.....

Re: Playing Doorbell Sound on Xiaomi Gateway

Posted: Tuesday 21 November 2017 21:30
by nettworker
Can I set the Color of the Gateway Ligth via LUA?