Blockly examples

Moderator: leecollings

denman091
Posts: 30
Joined: Monday 31 July 2017 15:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Pijnacker
Contact:

Re: Blockly examples

Post by denman091 »

He,

i have one virtual switch for my smartphone and one for my wifes smartphone. if one of us is at home (connect with the wifi) the virtual switch turns on.
Now i want a variable that goes to "1" if one of the two virtual switches is on. and when both virtual switches are off (so we are not at home) the variable need to change to "0".

I made a user variable with type: Float and name "Thuis".
i made the following event:
Image
But the variable is not change.
I want to to use the variable state for other events.

Why is this not working?
Lolo
Posts: 1
Joined: Sunday 10 December 2017 18:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by Lolo »

Termostato virtual con Blockly.

Hola, este es mi termostato virtual con Blockly, la temperatura es tomada con un DHT22 conectado en un ESP8266, el radiador está conectado a un enchufe “Aeon Labs Smart Switch 6”, el termostato es “virtual”, en realidad son dos termostatos virtuales, uno para regular la temperatura mínima, y otro para regular la temperatura máxima.

Es muy sencillo de configurar, con un dedo desde el móvil eliges el rango de temperatura que quieras en cada momento del día, sin complicaciones de scripts en Lua.

Funcionamiento:

Cuando el interruptor Virtual “termostato Desvan” está en “On”, el enchufe "Frigo On/Off" se encenderá y apagara conforme a la temperatura mínima y máxima configuradas en los termostatos virtuales “Termostato Desvan –“ (minimo) y “Termostato Desvan +” (máximo).

Cuando el interruptor Virtual “termostato Desvan” está en “Off”, el enchufe "Frigo On/Off" NO será regulado por los termostatos virtuales “Termostato Desvan –“ (minimo) y “Termostato Desvan +” (máximo).

Translation:

Virtual thermostat with Blockly.

Hello, this is my virtual thermostat with Blockly, the temperature is taken with a DHT22 connected to an ESP8266, the radiator is connected to a socket "Aeon Labs Smart Switch 6", the thermostat is "virtual", they are actually two virtual thermostats , one to regulate the minimum temperature, and another to regulate the maximum temperature.

It is very simple to configure, with a finger from the mobile you choose the temperature range you want at each moment of the day, without complications of Lua scripts.

Functioning:

When the Virtual switch “termostato Desvan” is "On", the "Frigo On/Off" plug will turn on and off according to the minimum and maximum temperature set in the virtual thermostats " Termostato Desvan –" (minimum) and " Termostato Desvan +" (maximum).

When the Virtual Switch " termostato Desvan " is set to "Off", the "Frigo On/Off" plug will NOT be regulated by the virtual thermostats " Termostato Desvan –" (minimum) and " Termostato Desvan +" (maximum).


Image

Image
Spitfire
Posts: 20
Joined: Thursday 29 December 2016 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by Spitfire »

denman091 wrote: Thursday 07 December 2017 19:39 He,

i have one virtual switch for my smartphone and one for my wifes smartphone. if one of us is at home (connect with the wifi) the virtual switch turns on.
Now i want a variable that goes to "1" if one of the two virtual switches is on. and when both virtual switches are off (so we are not at home) the variable need to change to "0".

I made a user variable with type: Float and name "Thuis".
i made the following event:
Image
But the variable is not change.
I want to to use the variable state for other events.

Why is this not working?
I think its safe to say that ”Else if” in Blocky does not work as any other implementations of it in ANY language. It’s just a stack of if:s...so...DO NOT USE IT! I would not be suprised if it’s the most asked about issue on this board. So much trouble would have been saved if this was fixed.
BullFrog
Posts: 6
Joined: Sunday 03 December 2017 18:41
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Blockly examples

Post by BullFrog »

What is the method to Turn ON/OFF with the same command? For example I want to turn off the lights with Cube shake, and also wanna turn on the lights when they are off with the same command, cube shake. If Do and Else IF does nothing.
blauwebuis
Posts: 331
Joined: Wednesday 21 December 2016 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: current
Contact:

Re: Blockly examples

Post by blauwebuis »

The new Aurora theme has a blockly import and export feature. That might be useful for the people in this thread :-)

viewtopic.php?f=8&t=20960
Xztraz
Posts: 107
Joined: Tuesday 31 January 2017 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by Xztraz »

Made a Blockly section in the Wiki.
www.domoticz.com/wiki/Blockly

Good place to collect experiences with blockly and it's rather own behavior.
blauwebuis
Posts: 331
Joined: Wednesday 21 December 2016 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: current
Contact:

Re: Blockly examples

Post by blauwebuis »

nice work! Could you explain a bit more how the trigger function works? I still don't quite understand what that does :-D
Xztraz
Posts: 107
Joined: Tuesday 31 January 2017 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by Xztraz »

blauwebuis wrote: Sunday 18 February 2018 16:22 Could you explain a bit more how the trigger function works?
Did fill in a bit more. a bit unsure about the ones i haven't tried so much yet. :)
thazand
Posts: 1
Joined: Saturday 24 February 2018 12:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Blockly examples

Post by thazand »

I've created this blockly to act as an alarm clock / wake up light. It's not a dimmer so it just switches on at a certain time.
I haven't found a way yet to read the time set in the iOS alarm and use that, so I have to set my alarm twice at night. However when I have to wake up multiple days in a row at the same time, there's no issue. I have to set the 'light alarm' separately as a virtual switch now.

I've added al these manual switches to a separate 'Alarm' room in the Home app.

Any suggestions om how to make this better / easier?
Attachments
Wekker.png
Wekker.png (91.95 KiB) Viewed 9043 times
thumbnail_IMG_6519.jpg
thumbnail_IMG_6519.jpg (29.19 KiB) Viewed 9045 times
CLEMENT99
Posts: 36
Joined: Friday 26 January 2018 9:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Blockly examples

Post by CLEMENT99 »

I made two events to turns on the light when a door is opened and turns off if no motion.

The first event turns on the light and the motion (type Blocky, DEVICE)
Capture11.JPG
Capture11.JPG (27.24 KiB) Viewed 8842 times
The second event turns off the light if no motion (type Blocky, ALL)
Capture22.JPG
Capture22.JPG (13.28 KiB) Viewed 8841 times
The problem is when the door stays open, the light does not turn off :-(
I thought that a blocky device event only changed when a state change occurred.
Here, many times the door stays open and unfortunately also the lights.
CLEMENT99
Posts: 36
Joined: Friday 26 January 2018 9:18
Target OS: Windows
Domoticz version: BETA
Location: Brussels
Contact:

Re: Blockly examples

Post by CLEMENT99 »

CLEMENT99 wrote: Monday 26 March 2018 12:58 I made two events to turns on the light when a door is opened and turns off if no motion.

The first event turns on the light and the motion (type Blocky, DEVICE)

Capture11.JPG

The second event turns off the light if no motion (type Blocky, ALL)

Capture22.JPG

The problem is when the door stays open, the light does not turn off :-(
I thought that a blocky device event only changed when a state change occurred.
Here, many times the door stays open and unfortunately also the lights.
Well, the problem seems to be that the second blocky with the "xiaomi human sensor"=OFF does not work.
I tried with "xiaomi human sensor" NOT EQUAL motion but it's also not working.
User avatar
Ragdag
Posts: 95
Joined: Friday 30 March 2018 13:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Post by Ragdag »

I'm pretty new to Domoticz and trying to accomplish something that should be fairly simple in my mind with Blocky but for the life of me I can't figure it out.

The idea is that at sunset I want to enable some lights for a duration of 4 hours but I want to randomly start them within 20 minutes. It seems that the combination of limited time and random start are not possible.
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 »

Ragdag wrote: Monday 02 April 2018 10:54 I'm pretty new to Domoticz and trying to accomplish something that should be fairly simple in my mind with Blocky but for the life of me I can't figure it out.

The idea is that at sunset I want to enable some lights for a duration of 4 hours but I want to randomly start them within 20 minutes. It seems that the combination of limited time and random start are not possible.
This is perfectly doable but perhaps a bit tricky. First of all, make it a time blockly and add a variable (integer with valua 0) for each light you'd like to control.
With 2 lights it becomes something like this:
Image

I think this'll do pretty much what you describe :)
User avatar
Ragdag
Posts: 95
Joined: Friday 30 March 2018 13:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly examples

Post by Ragdag »

tozzke wrote: Friday 06 April 2018 17:54
Ragdag wrote: Monday 02 April 2018 10:54 I'm pretty new to Domoticz and trying to accomplish something that should be fairly simple in my mind with Blocky but for the life of me I can't figure it out.

The idea is that at sunset I want to enable some lights for a duration of 4 hours but I want to randomly start them within 20 minutes. It seems that the combination of limited time and random start are not possible.
This is perfectly doable but perhaps a bit tricky. First of all, make it a time blockly and add a variable (integer with valua 0) for each light you'd like to control.
With 2 lights it becomes something like this:
Image

I think this'll do pretty much what you describe :)
Wow, thank you.
I think I understand what you're doing. You use the variable to work around the limitation of Domoticz to allow an extra evaluation.
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 »

I'm using the variables to switch instantly and prevent retriggering. If I won't be using the variables but the switch itself like 'if [Time = [Sunset]] and [TEST lamp 1] = [Off]', it would be triggering every minute because the light is still off the next minute and perhaps the next 19 minutes.
arek156
Posts: 7
Joined: Wednesday 10 January 2018 19:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Poland
Contact:

Re: Blockly examples

Post by arek156 »

Hello
Recently, I've been interested in domoticz, but there is a problem that I can not deal with. I count on the help of forum users. I built a script that verifies the garage door. If after 21:00 the system checks that it is open, it sends a pushover notification. Everything is ok but notifications are given every minute. Is it possible to set that open gate notifications appear every 15 minutes or every 30 minutes.
Attachments
blocky.png
blocky.png (14.52 KiB) Viewed 7981 times
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 »

that is possible using blockly by adding a variable so that you'll get something like:
If [Brama Anita] = [Open] and [Time > [21:00]] and [variable] = [0]
Do [Set [variable] = [1]]
[Send notification...]
[Set [variable] = [0] After [900] seconds]
arek156
Posts: 7
Joined: Wednesday 10 January 2018 19:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Poland
Contact:

Re: Blockly examples

Post by arek156 »

@tozzke
thank you very much for your help, in fact after adding the variables everything works perfectly.
SilentScreamer
Posts: 2
Joined: Wednesday 09 May 2018 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Blockly examples

Post by SilentScreamer »

I do not understand why my script does not work, i guess something goes wrong with the nested or function.
What I want is: If one of the four devices pings, and it is sunset (now i specified a specific time for testing), I want to turn on the four lights.

Does someone understand what is happening?

Image

Thanks in advance!
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 »

SilentScreamer wrote: Wednesday 09 May 2018 17:36 I do not understand why my script does not work, i guess something goes wrong with the nested or function.
What I want is: If one of the four devices pings, and it is sunset (now i specified a specific time for testing), I want to turn on the four lights.

Does someone understand what is happening?

Image

Thanks in advance!
You'll have to change it to:
If [Time] = [17:10] and [ [Jip Z5] = [On] or [Lenovo Jip] = [On] or [Z1 Sally] = [On] or [Lenovo Sally] = [On] ]
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest