Domoticz read realtime.txt

Moderator: leecollings

Post Reply
cazz
Posts: 16
Joined: Sunday 04 March 2018 18:12
Target OS: Linux
Domoticz version:
Contact:

Domoticz read realtime.txt

Post by cazz »

Is it possible to make Domoticz to read a realtime.txt file that generate from Cumulus?
cazz
Posts: 16
Joined: Sunday 04 March 2018 18:12
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz read realtime.txt

Post 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?
cazz
Posts: 16
Joined: Sunday 04 March 2018 18:12
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz read realtime.txt

Post by cazz »

Have got it to work :)
assenzuid
Posts: 135
Joined: Friday 13 November 2015 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands, Emmen Area
Contact:

Re: Domoticz read realtime.txt

Post by assenzuid »

What have you changed to get it work?
I'm interest.
cazz
Posts: 16
Joined: Sunday 04 March 2018 18:12
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz read realtime.txt

Post 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 :)
assenzuid
Posts: 135
Joined: Friday 13 November 2015 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands, Emmen Area
Contact:

Re: Domoticz read realtime.txt

Post by assenzuid »

The text file is imported with http/https poller?
cazz
Posts: 16
Joined: Sunday 04 March 2018 18:12
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz read realtime.txt

Post 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])
hve22
Posts: 7
Joined: Wednesday 11 October 2017 23:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz read realtime.txt

Post 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??
cazz
Posts: 16
Joined: Sunday 04 March 2018 18:12
Target OS: Linux
Domoticz version:
Contact:

Re: Domoticz read realtime.txt

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest