Page 1 of 1

Domoticz read realtime.txt

Posted: Monday 05 March 2018 21:05
by cazz
Is it possible to make Domoticz to read a realtime.txt file that generate from Cumulus?

Re: Domoticz read realtime.txt

Posted: Tuesday 06 March 2018 23:12
by cazz
Hi again
I trying now to build my own but I have a litle problem with the API/JSON of Domoticz

I have create a Virtual sensors and a device that have "Temp" as type

everything looks fine and is time to insert info
Before I did connect all my script I did make it easy and just write a static value of the weather to a webbrowser

Code: Select all

http://<ipaddress>:8080/json.htm?type=command&param=udevice&idx=15&nvalue=1.2
as you can see the idx number is 15 and the value is set to 1.2
I get no error
{
"status" : "OK",
"title" : "Update Device"
}
but I get no update in the device?

Re: Domoticz read realtime.txt

Posted: Wednesday 07 March 2018 15:58
by cazz
Have got it to work :)

Re: Domoticz read realtime.txt

Posted: Wednesday 07 March 2018 20:55
by assenzuid
What have you changed to get it work?
I'm interest.

Re: Domoticz read realtime.txt

Posted: Wednesday 07 March 2018 22:15
by cazz
Well this page is a BIG help
https://www.domoticz.com/wiki/Domoticz_ ... .2Fsensors

I did notice that my address was not complete

So maybe soon I can get my info to my weather system at home :)

Re: Domoticz read realtime.txt

Posted: Thursday 08 March 2018 9:47
by assenzuid
The text file is imported with http/https poller?

Re: Domoticz read realtime.txt

Posted: Thursday 08 March 2018 13:55
by cazz
All I do is read the textfile with python
Split where it is space and then use the array in the http protocol to send info to the Domoticz

A example to write the temp

Code: Select all

file = open("realtime.txt", "r") 
vader = file.read().split(" ")
response = urllib2.urlopen('http://<ipaddress>:<port>/json.htm?type=command&param=udevice&idx=15&nvalue=0&svalue=' + vader[2])

Re: Domoticz read realtime.txt

Posted: Sunday 31 March 2019 14:19
by hve22
Hi Cazz,
I'v been trying to get it ro work on my Pi Zero, but sofar no luck.

All i get is when i'm usong the code as you described in the previous reply:

File "weerstation.py", line 3, in <module>
response = urllib2.urlopen('http://<ipadres>:<port>/json.htm?type=command&param=udevice&idx=4178&nvalue=0&svalue=' + vader[2])
NameError: name 'urllib2' is not defined

How to go from here??

Re: Domoticz read realtime.txt

Posted: Sunday 31 March 2019 17:47
by cazz
Hmm it was sometime now I did work with this (I run now Hassio) but what I can read is something with the python script
Not sure if that help but look at this page
https://stackoverflow.com/questions/279 ... 2/38906959


At first you can see when you run your address in a browser that it show a value and no error.
Make the address static and put that in a browser and see if you get a value or a error
If you got a value then it mean that urllib2 to get the info. if you get a error then is something with the info you trying to get that is wrong.