Blockly triggering condition

Moderator: leecollings

Post Reply
zaska
Posts: 5
Joined: Monday 19 October 2020 12:50
Target OS: Linux
Domoticz version:
Contact:

Blockly triggering condition

Post by zaska »

Hi,

I am asking for advice how to solve this.
I have two switches. One is active during daylight, second gets active (ON) when I come home and it's stays ON till I leave home.

I would like to trigger action (turn on light) when first switch is OFF (night) and when second switch goes to ON state (I come home).

Blockly: if switch 1 is OFF AND if switch 2 is ON, THAN turn on the light.
This works fine if I come at night.

The problem I would like to solve, that if I am already at home and first switch change it's state when day goes to night. This triggers this action too and I do not like that. Has anyone any idea how to solve this?
Summary: how to ignore when specific switch is changing its state and still have working AND condition when other switch changes state.

thank you for ideas and best regards.
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Blockly triggering condition

Post by AllesVanZelf »

If HOME = On AND { (Time >= Sunset AND Time <= 0:00) OR (Time > 0:00 AND Time <= Sunrise) }
Do Set Light = On


example:
Image

If this is not working as expected, you should try a DzVents script. There you can distinct trigger and condition.
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
zaska
Posts: 5
Joined: Monday 19 October 2020 12:50
Target OS: Linux
Domoticz version:
Contact:

Re: Blockly triggering condition

Post by zaska »

Hi,
yes I have done the same but it gets triggered at sunset.

Thank you for your hint with DzVent, I need to google it as I am not familiar with this. So if someone has maybe a minute to write this function above with DzVents (distinct), I will be verry grateful as my start with DzVents will be much more painless :idea: ;)
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Blockly triggering condition

Post by AllesVanZelf »

Try this:

Code: Select all

return
{
    on =
        {
        devices =
        {
            ['At-Home'] =
                {
				'between sunset and sunrise'
			    },
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
    },

    execute = function(dz)
        local home = dz.devices('At-Home').state
        local light = dz.devices('Light-1')

    
        dz.log('State of At-Home is '  .. home, dz.LOG_DEBUG)
        dz.log('State of Light-1 is '  .. light.state, dz.LOG_DEBUG)

       
        if home == 'On' and dz.time.matchesRule('between sunset and sunrise') then
            light.switchOn()
            
        end
    end
}
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
zaska
Posts: 5
Joined: Monday 19 October 2020 12:50
Target OS: Linux
Domoticz version:
Contact:

Re: Blockly triggering condition

Post by zaska »

Thank you very much my friend :!:
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest