Blockly wont switch destination switch (SOLVED)
Moderator: leecollings
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Blockly wont switch destination switch (SOLVED)
Hi guys, running Domoticz V4.11590
setup, what I thought was a simple blockly.
I am experimenting with presence detection before my BT Nuts arrive.
Effectively we will have 3 BT tags, only 2 of the tags will ever leave the house (for now) (Wife & van ) or (Wife & Pug)
1=wife
2=van
3=Pug
in the 1st test I just want a switch to change state if any 2 of the 2 BT devices above leave the house
As you can see from the image, If i manually switch off Jo & Pug or Jo & Van the switch BT_Switch does not change.
Any help
Cheers
setup, what I thought was a simple blockly.
I am experimenting with presence detection before my BT Nuts arrive.
Effectively we will have 3 BT tags, only 2 of the tags will ever leave the house (for now) (Wife & van ) or (Wife & Pug)
1=wife
2=van
3=Pug
in the 1st test I just want a switch to change state if any 2 of the 2 BT devices above leave the house
As you can see from the image, If i manually switch off Jo & Pug or Jo & Van the switch BT_Switch does not change.
Any help
Cheers
- Attachments
-
- Blockly1.jpg (98.89 KiB) Viewed 1270 times
Last edited by alarm_guy1 on Wednesday 01 January 2020 15:10, edited 1 time in total.
-
snellejellep
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: Blockly wont switch destination switch
you need to repeat the = off for jo and pug as well, then it will work
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Blockly wont switch destination switch
Hi thanks for the quick reply, only just had a chance to try.
I have revised my Blockly as per attached.
but this still does not work.
Obviously it is down to my lack of knowledge. but in my head it seems right
I also seem to get this random error too
2019-12-31 17:54:04.329 Error: EventSystem: Lua script error (Blockly), Name: Presence_Detection_DZ_1 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: ')' expected near 'comparevariable'
Cheers
I have revised my Blockly as per attached.
but this still does not work.
Obviously it is down to my lack of knowledge. but in my head it seems right
I also seem to get this random error too
2019-12-31 17:54:04.329 Error: EventSystem: Lua script error (Blockly), Name: Presence_Detection_DZ_1 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: ')' expected near 'comparevariable'
Cheers
-
mrf68
Re: Blockly wont switch destination switch
You cannot combine “if A and B = Off”, you need te seperate them “If A = Off AND B = Off” do X. A = Off needs to be one statement, B = Off needs to be one statement and you combine these two within a new statement with an AND between the statements. Your constructed blockly sounds logical when you read it out loud, but the system does not recognize the way you used the blocks.
First statement in left block, second statement in right block, left block to the left in middle block, right block te the right in middle block. Then the whole conrstruction after the IF.
First statement in left block, second statement in right block, left block to the left in middle block, right block te the right in middle block. Then the whole conrstruction after the IF.
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Blockly wont switch destination switch
Cool cheers for the quick reply, i'm on it now. i'll keep u posted 
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Blockly wont switch destination switch
I think i have done as specified.
but it still doesnt work
but it still doesnt work
-
mrf68
Re: Blockly wont switch destination switch
You tried, but did not do it the way as mentioned. I’ll be right back with more examples, but give a minute, it takes some time to write the little manual. 
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Blockly wont switch destination switch
cheers, sorry thought I had 
I will try harder thanks for the continued help
I will try harder thanks for the continued help
-
mrf68
Re: Blockly wont switch destination switch
Your blockly:
contains this compartment:
That makes no sense. This part does:
contains this compartment:
That makes no sense. This part does:
-
mrf68
Re: Blockly wont switch destination switch
Create this:
in the same way as this:
and put one to the left of AND and the other to the right of AND in this block:
in the same way as this:
and put one to the left of AND and the other to the right of AND in this block:
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Blockly wont switch destination switch (SOLVED)
GOT IT
I finally got it
Cheers
Happy new year
I finally got it
Cheers
Happy new year
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Blockly wont switch destination switch
Just a continuation if you dont mind, I have created 2 Blockly's
Presence_Detection_Home
Presence_Detection_Away
The Away seems to function correctly any 2 leave and BT_Switch Switches ON
Home however is proving more difficult, and I think needs more thought, and possibly LUA or DZVents
I need any one coming back to switch BT_Switch OFF, The difficulty is generally there is always one thing at home.
i.e. Jo goes to work and I go out in the van so PUG will be at home.
Jo will come back for lunch then go out
Any help appreciated
(HOME)
Presence_Detection_Home
Presence_Detection_Away
The Away seems to function correctly any 2 leave and BT_Switch Switches ON
Home however is proving more difficult, and I think needs more thought, and possibly LUA or DZVents
I need any one coming back to switch BT_Switch OFF, The difficulty is generally there is always one thing at home.
i.e. Jo goes to work and I go out in the van so PUG will be at home.
Jo will come back for lunch then go out
Any help appreciated
(HOME)
-
mrf68
Re: Blockly wont switch destination switch
Ofcourse I don't mind. But I'm sorry, I don't understand what you're trying to achieve. To me it makes no sense mentioning BT_Jo the second time in the Away script. IF BT_Jo is On, then this script will do nothing. When it's Off it might trigger the script, but then BT_Pug has to be Off or BT_Van has to be Off. BT_Jo in the last part is not necessary, it is checked being TRUE in the first part. So the Away will execute when:
[BT_Jo is Off] and [ [BT_Pug is Off] or [BT_Van is Off] ]
Possible situation: BT_Van turns On. Result: because of BT_Jo still being Off and BT_Pug still being Off, the script will turn BT_Switch to On.
Back to the original situation.
Next possible situation: BT_Pug turns On. Again: Result: because of BT_Jo still being Off and BT_Van still being Off, the script will turn BT_Switch to On.
Back to the original situation.
Next possible situation: BT_Jo turns On. Result: script does nothing, because first statement is FALSE and because it is followed by an AND, it makes the complete statement FALSE, therefore nothing happens.
Do you agree with me that the HOME script will only be executed when the BT_Van is On? So whenever it is Off, the BT_Switch will never be turned Off.
[BT_Jo is Off] and [ [BT_Pug is Off] or [BT_Van is Off] ]
Possible situation: BT_Van turns On. Result: because of BT_Jo still being Off and BT_Pug still being Off, the script will turn BT_Switch to On.
Back to the original situation.
Next possible situation: BT_Pug turns On. Again: Result: because of BT_Jo still being Off and BT_Van still being Off, the script will turn BT_Switch to On.
Back to the original situation.
Next possible situation: BT_Jo turns On. Result: script does nothing, because first statement is FALSE and because it is followed by an AND, it makes the complete statement FALSE, therefore nothing happens.
Do you agree with me that the HOME script will only be executed when the BT_Van is On? So whenever it is Off, the BT_Switch will never be turned Off.
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Blockly wont switch destination switch
Yes this is the situation i'm facing, my problem is we will have 3 bluetooth fobs.
1 for the wife (JO)
1 for me Van
1 for the car (Pug)
the wife doesn't drive, so on a week day generally the pug will be at home and van and Jo out
Come the weekends we may both go out in the the PUG
but there are many variables
but in essence as long the system can see 2 fobs at home and change BT_Switch to OFF,
I have amended the Blockly but i'm not quite there yet. I cant quite get my head round it. but it is bedtime no, i'll try again tomorrow, if u have any pointers that would be great
1 for the wife (JO)
1 for me Van
1 for the car (Pug)
the wife doesn't drive, so on a week day generally the pug will be at home and van and Jo out
Come the weekends we may both go out in the the PUG
but there are many variables
but in essence as long the system can see 2 fobs at home and change BT_Switch to OFF,
I have amended the Blockly but i'm not quite there yet. I cant quite get my head round it. but it is bedtime no, i'll try again tomorrow, if u have any pointers that would be great
-
mrf68
Re: Blockly wont switch destination switch
OK, I think I understand.
First we have to determine how many possibilities there are. There are 8. I wrote it down (H is Home, A is Away):

From this you can create several blocklys. I'll link a video which shows the scripts. You'll see them in one page, they need to be saved seperately.
Watch the video
It's not the most efficient, but can do the trick. I hope you can benefit from this. Now it's also bedtime for me.
First we have to determine how many possibilities there are. There are 8. I wrote it down (H is Home, A is Away):

From this you can create several blocklys. I'll link a video which shows the scripts. You'll see them in one page, they need to be saved seperately.
Watch the video
It's not the most efficient, but can do the trick. I hope you can benefit from this. Now it's also bedtime for me.
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Blockly wont switch destination switch (SOLVED, SOLVED, HERO)
Cheers seems to be working as described. just waiting on my bluetooth devices to arrive and see what happens
Who is online
Users browsing this forum: No registered users and 1 guest