Skip to content
This repository was archived by the owner on Aug 4, 2020. It is now read-only.
This repository was archived by the owner on Aug 4, 2020. It is now read-only.

Wrong negative values on xively #22

@giardia

Description

@giardia

Hello. I'm a newbie. So i just copy from an example script to make a feed in xively.

!/usr/bin/env python

import xively
import time
from datetime import datetime
import HTMLParser
import urllib

key= 'hidden'
feedid = '117061'
urlText = []

class parseText(HTMLParser.HTMLParser):
def handle_data(self,data):
if data != '\n' and data != '\r\n' and data != '\r\n\t':
urlText.append(data)

lParser = parseText()

lParser.feed(urllib.urlopen('http://www.idrografico.roma.it/ASP.NET/tempo_reale_ripetta.aspx').read())
lParser.close()

client = xively.Client(key)
now = datetime.now()
prelev = urlText[35]
lev = prelev.replace(",",".")
if lev > 0:
datastream = xively.Datastream(id="livello", current_value= lev)
client.put('/v2/feeds/'+feedid, data={'datastreams': [datastream]})
print "%s %s" % (now, lev)

The script app.py is parsing water_level data from a website and posting value in xively.
I'm using Heroku platform who run "python app.py" every hour thanks to Heroku Scheduler. (using venv , with git+git://github.com/xively/xively-python.git in the requirements.txt)

The data seem to be sent fine to xively but, every now and then, on a period of 1 week, it shows strange negative values like -999, as you can see from the graph at https://xively.com/feeds/117061/

Why this negative values are posted? They don't seems to come from the website parsing. (i mean, water_level cannot go under zero). How can i solve the issue?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions