Page 15 of 16

Re: Is it gonna rain within the next X minutes?

Posted: Sunday 28 January 2018 11:05
by mvroosmalen
Hi Mace,

Google is your friend :-)..... viewtopic.php?t=8231
create a bash file pushbullet.sh:

Code: Select all

#!/bin/bash
api=<Put_Your_API_KEY_HERE>
title=$1
body=$2
curl -u $api: https://api.pushbullet.com/v2/pushes -d type=note -d title=$title -d body=$body
and in the script:

Code: Select all

os.execute('/home/pi/domoticz/scripts/pushbullet.sh "Rain alert" "blabla......."')
or directly use this as a HTML code in the script...

s6 Mark

Re: Is it gonna rain within the next X minutes?

Posted: Tuesday 30 January 2018 13:07
by bobke77
Hi,

SInce I'm new here (or call me NOOB :D ) I just used the script as mentioned in the start post.

On my dashboard I get the text message : Regen verwacht, so the text file seems to be working (took me some time to figure out I had to use the chmod 0666).

Now I've got one problem: When I look in the Log it says:

2018-01-30 12:57:00.239 LUA: -- Regen verwacht(0-255 hoe hoger hoe meer regen): nan binnen 15 minuten.

Looking further iI notice that in the /var/tmp/ folder I can't open the rain.tmp file

It says: Object moved, this document can be found here
Then I get forwarded in Chromium and I can see the values.

How can I solve this ?

Re: Is it gonna rain within the next X minutes?

Posted: Tuesday 30 January 2018 21:33
by poudenes
Does someone have at the full script for me that work on dzVents 2.4.0?

Re: Is it gonna rain within the next X minutes?

Posted: Wednesday 31 January 2018 15:09
by mickmack82
bobke77 wrote: Tuesday 30 January 2018 13:07 Hi,

SInce I'm new here (or call me NOOB :D ) I just used the script as mentioned in the start post.

On my dashboard I get the text message : Regen verwacht, so the text file seems to be working (took me some time to figure out I had to use the chmod 0666).

Now I've got one problem: When I look in the Log it says:

2018-01-30 12:57:00.239 LUA: -- Regen verwacht(0-255 hoe hoger hoe meer regen): nan binnen 15 minuten.

Looking further iI notice that in the /var/tmp/ folder I can't open the rain.tmp file

It says: Object moved, this document can be found here
Then I get forwarded in Chromium and I can see the values.

How can I solve this ?
Try to add the -L paramter in the curl command: read = os.execute('curl -L -s -o '..tempfilename..' "'..url..'"')
This enable follow redirects using the location header flag

Re: Is it gonna rain within the next X minutes?

Posted: Wednesday 31 January 2018 15:26
by bobke77
mickmack82 wrote: Wednesday 31 January 2018 15:09 Try to add the -L paramter in the curl command: read = os.execute('curl -L -s -o '..tempfilename..' "'..url..'"')
This enable follow redirects using the location header flag
That's the one !
I had already changed this, but made it -s -o -L instead of -L -s -o :lol: :lol:

Many thanks mickmack !!!!!

Re: Is it gonna rain within the next X minutes?

Posted: Wednesday 31 January 2018 15:38
by poudenes
the -L parameter also solved my NIL problem :)

Re: Is it gonna rain within the next X minutes?

Posted: Wednesday 31 January 2018 16:17
by EdwinK
Now noticing an error regarding

Code: Select all

2018-01-31 16:09:12.436 Error: EventSystem: in Regen: [string "---------------------------------------------..."]:27: module 'socket.http' not found:
no field package.preload['socket.http']
no file '/usr/local/share/lua/5.2/socket/http.lua'
no file '/usr/local/share/lua/5.2/socket/http/init.lua'
no file '/usr/local/lib/lua/5.2/socket/http.lua'
no file '/usr/local/lib/lua/5.2/socket/http/init.lua'
no file './socket/http.lua'
no file '/usr/local/lib/lua/5.2/socket/http.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket/http.so'
no file '/usr/local/lib/lua/5.2/socket.so'
no file '/usr/local/lib/lua/5.2/loadall.so'
no file './socket.so'
Didn't check often so don't know when this started to happen. Thought I had to do a sudo apt-get install socket.http, but that doesn't seem to work.

Now what?

Re: Is it gonna rain within the next X minutes?

Posted: Wednesday 31 January 2018 19:52
by mvroosmalen
You need to install the socket library and supporting code somewhere that Lua 5.2 can find.

It is explained on this page http://www.domoticz.com/wiki/Philips_Hu ... ng_Colours and the necassary supporting libraries are attached to the linked forum message.

Mark

Re: Is it gonna rain within the next X minutes?

Posted: Thursday 01 February 2018 9:27
by EdwinK
But it used to work

Re: Is it gonna rain within the next X minutes?

Posted: Thursday 01 February 2018 11:50
by jvdz
EdwinK wrote: Thursday 01 February 2018 9:27 But it used to work
.. and then the next line should read: "and I haven't changed anything".. right? :D
In general these things happen when you either initially do an install or changed things on your system.

Jos

Re: Is it gonna rain within the next X minutes?

Posted: Thursday 01 February 2018 13:57
by EdwinK
jvdz wrote: Thursday 01 February 2018 11:50
EdwinK wrote: Thursday 01 February 2018 9:27 But it used to work
.. and then the next line should read: "and I haven't changed anything".. right? :D
In general these things happen when you either initially do an install or changed things on your system.

Jos
Almost ;) But I'm getting the hint.

Re: Is it gonna rain within the next X minutes?

Posted: Sunday 11 February 2018 18:06
by EdwinK
Still no luck :(

Re: Is it gonna rain within the next X minutes?

Posted: Sunday 11 February 2018 18:59
by mvroosmalen
still about the socket?? Please list the files found in /usr/local/share/lua/5.2 and dir below. It should list all the needed files...

Re: Is it gonna rain within the next X minutes?

Posted: Monday 12 February 2018 10:05
by EdwinK
Nope, this time it's the following.

Code: Select all

2018-02-12 10:03:00.440 Error: EventSystem: in Regen: [string "---------------------------------------------..."]:45: attempt to call global 'UrlEncode' (a nil value)
2018-02-12 10:04:00.360 Error: EventSystem: in Regen: [string "---------------------------------------------..."]:45: attempt to call global 'UrlEncode' (a nil value)
Had to look it up again, as I was trying several different scripts at different times.

Re: Is it gonna rain within the next X minutes?

Posted: Monday 12 February 2018 10:19
by EdwinK
And also this still

./buienradar.py
Traceback (most recent call last):
File "./buienradar.py", line 23, in <module>
import ssl
File "/usr/local/lib/python3.5/ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: No module named '_ssl'

domoticz@domo-server:/usr/local/share/lua/5.2 $ ls
ansicolors.lua luacolors.lua mobdebug.lua socket.lua
ltn12.lua mime.lua socket

Re: Is it gonna rain within the next X minutes?

Posted: Monday 12 February 2018 11:59
by mvroosmalen
Hi Edwin,

You miss the relevant files in /usr/local/share/lua/5.2. It should list:
socket
ssl
ansicolors.lua
JSON.lua
ltn12.lua
luacolors.lua
mime.lua
mobdebug.lua
socket.lua
ssl.lua

you could reinstall...

Mark

Re: Is it gonna rain within the next X minutes?

Posted: Wednesday 30 May 2018 20:56
by Venzent
I had this script previous and it was running fine. Re-installed Domoticz and did create this script again, but it just won't run.
Created a dummy switch "Rain expected"
Copy-pasted the script in the eventsystem and added my lat and lon (52.39 and 5.30).
Created the /var/tmp/rain.tmp file and chmodded it to 0777.
Sometimes when fiddling around I see it trigger once after changing or re-creating the script, but only once, the next minute is not triggered.
Currently it is not triggered at all.
I saved the script as Rain expected, type Lua and trigger Time. The script is activated and under settings, other, Event system "not active" is not checked....
Any thoughts?

Re: Is it gonna rain within the next X minutes?

Posted: Wednesday 30 May 2018 21:09
by Venzent
Venzent wrote: Wednesday 30 May 2018 20:56 I had this script previous and it was running fine. Re-installed Domoticz and did create this script again, but it just won't run.
Created a dummy switch "Rain expected"
Copy-pasted the script in the eventsystem and added my lat and lon (52.39 and 5.30).
Created the /var/tmp/rain.tmp file and chmodded it to 0777.
Sometimes when fiddling around I see it trigger once after changing or re-creating the script, but only once, the next minute is not triggered.
Currently it is not triggered at all.
I saved the script as Rain expected, type Lua and trigger Time. The script is activated and under settings, other, Event system "not active" is not checked....
Any thoughts?
I just enabled debugging and after 3 minutes i see this, so it did run (once), but now 5 minutes later, it didn't run again.
2018-05-30 21:00:00.532 dzVents: https://gadgets.buienradar.nl/data/rain ... 9&lon=5.30
2018-05-30 21:00:00.896 dzVents: Line:000|21:00
2018-05-30 21:00:00.896 dzVents: Linetime: 21:00
2018-05-30 21:00:00.896 dzVents: 0
2018-05-30 21:00:00.896 dzVents: Line:000|21:05
2018-05-30 21:00:00.896 dzVents: Linetime: 21:05
2018-05-30 21:00:00.896 dzVents: 300
2018-05-30 21:00:00.896 dzVents: Line in time range found
2018-05-30 21:00:00.896 dzVents: Rain in timerange: 0
2018-05-30 21:00:00.896 dzVents: Total rain now: 0
2018-05-30 21:00:00.896 dzVents: Line:000|21:10
2018-05-30 21:00:00.896 dzVents: Linetime: 21:10
2018-05-30 21:00:00.897 dzVents: 600
2018-05-30 21:00:00.897 dzVents: Line in time range found
2018-05-30 21:00:00.897 dzVents: Rain in timerange: 0
2018-05-30 21:00:00.897 dzVents: Total rain now: 0
2018-05-30 21:00:00.897 dzVents: Line:000|21:15
2018-05-30 21:00:00.897 dzVents: Linetime: 21:15
2018-05-30 21:00:00.897 dzVents: 900
2018-05-30 21:00:00.897 dzVents: Line in time range found
2018-05-30 21:00:00.897 dzVents: Rain in timerange: 0
2018-05-30 21:00:00.897 dzVents: Total rain now: 0
2018-05-30 21:00:00.897 dzVents: Line:000|21:20
2018-05-30 21:00:00.897 dzVents: Linetime: 21:20
2018-05-30 21:00:00.897 dzVents: 1200
2018-05-30 21:00:00.897 dzVents: Line in time range found
2018-05-30 21:00:00.897 dzVents: Rain in timerange: 0
2018-05-30 21:00:00.897 dzVents: Total rain now: 0
2018-05-30 21:00:00.897 dzVents: Line:000|21:25
2018-05-30 21:00:00.897 dzVents: Linetime: 21:25
2018-05-30 21:00:00.897 dzVents: 1500
2018-05-30 21:00:00.897 dzVents: Line:000|21:30
2018-05-30 21:00:00.897 dzVents: Linetime: 21:30
2018-05-30 21:00:00.897 dzVents: 1800
2018-05-30 21:00:00.897 dzVents: Line:000|21:35
2018-05-30 21:00:00.897 dzVents: Linetime: 21:35
2018-05-30 21:00:00.897 dzVents: 2100
2018-05-30 21:00:00.897 dzVents: Line:000|21:40
2018-05-30 21:00:00.898 dzVents: Linetime: 21:40
2018-05-30 21:00:00.898 dzVents: 2400
2018-05-30 21:00:00.898 dzVents: Line:000|21:45
2018-05-30 21:00:00.898 dzVents: Linetime: 21:45
2018-05-30 21:00:00.898 dzVents: 2700
2018-05-30 21:00:00.898 dzVents: Line:000|21:50
2018-05-30 21:00:00.898 dzVents: Linetime: 21:50
2018-05-30 21:00:00.898 dzVents: 3000
2018-05-30 21:00:00.898 dzVents: Line:000|21:55
2018-05-30 21:00:00.898 dzVents: Linetime: 21:55
2018-05-30 21:00:00.898 dzVents: 3300
2018-05-30 21:00:00.898 dzVents: Line:000|22:00
2018-05-30 21:00:00.898 dzVents: Linetime: 22:00
2018-05-30 21:00:00.898 dzVents: 3600
2018-05-30 21:00:00.898 dzVents: Line:000|22:05
2018-05-30 21:00:00.898 dzVents: Linetime: 22:05
2018-05-30 21:00:00.898 dzVents: 3900
2018-05-30 21:00:00.898 dzVents: Line:000|22:10
2018-05-30 21:00:00.898 dzVents: Linetime: 22:10
2018-05-30 21:00:00.898 dzVents: 4200
2018-05-30 21:00:00.898 dzVents: Line:000|22:15
2018-05-30 21:00:00.898 dzVents: Linetime: 22:15
2018-05-30 21:00:00.898 dzVents: 4500
2018-05-30 21:00:00.898 dzVents: Line:000|22:20
2018-05-30 21:00:00.898 dzVents: Linetime: 22:20
2018-05-30 21:00:00.898 dzVents: 4800
2018-05-30 21:00:00.899 dzVents: Line:000|22:25
2018-05-30 21:00:00.899 dzVents: Linetime: 22:25
2018-05-30 21:00:00.899 dzVents: 5100
2018-05-30 21:00:00.899 dzVents: Line:000|22:30
2018-05-30 21:00:00.899 dzVents: Linetime: 22:30
2018-05-30 21:00:00.899 dzVents: 5400
2018-05-30 21:00:00.899 dzVents: Line:000|22:35
2018-05-30 21:00:00.899 dzVents: Linetime: 22:35
2018-05-30 21:00:00.899 dzVents: 5700
2018-05-30 21:00:00.899 dzVents: Line:000|22:40
2018-05-30 21:00:00.899 dzVents: Linetime: 22:40
2018-05-30 21:00:00.899 dzVents: 6000
2018-05-30 21:00:00.899 dzVents: Line:000|22:45
2018-05-30 21:00:00.899 dzVents: Linetime: 22:45
2018-05-30 21:00:00.899 dzVents: 6300
2018-05-30 21:00:00.899 dzVents: Line:000|22:50
2018-05-30 21:00:00.899 dzVents: Linetime: 22:50
2018-05-30 21:00:00.899 dzVents: 6600
2018-05-30 21:00:00.899 dzVents: Line:000|22:55
2018-05-30 21:00:00.899 dzVents: Linetime: 22:55
2018-05-30 21:00:00.899 dzVents: 6900
2018-05-30 21:00:00.899 dzVents: Regen verwacht: 0 mm binnen 20 minuten.

Re: Is it gonna rain within the next X minutes?

Posted: Wednesday 30 May 2018 21:50
by Venzent
Mmmmm, it seems to run every 15 minutes. Is this something new??
Probably this line:
if ((time.min % 15)==0) then
Which is fine by me, every minute is an overkill, but to my knowledge it did run every minute....
Never mind, case closed :-)

Re: Is it gonna rain within the next X minutes?

Posted: Wednesday 18 July 2018 23:39
by DickN
Hi,

In Hardware I have created a virtual sensor with type Regen
MWSnap002.jpg
MWSnap002.jpg (7.84 KiB) Viewed 2970 times
In devices i can see now:
The attachment MWSnap002.jpg is no longer available
Idx=782

and in the weather tab:
is correctly shown
MWSnap001.jpg
MWSnap001.jpg (26.91 KiB) Viewed 2969 times
Also when I open the Log:
is alsocorrectly shown.

So far everything is OKe

When I edit my script with:
RainDeviceIDX=778
commandArray[1] = {['UpdateDevice'] = RainDeviceIDX .. '|'..tostring(RainPrediction)..'|'..tostring(verw)}
The divice in the weather tab is not lookingen like before.
The log-file does niet appear anymore.

Can somebody tell me what I did wrong