Blockly wont switch destination switch (SOLVED)

Moderator: leecollings

Post Reply
alarm_guy1
Posts: 132
Joined: Tuesday 14 January 2014 0:03
Target OS: Linux
Domoticz version:
Contact:

Blockly wont switch destination switch (SOLVED)

Post by alarm_guy1 »

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


blockly.jpg
blockly.jpg (37.63 KiB) Viewed 1278 times
blockly.jpg
blockly.jpg (37.63 KiB) Viewed 1278 times
Attachments
Blockly1.jpg
Blockly1.jpg (98.89 KiB) Viewed 1278 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

Post by snellejellep »

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

Post by alarm_guy1 »

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'

Blockly2.jpg
Blockly2.jpg (39.83 KiB) Viewed 1259 times

Cheers
mrf68

Re: Blockly wont switch destination switch

Post by mrf68 »

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.
domo1.jpg
domo1.jpg (9.12 KiB) Viewed 1253 times
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

Post by alarm_guy1 »

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

Post by alarm_guy1 »

I think i have done as specified.
but it still doesnt work :-(
Blockly3.jpg
Blockly3.jpg (34.56 KiB) Viewed 1248 times
mrf68

Re: Blockly wont switch destination switch

Post by mrf68 »

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

Post by alarm_guy1 »

cheers, sorry thought I had :-(
I will try harder thanks for the continued help
mrf68

Re: Blockly wont switch destination switch

Post by mrf68 »

Your blockly:
1.jpg
1.jpg (20.67 KiB) Viewed 1244 times
contains this compartment:
4.jpg
4.jpg (7.81 KiB) Viewed 1244 times
That makes no sense. This part does:
5.jpg
5.jpg (5.05 KiB) Viewed 1244 times
mrf68

Re: Blockly wont switch destination switch

Post by mrf68 »

Create this:
6.jpg
6.jpg (4.31 KiB) Viewed 1244 times
in the same way as this:
5.jpg
5.jpg (5.05 KiB) Viewed 1244 times
and put one to the left of AND and the other to the right of AND in this block:
7.jpg
7.jpg (5.2 KiB) Viewed 1244 times
mrf68

Re: Blockly wont switch destination switch

Post by mrf68 »

In short:
8.jpg
8.jpg (115.08 KiB) Viewed 1244 times
alarm_guy1
Posts: 132
Joined: Tuesday 14 January 2014 0:03
Target OS: Linux
Domoticz version:
Contact:

Re: Blockly wont switch destination switch (SOLVED)

Post by alarm_guy1 »

GOT IT
I finally got it

Cheers
Happy new year
mrf68

Re: Blockly wont switch destination switch

Post by mrf68 »

Glad it works. Best whishes.
alarm_guy1
Posts: 132
Joined: Tuesday 14 January 2014 0:03
Target OS: Linux
Domoticz version:
Contact:

Re: Blockly wont switch destination switch

Post by alarm_guy1 »

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
Blockly4.jpg
Blockly4.jpg (44.52 KiB) Viewed 1237 times
(HOME)
Away.jpg
Away.jpg (56.36 KiB) Viewed 1237 times
mrf68

Re: Blockly wont switch destination switch

Post by mrf68 »

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.
alarm_guy1
Posts: 132
Joined: Tuesday 14 January 2014 0:03
Target OS: Linux
Domoticz version:
Contact:

Re: Blockly wont switch destination switch

Post by alarm_guy1 »

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
mrf68

Re: Blockly wont switch destination switch

Post by mrf68 »

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):

Image

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)

Post by alarm_guy1 »

Cheers seems to be working as described. just waiting on my bluetooth devices to arrive and see what happens
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest