Blockly 1=0 always true and other problems Topic is solved

Moderator: leecollings

Post Reply
User avatar
AlanGpio
Posts: 15
Joined: Monday 24 February 2020 21:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Blockly 1=0 always true and other problems

Post by AlanGpio »

Hi I've spent most of the day experimenting with a Blockly script without success. It would be nice to get another opinion. This is the script:
Blockly Script 1.jpg
Blockly Script 1.jpg (73.8 KiB) Viewed 292 times
The Else if 0=1 is for "parking" unused bits of script as I' was getting fed up with deleting and recreating bits of script.

The ShutdownButton (gpio6) is normally High and goes Low when pressed. It is defined as a Push Off Button in Domoticz and as Both rising and falling edge in sys/gpio. When the button is pressed for just a second this is the log:

Code: Select all

 2020-03-24 20:02:01.128 (Raspberry Pi 4 HMS) Lighting 2 (ShutDownButton)
2020-03-24 20:02:01.130 EventSystem: Event triggered: SDB_Test_1
2020-03-24 20:02:01.447 (Raspberry Pi 4 HMS) Lighting 2 (ShutDownButton)
2020-03-24 20:02:01.449 EventSystem: Event triggered: SDB_Test_2
2020-03-24 20:02:01.124 Status: Sysfs GPIO: gpio6 new state = off
2020-03-24 20:02:01.130 Status: If is triggerred
2020-03-24 20:02:01.442 Status: Sysfs GPIO: gpio6 new state = on
2020-03-24 20:02:01.449 Status: Else if if is triggered
2020-03-24 20:02:11.474 (StatusFlags) Light/Switch (ShutdownStatusEnd)
2020-03-24 20:02:18.469 (StatusFlags) Light/Switch (ShutdownStatusEnd)
2020-03-24 20:02:18.464 Status: User: Admin initiated a switch command (
10 seconds later the ShutdownStatusEnd Light/Switch comes on. Logic says that 1=0 should never be true.

Further the log entry "Else if if is triggered" should also never happen as both variables ShutdownStatusStart and ShutdownStatusEnd have been set to 1 and 0 respectively.

Note that my first version used dummy switches for ShutdownStatusStart and ShutdownStatusEnd and the behaviour was the same.
Blockly Script 2.jpg
Blockly Script 2.jpg (42.77 KiB) Viewed 292 times

Code: Select all

 2020-03-24 20:29:09.317 Status: EventSystem: reset all events...
2020-03-24 20:29:20.284 Status: EventSystem: reset all events...
2020-03-24 20:29:55.759 (Raspberry Pi 4 HMS) Lighting 2 (ShutDownButton)
2020-03-24 20:29:55.761 EventSystem: Event triggered: SDB_Test2_1
2020-03-24 20:29:55.804 (StatusFlags) Light/Switch (ShutdownStatusStart)
2020-03-24 20:29:55.808 (StatusFlags) Light/Switch (ShutdownStatusEnd)
2020-03-24 20:29:55.754 Status: Sysfs GPIO: gpio6 new state = off
2020-03-24 20:29:55.761 Status: If is triggerred
2020-03-24 20:29:55.761 Status: set End=On after 10 secs goes here
2020-03-24 20:29:56.244 (Raspberry Pi 4 HMS) Lighting 2 (ShutDownButton)
2020-03-24 20:29:56.245 EventSystem: Event triggered: SDB_Test2_2
2020-03-24 20:29:56.254 (StatusFlags) Light/Switch (ShutdownStatusStart)
2020-03-24 20:29:56.259 (StatusFlags) Light/Switch (ShutdownStatusEnd)
2020-03-24 20:29:56.239 Status: Sysfs GPIO: gpio6 new state = on
2020-03-24 20:29:56.245 Status: Else if if is triggered
2020-03-24 20:30:06.255 (StatusFlags) Light/Switch (ShutdownStatusEnd)
2020-03-24 20:30:17.932 (StatusFlags) Light/Switch (ShutdownStatusEnd
I'm running this on a Rasp Pi 4 under Buster and within a Docker container. Domoticz V4.10364 (c)2012-2019 GizMoCuz and Build Hash: 1cacdddf, Date: 2019-01-25 10:01:48

I'm tempted to do this in python script but I'm having problems accessing the gpio pins.

Thanks for reading.
Alan
Hobbyist developing home automation on a Rasp Pi 4 under Buster off SSD.
Custom electronics to link to alarm system, doors, lights, cameras and door bell.
Running Domoticz in a Docker Container along with containers for Moquitto and Portainer.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly 1=0 always true and other problems

Post by waaren »

AlanGpio wrote: Tuesday 24 March 2020 21:43 Hi I've spent most of the day experimenting with a Blockly script without success. It would be nice to get another opinion. This is the script:
There are quite a number of posts on this forum mentioning that nested if's in Blockly does not work as expected. Just type
nested Blockly
in the search window on the forum and you will get dozens of hits.
Bottom line: "Don't use nested if in Blockly "
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest