Playing Doorbell Sound on Xiaomi Gateway

Moderator: leecollings

Post Reply
nettworker
Posts: 14
Joined: Thursday 16 February 2017 6:18
Target OS: -
Domoticz version:
Contact:

Playing Doorbell Sound on Xiaomi Gateway

Post 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?
nettworker
Posts: 14
Joined: Thursday 16 February 2017 6:18
Target OS: -
Domoticz version:
Contact:

Re: Playing Doorbell Sound on Xiaomi Gateway

Post 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......
nettworker
Posts: 14
Joined: Thursday 16 February 2017 6:18
Target OS: -
Domoticz version:
Contact:

Re: Playing Doorbell Sound on Xiaomi Gateway

Post 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.....
jimicek
Posts: 6
Joined: Monday 09 October 2017 9:35
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Playing Doorbell Sound on Xiaomi Gateway

Post 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
nettworker
Posts: 14
Joined: Thursday 16 February 2017 6:18
Target OS: -
Domoticz version:
Contact:

Re: Playing Doorbell Sound on Xiaomi Gateway

Post by nettworker »

THX, now it works. Seems it was the missing Gateway Volume.....
nettworker
Posts: 14
Joined: Thursday 16 February 2017 6:18
Target OS: -
Domoticz version:
Contact:

Re: Playing Doorbell Sound on Xiaomi Gateway

Post by nettworker »

Can I set the Color of the Gateway Ligth via LUA?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest