Blockly examples

Moderator: leecollings

SilentScreamer
Posts: 2
Joined: Wednesday 09 May 2018 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by SilentScreamer »

Thanks, that worked very well, thanks for the unreal fast response!
shamie
Posts: 8
Joined: Wednesday 20 June 2018 22:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by shamie »

I cannot figure out why my blockly isnt working, i hope you guys can give me some advice..

i want to close my suncreen (zonnescherm) when it's in state of Open and when its 22:00 (in case i am not home and i forget to close the screen by myself.)
when it closes i want it to send out an message to Kodi and an e-mail and mentioned in the log.

Image

what is wrong here?
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Blockly examples

Post by StanHD »

shamie wrote:I cannot figure out why my blockly isnt working, i hope you guys can give me some advice..

i want to close my suncreen (zonnescherm) when it's in state of Open and when its 22:00 (in case i am not home and i forget to close the screen by myself.)
when it closes i want it to send out an message to Kodi and an e-mail and mentioned in the log.

Image

what is wrong here?
Try formating like this:-

If [Switch = State] and [Time = ??:??]
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
cobra045
Posts: 46
Joined: Friday 12 February 2016 20:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Contact:

Re: Blockly examples

Post by cobra045 »

Try this
2018-06-21_10h28_03.png
2018-06-21_10h28_03.png (15.42 KiB) Viewed 4602 times

Cobra045
shamie
Posts: 8
Joined: Wednesday 20 June 2018 22:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by shamie »

StanHD wrote: Wednesday 20 June 2018 22:48
shamie wrote:I cannot figure out why my blockly isnt working, i hope you guys can give me some advice..

i want to close my suncreen (zonnescherm) when it's in state of Open and when its 22:00 (in case i am not home and i forget to close the screen by myself.)
when it closes i want it to send out an message to Kodi and an e-mail and mentioned in the log.

Image

what is wrong here?
Try formating like this:-

If [Switch = State] and [Time = ??:??]
cobra045 wrote: Thursday 21 June 2018 10:35 Try this

2018-06-21_10h28_03.png


Cobra045

Thank you both, that helped me out a lot, its a logical thing after all 8-)
it didn't work for the first time, the sunscreen didnt go up, but i did get a mail, sow the part before "Do" worked.
after some testing i decided to use the group where the sunscreen belongs to.

so now i have this working:
Image

i don't understand why the suncreen goes to "close" but turning the group to "off" works :D
tozzke
Posts: 135
Joined: Friday 02 January 2015 9:22
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands
Contact:

Re: Blockly examples

Post by tozzke »

You'll probably have to use 'Open'/'Closed' in the If statement and 'On'/'Off' in the Do section
shamie
Posts: 8
Joined: Wednesday 20 June 2018 22:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by shamie »

tozzke wrote: Friday 22 June 2018 17:49 You'll probably have to use 'Open'/'Closed' in the If statement and 'On'/'Off' in the Do section
yeah maybe i will give that a shot as well.
Benneton
Posts: 111
Joined: Thursday 08 December 2016 9:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by Benneton »

Hi,

Working on similar script, to have my screens closed when it is after 07:30 and before 18:00.
Script checks if screen is open, then time check followed by actual status of light sensor. when bigger then 1100lux screen to close.
This is what I made of it:

Image

It works for the part that the screen needs to close.

I also have a script that opens the screen at 19:00 hours.
When screens are closed the script opens them. Problem is that the script to close the screens then closes them and I get looped in open /close.

It appears that the time statement is not working in the screens_neer script.

Below what I made to open the screens
Image

Any ideas what I am overlooking or not understanding correctly?
Help much appreciated.

Bernard
Benneton
Posts: 111
Joined: Thursday 08 December 2016 9:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by Benneton »

Looking at it I believe I have worked it out.
In the time statement it sould be AND instead of OR.

Will change and see if it works tomorrow.

Bernard
Benneton
Posts: 111
Joined: Thursday 08 December 2016 9:46
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by Benneton »

That did the trick :)
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Blockly examples

Post by EdddieN »

Has anyone got read power working?
I'm trying to do this:
Screen Shot 2018-07-31 at 21.46.03.png
Screen Shot 2018-07-31 at 21.46.03.png (29.71 KiB) Viewed 3789 times
I have a wall tablet with an inline aeon smart relay. When the tablet is charging, it usually charges over 10 Watts. I want to disconnect the power of the power supply after 1h when its power consumption drops below 10 Watts (about getting fully charged).

I have this tablet always on and charging, and I'm having problems with it I think due to overheating (always powered to the power supply).

The first part of it: if power < 10 does not seem to work in blockly for me, is there a way to get the power reading?
11101101 - www.machinon.com
henk99
Posts: 28
Joined: Thursday 02 March 2017 11:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by henk99 »

I'm trying blocky to have domoticz send me a notification when the outside temperature gets below the temperature inside the house, so I have to start opening doors and windows. I'm using blocky as I have no idea how to program in Lua. However, I can't get it to work properly.

I have setup a virtual switch (Woonkamer_Temp) that is set to ON when outside_temp < livingroom_temp AND time is between 18.00-2330 hrs
In the virtual switch (Woonkamer_Temp) I have setup a notification when it switches to ON

The switching part works like a charm, however I keep getting notification every minute or so. I can see in the log that the 'Woonkamer_Temp' switch is polled all the time, hence sending a new notification every time. How can I prevent domoticz from doing that? I just want to have a notification one time. Can't get it to work in blocky.

Version 1
B.JPG
B.JPG (57.73 KiB) Viewed 3689 times
Version 2
Attachments
Blocky3.JPG
Blocky3.JPG (47.2 KiB) Viewed 3688 times
Blocky2.JPG
Blocky2.JPG (38.46 KiB) Viewed 3688 times
Last edited by henk99 on Thursday 02 August 2018 16:50, edited 4 times in total.
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Blockly examples

Post by EdddieN »

Make sure you select the right trigger event (device, time, etc...) on your blockly diagram
11101101 - www.machinon.com
henk99
Posts: 28
Joined: Thursday 02 March 2017 11:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by henk99 »

EdddieN wrote: Thursday 02 August 2018 16:30 Make sure you select the right trigger event (device, time, etc...) on your blockly diagram
I'm sorry, can you elaborate? I'm fairly new to this. What I would like doesn't seem too difficult in my mind, but the blockys I made don't work. They keep repeating. I just want domoticz to send me one notification...it sounds so simple, and in Lua it is perhaps, but I can't figure out programming like that, i'm sorry. So, I'm either hoping for someone to show me what is wrong in my blocky or someone that can show me a lua script for me to figure out.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Post by waaren »

henk99 wrote: Thursday 02 August 2018 16:26 I'm trying blocky to have domoticz send me a notification when the outside temperature gets below the temperature inside the house, so I have to start opening doors and windows. I'm using blocky as I have no idea how to program in Lua. However, I can't get it to work properly.

I have setup a virtual switch (Woonkamer_Temp) that is set to ON when outside_temp < livingroom_temp AND time is between 18.00-2330 hrs
In the virtual switch (Woonkamer_Temp) I have setup a notification when it switches to ON

The switching part works like a charm, however I keep getting notification every minute or so. I can see in the log that the 'Woonkamer_Temp' switch is polled all the time, hence sending a new notification every time. How can I prevent domoticz from doing that? I just want to have a notification one time. Can't get it to work in blocky.
Your blockly does switch your notification triggerdevice every time the temperature condition evaluates to true.
Using the checkFirst option in dzVents you can prevent that . This small dzVents script should do the job.

Code: Select all

--  activateNotificationSwitch.lua 

return { 
         on = {   timer   =   {"every minute between 16:00 and 23:30 on 15/4-15/9"}}, -- during spring and summer

    execute = function(domoticz)
      
        if  domoticz.time.matchesRule("at 16:00-23:28") then
           if domoticz.devices("Buiten temperatuur").temperature <= domoticz.devices("Woonkamer").temperature then
                domoticz.devices("Woonkamer_Temp").switchOn().checkFirst()
           end
        else
            domoticz.devices("Woonkamer_Temp").switchOff().checkFirst()
        end      
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Blockly examples

Post by EdddieN »

henk99 wrote: Thursday 02 August 2018 17:11
EdddieN wrote: Thursday 02 August 2018 16:30 Make sure you select the right trigger event (device, time, etc...) on your blockly diagram
I'm sorry, can you elaborate? I'm fairly new to this. What I would like doesn't seem too difficult in my mind, but the blockys I made don't work. They keep repeating. I just want domoticz to send me one notification...it sounds so simple, and in Lua it is perhaps, but I can't figure out programming like that, i'm sorry. So, I'm either hoping for someone to show me what is wrong in my blocky or someone that can show me a lua script for me to figure out.
No worries! Here, under blockly you have many options there how to trigger the event
Screen Shot 2018-08-02 at 20.41.09.png
Screen Shot 2018-08-02 at 20.41.09.png (53.65 KiB) Viewed 3663 times
11101101 - www.machinon.com
henk99
Posts: 28
Joined: Thursday 02 March 2017 11:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by henk99 »

waaren wrote: Thursday 02 August 2018 18:08 Your blockly does switch your notification triggerdevice every time the temperature condition evaluates to true.
Using the checkFirst option in dzVents you can prevent that . This small dzVents script should do the job.

Code: Select all

--  activateNotificationSwitch.lua 

return { 
         on = {   timer   =   {"every minute between 16:00 and 23:30 on 15/4-15/9"}}, -- during spring and summer

    execute = function(domoticz)
      
        if  domoticz.time.matchesRule("at 16:00-23:28") then
           if domoticz.devices("Buiten temperatuur").temperature <= domoticz.devices("Woonkamer").temperature then
                domoticz.devices("Woonkamer_Temp").switchOn().checkFirst()
           end
        else
            domoticz.devices("Woonkamer_Temp").switchOff().checkFirst()
        end      
end
}
Hi Waaren. thank you so much! I have implemented it in my domoticz and it worked like a charm. Very happy with this!
Hoekies
Posts: 5
Joined: Wednesday 13 January 2016 15:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Blockly examples

Post by Hoekies »

henk99 wrote: Friday 03 August 2018 11:21 Your blockly does switch your notification triggerdevice every time the temperature condition evaluates to true.
Using the checkFirst option in dzVents you can prevent that . This small dzVents script should do the job.

Code: Select all

--  activateNotificationSwitch.lua 

return { 
         on = {   timer   =   {"every minute between 16:00 and 23:30 on 15/4-15/9"}}, -- during spring and summer

    execute = function(domoticz)
      
        if  domoticz.time.matchesRule("at 16:00-23:28") then
           if domoticz.devices("Buiten temperatuur").temperature <= domoticz.devices("Woonkamer").temperature then
                domoticz.devices("Woonkamer_Temp").switchOn().checkFirst()
           end
        else
            domoticz.devices("Woonkamer_Temp").switchOff().checkFirst()
        end      
end
}
Is the last piece of the code not. The else is for the temperature check,

Code: Select all

           if domoticz.devices("Buiten temperatuur").temperature <= domoticz.devices("Woonkamer").temperature then
                domoticz.devices("Woonkamer_Temp").switchOn().checkFirst()
                else
          	domoticz.devices("Woonkamer_Temp").switchOff().checkFirst()
       		end   
        end   
end
henk99
Posts: 28
Joined: Thursday 02 March 2017 11:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by henk99 »

waaren wrote: Thursday 02 August 2018 18:08
henk99 wrote: Thursday 02 August 2018 16:26 I'm trying blocky to have domoticz send me a notification when the outside temperature gets below the temperature inside the house, so I have to start opening doors and windows. I'm using blocky as I have no idea how to program in Lua. However, I can't get it to work properly.

I have setup a virtual switch (Woonkamer_Temp) that is set to ON when outside_temp < livingroom_temp AND time is between 18.00-2330 hrs
In the virtual switch (Woonkamer_Temp) I have setup a notification when it switches to ON

The switching part works like a charm, however I keep getting notification every minute or so. I can see in the log that the 'Woonkamer_Temp' switch is polled all the time, hence sending a new notification every time. How can I prevent domoticz from doing that? I just want to have a notification one time. Can't get it to work in blocky.
Your blockly does switch your notification triggerdevice every time the temperature condition evaluates to true.
Using the checkFirst option in dzVents you can prevent that . This small dzVents script should do the job.

Code: Select all

--  activateNotificationSwitch.lua 

return { 
         on = {   timer   =   {"every minute between 16:00 and 23:30 on 15/4-15/9"}}, -- during spring and summer

    execute = function(domoticz)
      
        if  domoticz.time.matchesRule("at 16:00-23:28") then
           if domoticz.devices("Buiten temperatuur").temperature <= domoticz.devices("Woonkamer").temperature then
                domoticz.devices("Woonkamer_Temp").switchOn().checkFirst()
           end
        else
            domoticz.devices("Woonkamer_Temp").switchOff().checkFirst()
        end      
end
}
One question/request on this. As this script is setting a virtual switch, I found out it remains switched on until I switch it off manually. I didn't know this, which results in the script thinking that it has already sent me the message. Is there a way that this script switches off the switch at midnight so it's off again the next day?
Hoekies
Posts: 5
Joined: Wednesday 13 January 2016 15:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Blockly examples

Post by Hoekies »

henk99 wrote: Monday 06 August 2018 13:26
waaren wrote: Thursday 02 August 2018 18:08
henk99 wrote: Thursday 02 August 2018 16:26 I'm trying blocky to have domoticz send me a notification when the outside temperature gets below the temperature inside the house, so I have to start opening doors and windows. I'm using blocky as I have no idea how to program in Lua. However, I can't get it to work properly.

I have setup a virtual switch (Woonkamer_Temp) that is set to ON when outside_temp < livingroom_temp AND time is between 18.00-2330 hrs
In the virtual switch (Woonkamer_Temp) I have setup a notification when it switches to ON

The switching part works like a charm, however I keep getting notification every minute or so. I can see in the log that the 'Woonkamer_Temp' switch is polled all the time, hence sending a new notification every time. How can I prevent domoticz from doing that? I just want to have a notification one time. Can't get it to work in blocky.
Your blockly does switch your notification triggerdevice every time the temperature condition evaluates to true.
Using the checkFirst option in dzVents you can prevent that . This small dzVents script should do the job.

Code: Select all

--  activateNotificationSwitch.lua 

return { 
         on = {   timer   =   {"every minute between 16:00 and 23:30 on 15/4-15/9"}}, -- during spring and summer

    execute = function(domoticz)
      
        if  domoticz.time.matchesRule("at 16:00-23:28") then
           if domoticz.devices("Buiten temperatuur").temperature <= domoticz.devices("Woonkamer").temperature then
                domoticz.devices("Woonkamer_Temp").switchOn().checkFirst()
           end
        else
            domoticz.devices("Woonkamer_Temp").switchOff().checkFirst()
        end      
end
}
One question/request on this. As this script is setting a virtual switch, I found out it remains switched on until I switch it off manually. I didn't know this, which results in the script thinking that it has already sent me the message. Is there a way that this script switches off the switch at midnight so it's off again the next day?
Place the end before the else statement behind the statement. Then the problem is solved.

Code: Select all

--  activateNotificationSwitch.lua 

return { 
         on = {   timer   =   {"every minute between 16:00 and 23:30 on 15/4-15/9"}}, -- during spring and summer

    execute = function(domoticz)
      
        if  domoticz.time.matchesRule("at 16:00-23:28") then
           if domoticz.devices("Buiten temperatuur").temperature <= domoticz.devices("Woonkamer").temperature then
                domoticz.devices("Woonkamer_Temp").switchOn().checkFirst()
           else
            domoticz.devices("Woonkamer_Temp").switchOff().checkFirst()
            end
        end      
end
}
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests