doorbell script

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.
Post Reply
snellejellep
Posts: 125
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi
Domoticz version: 4.1xxxx
Location: The Neterlands
Contact:

doorbell script

Post by snellejellep » Monday 10 September 2018 21:20

dear forum users,

i have a wish and i do not know how to realize it, i have a button connected to domoticz which i want to use as a doorbell, when the doorbell is pressed i want some lights to flash, but is there a possibility to store the state of the light, activate a doorbell scene and after the scene restore the state off the lights.

for as far as i know this should be possible in dzvents but i do not know how to do that.

i hope someone can help me, thanks in advance!
raspberry pi | xiaomi gateway/vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ

User avatar
waaren
Posts: 1239
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: doorbell script

Post by waaren » Monday 10 September 2018 21:29

snellejellep wrote:
Monday 10 September 2018 21:20
i have a wish and i do not know how to realize it, i have a button connected to domoticz which i want to use as a doorbell, when the doorbell is pressed i want some lights to flash, but is there a possibility to store the state of the light, activate a doorbell scene and after the scene restore the state off the lights.
@snellejellep, Should be possible but some questions:
- are these standard on/off, -dimlights or rgbw type of lights
- howto "flash" these lights? Simple on/off or something else ?
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

snellejellep
Posts: 125
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi
Domoticz version: 4.1xxxx
Location: The Neterlands
Contact:

Re: doorbell script

Post by snellejellep » Monday 10 September 2018 21:40

waaren wrote:
snellejellep wrote:
Monday 10 September 2018 21:20
i have a wish and i do not know how to realize it, i have a button connected to domoticz which i want to use as a doorbell, when the doorbell is pressed i want some lights to flash, but is there a possibility to store the state of the light, activate a doorbell scene and after the scene restore the state off the lights.
@snellejellep, Should be possible but some questions:
- are these standard on/off, -dimlights or rgbw type of lights
- howto "flash" these lights? Simple on/off or something else ?
I use philips hue lights, some are rgb, some just white, i tought about just flashing the white ones and letting the rgb ones flash red, the color change is what makes it difficult i think.
Also i wanted to use the data from my motion sensors to let the lights flash only in the rooms people are

But first wanted to start with just the flashing
raspberry pi | xiaomi gateway/vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ

User avatar
HansieNL
Posts: 457
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: doorbell script

Post by HansieNL » Monday 10 September 2018 22:37

Maybe you can take a look at the HUE API. https://www.developers.meethue.com/docu ... ng-started
With a curl command a lot is possible:

Code: Select all

curl -H "Accept: application/json" -X PUT --data '{"alert":"select"}' http://<hue-bridge-ip>/api/<hue-username>/lights/4/state
Blah blah blah

User avatar
waaren
Posts: 1239
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: doorbell script

Post by waaren » Tuesday 11 September 2018 1:02

snellejellep wrote:
Monday 10 September 2018 21:40
waaren wrote:
snellejellep wrote:
Monday 10 September 2018 21:20
i have a wish and i do not know how to realize it, i have a button connected to domoticz which i want to use as a doorbell, when the doorbell is pressed i want some lights to flash, but is there a possibility to store the state of the light, activate a doorbell scene and after the scene restore the state off the lights.
@snellejellep, Should be possible but some questions:
- are these standard on/off, -dimlights or rgbw type of lights
- howto "flash" these lights? Simple on/off or something else ?
I use philips hue lights, some are rgb, some just white, i tought about just flashing the white ones and letting the rgb ones flash red, the color change is what makes it difficult i think.
Also i wanted to use the data from my motion sensors to let the lights flash only in the rooms people are

But first wanted to start with just the flashing
Maybe this example script will help in what you want to achieve. Another line of approach could be to trigger an IFTTT applet from this dzVents script.

Code: Select all

-- doorbell actions
 
return {
    on = { devices = {"Doorbell" } },
    
    logging =   {       level   =   domoticz.LOG_DEBUG,                  -- switch to LOG_INFO when results are OK 
                        marker  =   "doorbell actions" },                                           

    execute = function(dz, trigger)
     
        if trigger.state == "Off" then -- No action needed when doorbell switch back to Off state
            return
        end
        
        local rgbwLights    = {"Hue lightstrip","Hue Go","Hue rgbw1","Hue etc"}        -- table with rgbwlights that need to flash red
        local whiteLights   = {"lamp1","lamp2","lamp999"}                             -- table with white lights that need to flash
        
        local function flashRGBWLights()    
            local redflashDelay = 20 		-- delay in seconds
            for i = 1,#rgbwLights do  		-- walk the table from first (1) to last (#rgbwLights)
                local loopDevice = dz.devices(rgbwLights[i])
                local colorTable = dz.utils.fromJSON(loopDevice.color) 
                
                dz.log(loopDevice.name .. " ;state ===>> " .. loopDevice.state,dz.LOG_DEBUG)
                loopDevice.setRGB(255,0,0)                                                  -- Turn to RED
                loopDevice.switchOn()
                loopDevice.setRGB(colorTable.r, colorTable.g, colorTable.b).afterSec(redflashDelay)
                if loopDevice.state == "Off" then
                    dz.log("Schedule switchOff for " .. loopDevice.name,dz.LOG_DEBUG)
                    loopDevice.switchOff().afterSec(redflashDelay)
                end
            end
        end
        
        local function flashWhiteLights()    
            local whiteflashDelay = 1 -- delay in seconds
            for i = 1,#whiteLights do -- walk the table
                local loopDevice = dz.devices(whiteLights[i])
                local state      = loopDevice.state 
                dz.log(loopDevice.name .. " ;state ===>> " .. loopDevice.state,dz.LOG_DEBUG)
                if loopDevice.state == "Off" then
                    loopDevice.switchOn()
                    loopDevice.switchOff().afterSec(whiteflashDelay)
                else
                    loopDevice.switchOff()
                    loopDevice.switchOn().afterSec(whiteflashDelay)
                end
            end
        end
        
        flashRGBWLights()
        flashWhiteLights()

        end
}
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

snellejellep
Posts: 125
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi
Domoticz version: 4.1xxxx
Location: The Neterlands
Contact:

Re: doorbell script

Post by snellejellep » Tuesday 11 September 2018 19:24

thank you, it works great!
raspberry pi | xiaomi gateway/vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests