Nighttime and Daytime command not working Topic is solved

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!
Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
RikkieB
Posts: 41
Joined: Monday 28 March 2016 17:11
Target OS: Raspberry Pi
Domoticz version: 3.8934
Contact:

Nighttime and Daytime command not working

Post by RikkieB » Tuesday 19 December 2017 19:23

Version: V3.8794
Platform: Raspberry PI3

Description:
Nightime and Daytime command seems to be not working anymore.

I always get that Nightime is false. Daytime command is always true

script:

commandArray = {}

currentDate = os.date("%A:%x")
print (currentDate)
currentTime = os.date("%H:%M")
print (currentTime)

if timeofday['Nighttime']==true then print('NIGHTTIME')
elseif
timeofday['Nighttime']==false then print('DAYTIME')
end

return commandArray


Result:

2017-12-19 18:22:00.227 LUA: Tuesday:12/19/17
2017-12-19 18:22:00.227 LUA: 18:22
2017-12-19 18:22:00.227 LUA: DAYTIME

The sun went down at 16.33 h at my location

assenzuid
Posts: 154
Joined: Friday 13 November 2015 10:11
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands, Emmen Area
Contact:

Re: Nighttime and Daytime command not working

Post by assenzuid » Tuesday 19 December 2017 21:17

Noticed the same behavior today

SweetPants
Posts: 2056
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V3.9639
Location: The Netherlands
Contact:

Re: Nighttime and Daytime command not working

Post by SweetPants » Tuesday 19 December 2017 21:27

This could well be introduced by this change "Add support for Twilight and day length #1998" https://github.com/domoticz/domoticz/pull/1998
Ubuntu 16.04.3 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (source)

BakSeeDaa
Posts: 551
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version:

Re: Nighttime and Daytime command not working

Post by BakSeeDaa » Tuesday 19 December 2017 21:37

SweetPants wrote:
Tuesday 19 December 2017 21:27
This could well be introduced by this change "Add support for Twilight and day length #1998" https://github.com/domoticz/domoticz/pull/1998
I will take a look at that at once.

BakSeeDaa
Posts: 551
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version:

Re: Nighttime and Daytime command not working

Post by BakSeeDaa » Tuesday 19 December 2017 22:05

SweetPants wrote:
Tuesday 19 December 2017 21:27
This could well be introduced by this change "Add support for Twilight and day length #1998" https://github.com/domoticz/domoticz/pull/1998
I found the problem and I've issued a pull request to fix it.
In case you need a quick fix, it's only a single line of source code that is affected in the pull request.

Kochmeister
Posts: 17
Joined: Wednesday 24 February 2016 12:50
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Nighttime and Daytime command not working

Post by Kochmeister » Tuesday 19 December 2017 22:21

Hi Bakseedaa,
Can you explain how to get the quick-fix active?

SweetPants
Posts: 2056
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V3.9639
Location: The Netherlands
Contact:

Re: Nighttime and Daytime command not working

Post by SweetPants » Tuesday 19 December 2017 22:36

Kochmeister wrote:
Tuesday 19 December 2017 22:21
Can you explain how to get the quick-fix active?
https://github.com/domoticz/domoticz/pu ... 251936bf9f
Ubuntu 16.04.3 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (source)

Kochmeister
Posts: 17
Joined: Wednesday 24 February 2016 12:50
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Nighttime and Daytime command not working

Post by Kochmeister » Tuesday 19 December 2017 23:00

SweetPants wrote:
Tuesday 19 December 2017 22:36
Kochmeister wrote:
Tuesday 19 December 2017 22:21
Can you explain how to get the quick-fix active?
https://github.com/domoticz/domoticz/pu ... 251936bf9f
Could you be more specific?
Like what command to type in a RPI-3?
Or what file to modify on the RPI-3?
Thank you!

BakSeeDaa
Posts: 551
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version:

Re: Nighttime and Daytime command not working

Post by BakSeeDaa » Wednesday 20 December 2017 0:07

Kochmeister wrote:
Tuesday 19 December 2017 22:21
Hi Bakseedaa,
Can you explain how to get the quick-fix active?
If you need to fix it before the pull request gets through, you need to edit the single line of code in main/EventSystem.cpp that the pull requests affects.

It's only an option if you compile Domoticz yourself from source files.

That is:

At line 2751 in /home/pi/domoticz/main/EventSystem.cpp :

Replace

Code: Select all

	if (intRise == intSet == 0) {
with this:

Code: Select all

	if (intRise == 0 && intSet == 0) {
It will fix the problem.

Or as an alternative, if you don't want to edit anything, rightclick this link: https://raw.githubusercontent.com/BakSe ... System.cpp (save it locally) and replace the old file file with the name /home/pi/domoticz/main/EventSystem.cpp.

Then you can build new.

Thanks
Last edited by BakSeeDaa on Friday 23 February 2018 10:27, edited 2 times in total.

Kochmeister
Posts: 17
Joined: Wednesday 24 February 2016 12:50
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Nighttime and Daytime command not working

Post by Kochmeister » Wednesday 20 December 2017 6:48

pi@raspberrypi:~$ cd domoticz/
pi@raspberrypi:~/domoticz$ cd main
-bash: cd: main: No such file or directory

pi@raspberrypi:~/domoticz$ ls -ls
total 31248
4 -rw-r----- 1 root root 540 Dec 16 17:43 20.00
4 drwxr-x--- 5 root root 4096 Oct 12 2016 backups
4 drwxr-xr-x 80 pi pi 4096 Nov 16 08:45 Config
4 -rw-r----- 1 root root 451 Dec 20 05:36 domocookie.txt
13244 -rwxr-xr-x 1 pi pi 13558784 Dec 18 18:33 domoticz
8548 -rw-r--r-- 1 pi pi 8748032 Dec 20 05:35 domoticz.db
96 -rw-r--r-- 1 pi pi 98304 Dec 20 05:36 domoticz.db-shm
9180 -rw-r--r-- 1 pi pi 9398496 Dec 20 05:36 domoticz.db-wal
8 -rw-r--r-- 1 pi pi 4427 Aug 29 16:35 domoticz.sh
4 drwxr-xr-x 4 pi pi 4096 Oct 8 17:17 dzVents
4 drwxrwxrwx 2 root root 4096 Dec 20 03:01 GCal3
84 -rw-r--r-- 1 pi pi 85641 Oct 26 11:05 History.txt
36 -rw-r--r-- 1 pi pi 35147 Aug 29 16:35 License.txt
4 -rw-r----- 1 root root 233 Jun 11 2017 ozwcp.poll.XXXXXX.xml
4 drwxr-xr-x 4 pi pi 4096 Aug 29 16:35 plugins
4 drwxr-xr-x 8 pi pi 4096 Aug 29 16:35 scripts
4 -rw-r--r-- 1 pi pi 3414 Aug 29 16:35 server_cert.pem
4 -rwxr-xr-x 1 pi pi 583 Aug 29 16:35 updatebeta
4 -rwxr-xr-x 1 pi pi 600 Aug 29 16:35 updaterelease
4 drwxr-xr-x 13 pi pi 4096 Dec 18 11:18 www
pi@raspberrypi:~/domoticz$ pwd
/home/pi/domoticz
Okay, so I was looking in the right place, however this main folder does not seem to exist.
I did not yet want to mess wit the downloaded file by just adding the folder/file

Guess I will have to wait for the update.

BakSeeDaa
Posts: 551
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version:

Re: Nighttime and Daytime command not working

Post by BakSeeDaa » Wednesday 20 December 2017 9:33

Kochmeister wrote:
Wednesday 20 December 2017 6:48
Guess I will have to wait for the update.
That's the absolute best thing to do if you have used the Web Interface to update Domoticz to latest Beta. I don't think it will be long before next Beta version will be released.

In case you can't wait for for next Beta version after V3.8794 and if you have a single script or so, you can TRY to insert the following code snippet in your script. Put it just below the line "commandArray = {}"

Code: Select all

-- TEMPORARY FIX FOR Version: V3.8794 TO PROPERLY SET timeofday['Nighttime'] and timeofday['Daytime'] IN A SINGLE SCRIPT
minutesSinceMidnight = os.date("*t").min + (os.date("*t").hour * 60)
print('Temporary fix timeofday[\'Nighttime\'] and timeofday[\'Daytime\']')
if ((minutesSinceMidnight >= timeofday['SunriseInMinutes']) and (minutesSinceMidnight < timeofday['SunsetInMinutes'])) then
    timeofday['Nighttime'] = false
    timeofday['Daytime'] = true
else
    timeofday['Nighttime'] = true
    timeofday['Daytime'] = false
end
-- END TEMPORARY FIX

Don't forget to remove the code after you have upgraded. It's just a temporary fix that hasn't been tested a lot. It should only be used on version V3.8794 if you experience the problem and it should absolutely be removed after upgrading to a version later than V3.8794.

SweetPants
Posts: 2056
Joined: Friday 12 July 2013 21:24
Target OS: Linux
Domoticz version: V3.9639
Location: The Netherlands
Contact:

Re: Nighttime and Daytime command not working

Post by SweetPants » Wednesday 20 December 2017 14:35

Kochmeister wrote:
Wednesday 20 December 2017 6:48
pi@raspberrypi:~$ cd domoticz/
pi@raspberrypi:~/domoticz$ cd main
-bash: cd: main: No such file or directory

pi@raspberrypi:~/domoticz$ ls -ls
total 31248
4 -rw-r----- 1 root root 540 Dec 16 17:43 20.00
4 drwxr-x--- 5 root root 4096 Oct 12 2016 backups
4 drwxr-xr-x 80 pi pi 4096 Nov 16 08:45 Config
4 -rw-r----- 1 root root 451 Dec 20 05:36 domocookie.txt
13244 -rwxr-xr-x 1 pi pi 13558784 Dec 18 18:33 domoticz
8548 -rw-r--r-- 1 pi pi 8748032 Dec 20 05:35 domoticz.db
96 -rw-r--r-- 1 pi pi 98304 Dec 20 05:36 domoticz.db-shm
9180 -rw-r--r-- 1 pi pi 9398496 Dec 20 05:36 domoticz.db-wal
8 -rw-r--r-- 1 pi pi 4427 Aug 29 16:35 domoticz.sh
4 drwxr-xr-x 4 pi pi 4096 Oct 8 17:17 dzVents
4 drwxrwxrwx 2 root root 4096 Dec 20 03:01 GCal3
84 -rw-r--r-- 1 pi pi 85641 Oct 26 11:05 History.txt
36 -rw-r--r-- 1 pi pi 35147 Aug 29 16:35 License.txt
4 -rw-r----- 1 root root 233 Jun 11 2017 ozwcp.poll.XXXXXX.xml
4 drwxr-xr-x 4 pi pi 4096 Aug 29 16:35 plugins
4 drwxr-xr-x 8 pi pi 4096 Aug 29 16:35 scripts
4 -rw-r--r-- 1 pi pi 3414 Aug 29 16:35 server_cert.pem
4 -rwxr-xr-x 1 pi pi 583 Aug 29 16:35 updatebeta
4 -rwxr-xr-x 1 pi pi 600 Aug 29 16:35 updaterelease
4 drwxr-xr-x 13 pi pi 4096 Dec 18 11:18 www
pi@raspberrypi:~/domoticz$ pwd
/home/pi/domoticz
Okay, so I was looking in the right place, however this main folder does not seem to exist.
I did not yet want to mess wit the downloaded file by just adding the folder/file

Guess I will have to wait for the update.
This is because you are not compiling from source hence you miss the source code files to modify
Ubuntu 16.04.3 LTS, Intel NUC, MySensors 2.3.0-alpha, Pro Mini 3.3/8M RFM69(HW), ESP8266 (SDK2.2.0), Sonoff, RFLink, RFXcom, MQTT, NodeRed, Domoticz Beta (source)

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests