glad to help

think i got the double humidity fixed attached the fix i hope script if you 
still want it
but tcpflow looks better fit for the interceptor driver

that's the same tcpdump line that i use too

On Monday, October 31, 2016 at 3:47:51 PM UTC-5, Brad Tucker wrote:
>
> Radar,
>
> Thanks again for script and all the help. I ran my tcpdump through your 
> script and it actually logs data!!! I have added some of the logs so you 
> can see. One thing Ive noticed is it doesn't log barometric pressure. Not 
> sure why. I did see that after getting processed by the perl script it adds 
> two areas for humidity. Not sure if the duplicate value is the culprit or 
> not.
>
>
> *Couple Questions for you if you have the time:*
> 1. Is my "tcpdump" syntax what you would use?
> 2. Any idea on why the Barometric Pressure is not logging?
> 3. Why does the Console say ""checkversion": "126" when my bridge is the 
> latest 2.24 firmware?
>
>
> *Here is the command Im running:*
> sudo tcpdump -A -n -p -l -i eth0 -s0 -W tcp dst port 80 | stdbuf -oL 
> strings -n8 | stdbuf -oL grep "&" | ./acurite-lwp.pl
>
> *Raw Dump not processed with the perl script for 5n1:*
> ..P.....C.&P....0..GET 
> /weatherstation/updateweatherstation?dateutc=now&action=updateraw&realtime=1
> ..P...0.C.&P....p..&id=24C86E06B15C&mt=5N1x38&sensor=00002179
> ..P...Z.C.&P...cl..&windspeedmph=2&humidity=50
> ..P...u.C.&P.......&tempf=71.0
> ..P.....C.&P.......&baromin=29.30&battery=normal&rssi=3
> ..P.....C.&P....... HTTP/1.1
> ..P.....C.&P.......hubapi.myacurite.com
>
>
> *From Console for 5n1 Sensor after issuing the above command:*
>
> dateutc=now&action=updateraw&realtime=1&id=24C86E06B15C&mt=5N1x38&sensor=00002179&windspeedmph=3
> *&humidity=50&humidity=50*&tempf=71.5&baromin=29.30&battery=normal&rssi=3
> { "success": 1, "checkversion": "126" }
>
> *syslog for 5n1:*
> Oct 31 13:25:39 weather weewx[15893]: interceptor: ServerThread: POST: 
> dateutc=now&action=updateraw&realtime=1&id=24C86E06B15C&mt=5N1x38&sensor=00002179&windspeedmph=3
> *&humidity=50&humidity=50*&tempf=71.5&baromin=29.30&battery=normal&rssi=3
> Oct 31 13:25:39 weather weewx[15893]: interceptor: MainThread: raw data: 
> dateutc=now&action=updateraw&realtime=1&id=24C86E06B15C&mt=5N1x38&sensor=00002179&windspeedmph=3
> *&humidity=50&humidity=50*&tempf=71.5&baromin=29.30&battery=normal&rssi=3
> Oct 31 13:25:39 weather weewx[15893]: interceptor: MainThread: ignored 
> parameter realtime=1
> Oct 31 13:25:39 weather weewx[15893]: interceptor: MainThread: ignored 
> parameter action=updateraw
> Oct 31 13:25:39 weather weewx[15893]: interceptor: MainThread: raw packet: 
> {'sensor_type.00002179.24C86E06B15C': '5N1x38', 
> 'sensor_id.00002179.24C86E06B15C': '00002179', 
> 'temperature.00002179.24C86E06B15C': 71.5, 
> 'dateTime.00002179.24C86E06B15C': 1477945540, 
> 'usUnits.00002179.24C86E06B15C': 1, 'battery.00002179.24C86E06B15C': 0, 
> 'dateTime': 1477945540, 'humidity.00002179.24C86E06B15C': 50.0, 
> 'bridge_id.00002179.24C86E06B15C': '24C86E06B15C', 
> 'barometer.00002179.24C86E06B15C': 29.3, 'rssi.00002179.24C86E06B15C': 
> 0.75, 'windspeed.00002179.24C86E06B15C': 3.0, 'usUnits': 1}
> Oct 31 13:25:39 weather weewx[15893]: interceptor: MainThread: mapped 
> packet: {'txBatteryStatus': 0, 'outHumidity': 50.0, 'dateTime': 1477945540, 
> 'outTemp': 71.5, 'windSpeed': 3.0, 'rxCheckPercent': 0.75, 'usUnits': 1}
> Oct 31 13:25:40 weather weewx[15893]: manager: added record 2016-10-31 
> 13:25:00 PDT (1477945500) to database 'weewx.sdb'
>
>
>
> I also have 2 Tower Sensors attached so I included logs for this incase 
> one of them is conflicting...
>
>
>
> *Raw Dump not processed with the perl script for the TowerSensor:*
> ..P}hNg.MdvP.......GET 
> /weatherstation/updateweatherstation?dateutc=now&action=updateraw&realtime=1
> ..P}hN..MdvP...K...&id=24C86E06B15C&mt=tower&sensor=00008384
> ..P}hN..MdvP.......&humidity=44&tempf=83.8
> ..P}hN..MdvP...U"..&baromin=29.30&battery=normal&rssi=3
>
> *From Console for the TowerSensor after issuing the above command:*
>
> dateutc=now&action=updateraw&realtime=1&id=24C86E06B15C&mt=tower&sensor=00012694&humidity=61&tempf=73.4&baromin=29.30&battery=normal&rssi=3
> { "success": 1, "checkversion": "126" }
>
> *syslog for **the TowerSensor**:*
> Oct 31 13:25:42 weather weewx[15893]: interceptor: ServerThread: POST: 
> dateutc=now&action=updateraw&realtime=1&id=24C86E06B15C&mt=tower&sensor=00012694&humidity=61&tempf=73.4&baromin=29.30&battery=normal&rssi=3
> Oct 31 13:25:43 weather weewx[15893]: interceptor: MainThread: raw data: 
> dateutc=now&action=updateraw&realtime=1&id=24C86E06B15C&mt=tower&sensor=00012694&humidity=61&tempf=73.4&baromin=29.30&battery=normal&rssi=3
> Oct 31 13:25:43 weather weewx[15893]: interceptor: MainThread: ignored 
> parameter realtime=1
> Oct 31 13:25:43 weather weewx[15893]: interceptor: MainThread: ignored 
> parameter action=updateraw
> Oct 31 13:25:43 weather weewx[15893]: interceptor: MainThread: raw packet: 
> {'dateTime.00012694.24C86E06B15C': 1477945543, 
> 'sensor_type.00012694.24C86E06B15C': 'tower', 'rssi.00012694.24C86E06B15C': 
> 0.75, 'battery.00012694.24C86E06B15C': 0, 'dateTime': 1477945543, 
> 'bridge_id.00012694.24C86E06B15C': '24C86E06B15C', 'usUnits': 1, 
> 'humidity.00012694.24C86E06B15C': 61.0, 'usUnits.00012694.24C86E06B15C': 1, 
> 'barometer.00012694.24C86E06B15C': 29.3, 
> 'temperature.00012694.24C86E06B15C': 73.4, 
> 'sensor_id.00012694.24C86E06B15C': '00012694'}
> Oct 31 13:25:43 weather weewx[15893]: interceptor: MainThread: mapped 
> packet: {'txBatteryStatus': 0, 'outHumidity': 61.0, 'dateTime': 1477945543, 
> 'outTemp': 73.4, 'rxCheckPercent': 0.75, 'usUnits': 1}
> Oct 31 13:25:43 weather weewx[15893]: manager: unable to add record 
> 2016-10-31 13:25:00 PDT (1477945500) to database 'weewx.sdb': UNIQUE 
> constraint failed: archive.dateTime
>
>
>
> *Added Bonus:*
>
> I have the latest tcpflow and it now works with -0. I have a nice pretty 
> output from that by issuing the following:
>
> *sudo tcpflow -C -0 -s tcp dst port 80:*
> GET 
> /weatherstation/updateweatherstation?dateutc=now&action=updateraw&realtime=1&id=24C86E06B15C&mt=5N1x38&sensor=00002179&windspeedmph=2&humidity=50&tempf=70.9&baromin=29.31&battery=normal&rssi=3
>  
> HTTP/1.1
> Host: hubapi.myacurite.com
> User-Agent: Hub/224
> Connection: close
>
> GET 
> /weatherstation/updateweatherstation?dateutc=now&action=updateraw&realtime=1&id=24C86E06B15C&mt=tower&sensor=00008384&humidity=44&tempf=83.8&baromin=29.31&battery=normal&rssi=3
>  
> HTTP/1.1
> Host: hubapi.myacurite.com
> User-Agent: Hub/224
> Connection: close
>
> GET 
> /weatherstation/updateweatherstation?dateutc=now&action=updateraw&realtime=1&id=24C86E06B15C&mt=tower&sensor=00012694&humidity=63&tempf=73.0&baromin=29.31&battery=normal&rssi=3
>  
> HTTP/1.1
> Host: hubapi.myacurite.com
> User-Agent: Hub/224
> Connection: close
>
>
>
> Thanks Again!
> Brad
>
>

-- 
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 weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#!/usr/bin/perl 
#===============================================================================
#
#          FILE: acurite-lwp.pl
#
#         USAGE: ./acurite-lwp.pl  
#
#   DESCRIPTION: 
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Radar (), radar@localhost
#  ORGANIZATION: 
#       VERSION: 0.1
#       CREATED: 10/08/2016 07:16:48 PM
# Last modified: Mon Oct 31, 2016 10:49PM
#      REVISION: 1
#===============================================================================

use strict;
use warnings;

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");

my $req = HTTP::Request->new(POST => 'http://192.168.1.6:9999');
my $res;

my $newline = '';
my $build = 0;
my $obs_line = 'dateutc=now&action=updateraw&realtime=1';

#-------------------------------------------------------------------------------
#  the 5n1 sends two packets
#  5N1x31 packet has windspeedmph & winddir & rainin & dailyrainin & 
#  baromin & battery & rssi
#
#  5N1x38 packet has windspeedmph & humidity & tempf & baromin & battery & rssi
#-------------------------------------------------------------------------------
while ( my $line = <> ) {
	if ( defined $line ) {
		if ($line =~ /GET /) {
			$build = 1;
			$newline = '';
		}
#-------------------------------------------------------------------------------
#  id & mt & sensor
#  id = smarthub mac address
#  mt sensor type
#  sensor number
#-------------------------------------------------------------------------------
		if (($line =~ /&id=/) && ($build == 1)) {
			$line =~ s/.*&id=/&id=/xm;
			chomp $line;
			$newline = $line;
		}
#-------------------------------------------------------------------------------
#  windspeedmph & humidity for 5n1 from 5N1x38 packet;
#  5N1x31 packet has windspeedmph & winddir
#-------------------------------------------------------------------------------
		if (($build == 1) && ($line =~ /&windspeedmph=/)) {
			$line =~ s/.*&windspeedmph=/&windspeedmph=/xm;
			chomp $line;
			$newline = $newline . $line;
		}
#-------------------------------------------------------------------------------
#  look for 5N1x38 if found grab the tempf
#-------------------------------------------------------------------------------
		if (($build == 1) && ($newline =~ /5N1x38/)) {
			if (($build == 1) && ($line =~ /&tempf=/)) {
				$line =~ s/.*&tempf=/&tempf=/xm;
				chomp $line;
				$newline = $newline . $line;
			}
#-------------------------------------------------------------------------------
#  if not found grab humidity & tempf
#-------------------------------------------------------------------------------
		} elsif (($build == 1) && ($line =~ /&humidity=/)) {
			$line =~ s/.*&humidity=/&humidity=/xm;
			chomp $line;
			$newline = $newline . $line;
		}
#-------------------------------------------------------------------------------
#  rainin & dailyrainin for rain gauge and 5n1
#-------------------------------------------------------------------------------
		if (($build == 1) && ($line =~ /&rainin=/)) {
			$line =~ s/.*&rainin=/&rainin=/xm;
			chomp $line;
			$newline = $newline . $line;
		}
#-------------------------------------------------------------------------------
#  ProIn sensor
#  indoorhumidity & indoortempf
#-------------------------------------------------------------------------------
		if (($build == 1) && ($line =~ /&indoorhumidity=/)) {
			$line =~ s/.*&indoorhumidity=/&indoorhumidity=/xm;
			chomp $line;
			$newline = $newline . $line;
		}
#-------------------------------------------------------------------------------
#  the extra probs for a ProIn & ProOut sensors
#  probe & check & water (Water Detector)
#  probe & check & ptempf (Liquide and or Soil Temp)
#  probe & check & ptempf & phumidity (Spot Check Temperature and Humidity)
#-------------------------------------------------------------------------------
		if (($build == 1) && ($line =~ /&probe=/)) {
			$line =~ s/.*&probe=/&probe=/xm;
			chomp $line;
			$newline = $newline . $line;
		}
#-------------------------------------------------------------------------------
#  baromin & battery & rssi
#  baromin is from the smarthub
#-------------------------------------------------------------------------------
		if (($build == 1) && ($line =~ /&baromin=/)) {
			$line =~ s/.*&baromin=/&baromin=/xm;
			chomp $line;
			$build = 2;
			$newline = $newline . $line;
			$obs_line = $obs_line . $newline;
			$newline = '';
		}

		if ($build == 2) {
			$build = 0;
			print "$obs_line\n";
			$req->content("$obs_line");
			$res = $ua->request($req);
			$obs_line = 'dateutc=now&action=updateraw&realtime=1';
			
			if ( $res->is_success ) {
				print $res->content, "\n";
			}
			else {
				print $res->status_line, "\n";
			}
		}
	} #end of if definde $line
} # end of while loop

Reply via email to