Hello Eric,
Thank you for the swift reply.
I found timeout issues, but have to admit: As I am running a python script I ignored the .js discussions.
I am not using an addon, but an adapted version based on the python example. I try to derive a Thing which reads from the internal webserver:
from __future__ import division, print_function
from webthing import (Action, Event, MultipleThings, Property, Thing, Value,
WebThingServer)
import logging
import random
import time
import tornado.ioloop
import uuid
log = logging.getLogger('GetterThing')
log.setLevel(logging.DEBUG)
import os
import sys
dirname = os.path.dirname(__file__)
sys.path.insert(1, os.path.join(dirname, '../ReadFromWebServer'))
from ReadHTMLdata import readFromIP
class GetDataAction(Action):
def __init__(self, thing, input_):
Action.__init__(self, uuid.uuid4().hex, thing, 'collectData', input_=input_)
def perform_action(self):
self.input['IP-Adress']
self.thing.set_property('brightness', self.input['brightness'])
class DHT22_Sensor(Thing):
"""A device to read out a DHT sensor which is connected to the LAN, updates its measurement every 30 seconds."""
def __init__(self, IP = "192.168.0.100"):
Thing.__init__(
self,
'urn:dev:ops:my-DHT-URL-sensor',
'My Multipurpose Sensor on: '+IP,
['MultiLevelSensor'],
'A web connected Sensor to read out IP values'
)
self.humidity = Value(50.0)
self.add_property(
Property(self,
'Humidity',
self.humidity,
metadata={
'@type': 'LevelProperty',
'title': 'Humidity',
'type': 'number',
'description': 'The current humidity in %',
'minimum': 0,
'maximum': 100,
'unit': 'percent',
'readOnly': True,
}))
logging.debug('starting the sensor update looping task')
self.temp = Value(10.0)
self.add_property(
Property(self,
'Temperature',
self.temp,
metadata={
'@type': 'TemperatureProperty',
'title': 'Temperature',
'type': 'number',
'description': 'The current Temperature in degree celsius',
'unit': 'degree celsius',
'readOnly': True,
}))
self.timer = tornado.ioloop.PeriodicCallback(lambda: self.update_values(IP),5000)
self.timer.start()
def update_values(self, IP):
new_hum, newTemp = self.readIP(IP)
logging.debug('Reading Humidity level: %s', new_hum)
logging.debug('Reading Temperature level: %s', newTemp)
self.temp.notify_of_external_update(newTemp)
self.humidity.notify_of_external_update(new_hum)
def cancel_update_level_task(self):
self.timer.stop()
@staticmethod
def readIP(IP = "192.168.0.100"):
"""Reading from an actual sensor updating its every couple seconds."""
a = readFromIP()
strVal = a.getValues(IP, ret = True)
posHum = 2
posTemp = 3
strVal = a.getValues(IP, ret = True)
hum = float(strVal[posHum])
temp = float(strVal[posTemp])
return hum, temp
def run_server():
HumTempSensor1 = DHT22_Sensor(IP = "192.168.0.100")
server = WebThingServer(HumTempSensor1, 'PiServer', port=8888)
try:
logging.info('starting the server')
server.start()
except KeyboardInterrupt:
logging.debug('canceling the sensor update looping task')
HumTempSensor1.cancel_update_level_task()
logging.info('stopping the server')
server.stop()
logging.info('done')
if __name__ == '__main__':
logging.basicConfig(
level=10,
format="%(asctime)s %(filename)s:%(lineno)s %(levelname)s %(message)s"
)
run_server()
But as this stopped working properly I tried to debug by starting the example. This did not work either and the Gateway Log showed the increasing number (same did the Chromecast adapter b.t.w):
2022-01-29 16:59:41.259 ERROR : thing-url-adapter: (node:889) TimeoutOverflowWarning: 118639774953.81918 does not fit into a 32-bit signed integer.
2022-01-29 16:59:41.261 ERROR : thing-url-adapter: Timeout duration was set to 1.
2022-01-29 16:59:41.264 ERROR : thing-url-adapter: (node:889) TimeoutOverflowWarning: 127587159120.50343 does not fit into a 32-bit signed integer.
2022-01-29 16:59:41.265 ERROR : thing-url-adapter: Timeout duration was set to 1.
2022-01-29 16:59:41.266 ERROR : thing-url-adapter: (node:889) TimeoutOverflowWarning: 134183021018.23598 does not fit into a 32-bit signed integer.
2022-01-29 16:59:41.269 ERROR : thing-url-adapter: Timeout duration was set to 1.
2022-01-29 16:59:41.272 ERROR : thing-url-adapter: (node:889) TimeoutOverflowWarning: 141203322911.06372 does not fit into a 32-bit signed integer.
2022-01-29 16:59:41.274 ERROR : thing-url-adapter: Timeout duration was set to 1.
2022-01-29 16:59:41.277 ERROR : thing-url-adapter: (node:889) TimeoutOverflowWarning: 146818304000 does not fit into a 32-bit signed integer.
2022-01-29 16:59:41.279 ERROR : thing-url-adapter: Timeout duration was set to 1.
2022-01-29 16:59:41.284 ERROR : chromecast-adapter: (node:865) TimeoutOverflowWarning: 125452171085.27827 does not fit into a 32-bit signed integer.
2022-01-29 16:59:41.287 ERROR : chromecast-adapter: Timeout duration was set to 1.