I have this working but not as clean as it should be. I'm new to Perl and This has been my first project to monitor my solar equipment.
Here is the data stream - {"result":{"overview":[{"meta":"GriPwr","value":"3689","name":"GriPwr","unit":"W"},{"meta":"GriEgyTdy",
-
"value":"2.763333886","name":"GriEgyTdy","unit":"kWh"},{"meta":"GriEgyTot","value":"11235.17878036864",
-
"name":"GriEgyTot","unit":"kWh"},{"meta":"OpStt","value":"","name":"OpStt","unit":""},{"meta":"Msg","value":"",
-
"name":"Msg","unit":""}]},"version":"1.0","format":"JSON","proc":"GetPlantOverview","id":"1"}
-
Here is my code.
It give it to me in a decent view. lookin to find out how much easier it would have been to make this work in a table format and how to get it to auto refresh. - #!c:/www/Perl/bin/perl
-
-
use strict;
-
-
use IO::Socket::INET;
-
-
my $webboxIP = "192.168.1.10";
-
-
my $request = '{ "version":"1.0", "proc":"GetPlantOverview", "id":"1", "format":"JSON" }';
-
-
$request =~ s/\s//go;
-
$request =~ s/(.)/$1\0/go;
-
-
my $myRecvSocket = new IO::Socket::INET->new(LocalPort=>34268,Proto=>'udp');
-
my $mySendSocket = new IO::Socket::INET->new(PeerPort=>34268,Proto=>'udp',PeerAddr=>"$webboxIP");
-
my $sentCharacters = $mySendSocket->send($request);
-
if (defined $sentCharacters) {
-
# print "Sent $sentCharacters characters\n";
-
} else {
-
print "Error in send\n";
-
}
-
my $response;
-
my $responder = $myRecvSocket->recv($response,1024);
-
my @names;
-
my @test1;
-
my $string_to_find="value";
-
#
-
$response =~ s/\0//go;
-
$response =~ s/\{//go;
-
$response =~ s/\}//go;
-
$response =~ s/\[//go;
-
$response =~ s/\]//go;
-
$response =~ s/"result":"overview":/<br>/go;
-
$response =~ s/"meta":/<br>/go;
-
$response =~ s/"OpStt","value":"","name":"OpStt","unit":""//go;
-
$response =~ s/"Msg","value":"","name":"Msg","unit":""//go;
-
$response =~ s/"version":"1.0","format":"JSON","proc":"GetPlantOverview","id":"1"//go;
-
$response =~ s/,/<br>/go;
-
#
-
print "Content-type: text/html\n\n";
-
print "<HTML><HEAD>\n";
-
print "<TITLE>GetPlantOverview-test</TITLE>\n";
-
print "</HEAD><body><h1>Live Solar Data via Webbox</h1>";
-
-
#
-
print $response;
0 953 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dusty |
last post by:
Hi,
I recently switched from windoze to Linux (SuSE 9.1) and want to write
some applications (mostly for personal use). I have several years
experience writing with Borland Delphi and now I am looking at Python.
BlackAdder incorporates Python and QT into a application similar to
Delphi for writing GUI applications. (I looked at Kylix and didn't
like it)
I wonder if BlackAdder is worth the price or would I be just as well
off using Idle...
|
by: Istvan Buki |
last post by:
Dear C++ gurus,
I'm having some problems inserting some template classes into containers.
I'm looking for ideas, suggestions,... on how to achieve this but first let
me explain my problem. Everything starts with a simple template class like
the one below. In this example class A has two template parameters but that
number can be different.
template < typename T, typename U >
class A
|
by: Tommy Carlier |
last post by:
I've created a data structuring format (you can't really call it a
markup language), that behaves like XML, but that's much more
flexible. You can have elements without names, attributes without
names, you don't need something like CDATA or entities, and there's no
such thing as DTD.
Now I'm looking for an interesting name for it. I've thought of using
a name like *ML (replace the * by any letter), but all the letters
were already taken.
|
by: Al Moritz |
last post by:
Hi all,
I was always told that the conversion of Word files to HTML as done by
Word itself sucks - you get a lot of unnecessary code that can
influence the design on web browsers other than Internet Explorer. Our
computer expert in my company had told me already a while ago that I
should learn HTML and encode myself. I was never inclined to do so (I
am no computer expert), and when upon his suggestion I looked how my
pages (converted to...
|
by: walterbyrd |
last post by:
Way back when, I got a lot of training and experience in highly
structued software development. These days, I dabble with
web-development, but I may become more serious.
I consider php to be an abombination, the backward compatibility issues
alone are reason enough to make me hate it. Rail looks promising, but
it's difficult to find inexpensive hosting that supports rails.
I like python much better, but I'm not certain it's as well...
| |
by: BLACKDOG157 |
last post by:
I am starting to study dot net languages, and I'm wondering - which
language do employers look for - C# or VB.net? Are they both equally
powerful languages?
Thanks,
BD
|
by: Alan Silver |
last post by:
Hello,
MSDN (amongst other places) is full of helpful advice on ways to do data
access, but they all seem geared to wards enterprise applications. Maybe
I'm in a minority, but I don't have those sorts of clients. Mine are all
small businesses whose sites will never reach those sorts of scales. I
deal with businesses whose sites get maybe a few hundred visitors per
day (some not even that much) and get no more than ten orders per day....
|
by: Jack |
last post by:
Basically I am trying to find a high performance web server. Since
Python is installed on all of the servers, It'll be great if the web
server is written in Python as well. Otherwise, I will have to install
lighttpd or other web servers.
Then the largest issue with Python-based web servers is performance.
That's why I start to look into medusa or twisted-based servers. Twisted
seems too big and complicated for what I really want to do...
|
by: myprotein |
last post by:
if "all applications disconnection" is anathor tigger of page cleaner?
hi all
I discovered that when all application disconnect from the database, db2 will "truncate" current active log file and push forward a new log file either by reusing a exist log or by generating a new log file.
when anather application get connected to current database, execute "db2 get db cfg for xxxxx", u should see that the first active log is just the file...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |