someone who can help me out with a script
Moderator: leecollings
someone who can help me out with a script
hello all,
i have used domoticz for a while now, but i want to export my data to bidgely also.
i have found a script online and after some modifying it works now, but sometimes it halts.
when i look at the verbose output, i found out i have a socket timeout.
i guess my system is busy at the moment, getting or sending data to pvoutput, which is a other script that i am running.
but somehow i need some modifications in the script so that it retries after socket timeout. for now i can't see that a retry is used, but i have very little scripting skills only arduino programming.
is there someone who can help me with it?
kind regards,
bert
i have used domoticz for a while now, but i want to export my data to bidgely also.
i have found a script online and after some modifying it works now, but sometimes it halts.
when i look at the verbose output, i found out i have a socket timeout.
i guess my system is busy at the moment, getting or sending data to pvoutput, which is a other script that i am running.
but somehow i need some modifications in the script so that it retries after socket timeout. for now i can't see that a retry is used, but i have very little scripting skills only arduino programming.
is there someone who can help me with it?
kind regards,
bert
- Attachments
-
- bidgely.zip
- (13.96 KiB) Downloaded 41 times
Re: someone who can help me out with a script
error i get is
Code: Select all
Traceback (most recent call last):
File "bidgely.py", line 114, in <module>
loop()
File "bidgely.py", line 107, in loop
el_data, gas_data = gather_data(settings.get_setting("seconds"))
File "bidgely.py", line 58, in gather_data
success, ElectricitySerial, ElectricityRateUsedOffPeak, ElectricityRateUsedPeak, ElectricityCurrentRate, ElectricityTotalUsed, ElectricityTotalGenerated, ElectricitySwitchPosition, GasSerial, GasLogDateTime, GasTotal = settings.rd.get_data(settings.get_setting("verbose"))
File "/home/pi/testscripts/bidgely/domodata.py", line 15, in get_data
GasTotal, GasLogDateTime = get_gas_values(settings.get_setting("domoticzurl"), settings.get_setting("domoticzdeviceid_gas"))
File "/home/pi/testscripts/bidgely/domodata.py", line 107, in get_gas_values
device_data = Domoticz(url).get_device(device_id)
File "/home/pi/testscripts/bidgely/domodata.py", line 78, in get_device
data = json.load(self.__execute__(url))
File "/home/pi/testscripts/bidgely/domodata.py", line 71, in __execute__
return urllib2.urlopen(req, timeout=5)
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1200, in do_open
r = h.getresponse(buffering=True)
File "/usr/lib/python2.7/httplib.py", line 1111, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 444, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 400, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
socket.timeout: timed out
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: someone who can help me out with a script
Does your script run in a loop?
Why not just execute once and execute it by cron?
That way, if it exits it'll just run again a minute later.
Why not just execute once and execute it by cron?
That way, if it exits it'll just run again a minute later.
Re: someone who can help me out with a script
I borrowed this script from someone else because I can't script myself. So i wouldn't know how to make this script run once. It works but locks up sometimes.
Verstuurd vanaf mijn P6-U06 met Tapatalk
Verstuurd vanaf mijn P6-U06 met Tapatalk
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: someone who can help me out with a script
I don't know Python very good, but this would be my guess:
In bidgely.py there's a "while 1:" loop wich runs forever. In another part of the code (domodata.py:58) there's a sleep of 10 seconds. The script runs every 10 seconds.
So, if you change the endless while 1 loop to a loop that runs 6 times and execute the script by cron every minute it should run forever.
Try this:
change bidgely.py line 106:
to
And add the script to cron:
sudo crontab -e
* * * * * /path/to/script.py
In bidgely.py there's a "while 1:" loop wich runs forever. In another part of the code (domodata.py:58) there's a sleep of 10 seconds. The script runs every 10 seconds.
So, if you change the endless while 1 loop to a loop that runs 6 times and execute the script by cron every minute it should run forever.
Try this:
change bidgely.py line 106:
Code: Select all
while 1:
Code: Select all
for _ in " "*6:
sudo crontab -e
* * * * * /path/to/script.py
Re: someone who can help me out with a script
Will try that thanks, do i have to change the sleep command also?
Edit: or the sleep uses 10 and the other lines makes it run 6 times. So this script will run 1 minute. And cron makes it run every minute.
Edit: or the sleep uses 10 and the other lines makes it run 6 times. So this script will run 1 minute. And cron makes it run every minute.
Re: someone who can help me out with a script
Hmm for_in gives invalid syntax
Verstuurd vanaf mijn P6-U06 met Tapatalk
Verstuurd vanaf mijn P6-U06 met Tapatalk
Re: someone who can help me out with a script
Hmm for_in gives invalid syntax
Re: someone who can help me out with a script
Any other ideas
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: someone who can help me out with a script
Must be python version.
Google for python loop 6 times and you'll find other ways.
Google for python loop 6 times and you'll find other ways.
Re: someone who can help me out with a script
It Works now seems I forgotten a space.
Who is online
Users browsing this forum: No registered users and 1 guest