I have created the following blockly script:
but in the log file, I find:
2016-08-12 19:35:00.517 Start
2016-08-12 19:35:00.517 195
2016-08-12 19:35:00.517 Light on
2016-08-12 19:35:00.517 Light off
Why is the If/Then not working?
If Then not working in Blockly?
Moderator: leecollings
-
- Posts: 16
- Joined: Monday 25 January 2016 23:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
If Then not working in Blockly?
Raspberry Pi 2 with latest beta version
1x Aeon Labs USB Z-Stick S2
5x Fibaro Modules
1x Aeon Labs USB Z-Stick S2
5x Fibaro Modules
-
- Posts: 135
- Joined: Friday 02 January 2015 9:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands
- Contact:
Re: If Then not working in Blockly?
as far as I know you can't use an If-block inside another If-block. You can only use an If-block and then multiple Else if-blocks
So what you should do is something like:
Except I don't know if you really want to add the first and last If-statements because this is going to trigger very often. You could change that by adding a variable 'Already_started?' with value 1/0 (Integer) or yes/no (String) so you'll get something like this:
Now the first and last statement will only trigger once between those times
So what you should do is something like:
Code: Select all
If [Time > 07:00] and [Time <= 23:45]
Do [Write to log "Start"]
[Write to log M-R Motion Sensor 1 - Lux actual]
Else if [Time > 07:00] and [Time <= 23:45] and [M-R Motion Sensor 1 - Lux actual <= 30]
Do [Write log "Light on"]
Else if [Time > 07:00] and [Time <= 23:45] and [M-R Motion Sensor 1 - Lux actual > 30]
Do [Write to log "Light off"]
Else if [Time < 07:00] or [Time > 23:45]
Do [Write to log "Lamp altijd uit"]
Code: Select all
If [Time > 07:00] and [Time <= 23:45] and [Var A-F Already_started? = "no"]
Do [Set Var A-F Already_started? = "yes"]
[Write to log "Start"]
[Write to log M-R Motion Sensor 1 - Lux actual]
Else if [Time > 07:00] and [Time <= 23:45] and [M-R Motion Sensor 1 - Lux actual <= 30]
Do [Write log "Light on"]
Else if [Time > 07:00] and [Time <= 23:45] and [M-R Motion Sensor 1 - Lux actual > 30]
Do [Write to log "Light off"]
Else if [Time < 07:00] or [Time > 23:45] and [Var A-F Already_started? = "yes"]
Do [Set Var A-F Already_started? = "no"]
[Write to log "Lamp altijd uit"]
-
- Posts: 16
- Joined: Monday 25 January 2016 23:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
Re: If Then not working in Blockly?
Thnx tozzke! That is the solution. Weird that I can not use nested if-blocks?
Raspberry Pi 2 with latest beta version
1x Aeon Labs USB Z-Stick S2
5x Fibaro Modules
1x Aeon Labs USB Z-Stick S2
5x Fibaro Modules
Who is online
Users browsing this forum: No registered users and 1 guest