hmm not working how i want it.

can someone tell me how to read values from a ip adress?

I have on 192.168.0.70 my data comma separated and i want to read the 
values with:

import syslog
import requests
import weewx
from weewx.wxengine import StdService

class ds18b20(StdService):
    def __init__(self, engine, config_dict):
        super(ds18b20, self).__init__(engine, config_dict)
        d = config_dict.get('PondService', {})
        #self.filename = d.get('filename', 
'/home/weewx/public_html/data/ds18b20.txt')
        #self.filename = d.get('filename', 
'urllib2.urlopen("http://192.168.0.70";).read()')
        # link = "http://192.168.0.70";
        syslog.syslog(syslog.LOG_INFO, "ds18b20: using %s" % self.filename)
        self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_file)

    def read_file(self, event):
        try:
            with open(self.filename) as f:
                #value = f.read()
                line = f.readline()
                value = line.split(',')
            syslog.syslog(syslog.LOG_DEBUG, "ds18b20: found value of %s" % 
value)
            event.record['soilTemp1'] = float(value[0])
            event.record['soilTemp2'] = float(value[1])
            event.record['soilTemp3'] = float(value[2])
            event.record['soilTemp4'] = float(value[3])
        except Exception, e:
            syslog.syslog(syslog.LOG_ERR, "ds18b20: cannot read value: %s" 
% e)

i fail here. What is the line to read from URL? my both attempts are faulty 
:(



Am Samstag, 20. Januar 2018 20:31:25 UTC+1 schrieb Andreas Otten:
>
> Before i invent the wheel new  :)
>
> anybody have a *ino file with a http post to write the values in a file 
> from multiple ds18b20 sensors ?
>
> I have the weewx functions ready, but not the ino file for the esp8266
>
> if yes, i am happy when you share it :)
>
> if not i made one :)
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to