object_page http://www.yama-lab.org/fwb4pi/index.php?Value_insertion_01_20241007 or http://www.yama-lab.org/fwb4pi/index.php?Value_insertion_01_20241007
device yamaRasPiDp9_1 or yamaRasPiDp9_2 start after no write for 10 min.
command: set read_interval=60000
command: set exec_interval=0
command: set report_length=100
command: py test
py: import time
py: import re
py: map_url='http://www.yama-lab.org/fwb4pi/'
py: map_page='map01'
py: map_driver=pico_wiki_driver()
py: map_driver.set_url(map_url)
py: map_driver.set_page(map_page)
py: map_source=map_driver.get_wiki_source()
py: #print(map_source)
py: uris=[('01','http://www.yama-lab.org/fwb4pi/','sensor_01_20241007'),('02','http://www.yama-lab.org/fwb4pi/','sensor_02_20241007'),('04','http://www.yama-lab.org/fwb4pi/','sensor_04_20241120')]
py: sensor_driver=pico_wiki_driver()
py: for uri in uris:
py:   sensor_url=uri[1]
py:   sensor_page=uri[2]
py:   sensor_driver.set_url(sensor_url)
py:   sensor_driver.set_page(sensor_page)
py:   r=sensor_driver.get_result()
py:   ra=r.splitlines()
py:   temps=[]
py:   co2s=[]
py:   lxs=[]
py:   motions=[]
py:   for line in ra:
py:     if 'device=temp' in line:
py:        temps.append(line)
py:     if 'device=co2' in line:
py:        co2s.append(line) 
py:     if 'device=lx' in line:
py:        lxs.append(line)
py:     if 'device=motion' in line:
py:        motions.append(line)
py:   #
py:   # temperature 
py:   #print(ta)
py:   last_elm=temps[len(temps)-1]
py:   #print('last_temp='+last_elm)
py:   ela=last_elm.split(',')
py:   #print(ela)
py:   for e in ela:
py:     if 'v=' in e:
py:        tvx=e
py:   #print(tvx)
py:   tva=tvx.split('=')
py:   temp_value=tva[1]
py:   px=temp_value.find('.')
py:   print('px='+str(px))
py:   temp_value=temp_value[0:px+2]
py:   print('temp_value='+temp_value)  
py:   map_source = re.sub('temp_'+uri[0]+r'=\d+(\.\d+)?', 'temp_'+uri[0]+'='+f'{temp_value}', map_source)
py:   #
py:   # co2 
py:   #print(ta)
py:   last_elm=co2s[len(co2s)-1]
py:   #print('last_temp='+last_temp)
py:   ela=last_elm.split(',')
py:   #print(ela)
py:   for e in ela:
py:     if 'v=' in e:
py:        tvx=e
py:   #print(tvx)
py:   tva=tvx.split('=')
py:   co2_value=tva[1]
py:   print('co2_value='+co2_value)  
py:   map_source = re.sub('co2_'+uri[0]+r'=\d+(\.\d+)?','co2_'+uri[0]+'='+f'{co2_value}', map_source)
py:   #
py:   # lx 
py:   #print(ta)
py:   last_elm=lxs[len(lxs)-1]
py:   #print('last_temp='+last_temp)
py:   ela=last_elm.split(',')
py:   #print(ela)
py:   for e in ela:
py:     if 'v=' in e:
py:        tvx=e
py:   #print(tvx)
py:   tva=tvx.split('=')
py:   lx_value=tva[1]
py:   print('lx_value='+lx_value)  
py:   map_source = re.sub('lx_'+uri[0]+r'=\d+(\.\d+)?', 'lx_'+uri[0]+'='+f'{lx_value}', map_source)
py:   #
py:   # motion
py:   #print(ta)
py:   last_elm=motions[len(motions)-1]
py:   #print('last_temp='+last_temp)
py:   ela=last_elm.split(',')
py:   #print(ela)
py:   for e in ela:
py:     if 'v=' in e:
py:        tvx=e
py:   #print(tvx)
py:   tva=tvx.split('=')
py:   motion_value=tva[1]
py:   print('motion_value='+motion_value)  
py:   map_source = re.sub('motion_'+uri[0]+r'=\d+(\.\d+)?C*', 'motion_'+uri[0]+'='+f'{motion_value}', map_source)
py:   #
py:   #print(map_source)
py: map_driver.replace_wiki_page(map_source)
py: #
command: end test
command: run test
result:
current_device="yama_bot_0000_0000_0000_0001". Date=2024/10/06 15:00:21

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS