insert meterssite and meterssolar
This commit is contained in:
parent
231bd195cb
commit
e34b5f8c07
@ -59,6 +59,7 @@ use warnings;
|
|||||||
use FHEM::Meta;
|
use FHEM::Meta;
|
||||||
use GPUtils qw(GP_Import GP_Export);
|
use GPUtils qw(GP_Import GP_Export);
|
||||||
use HttpUtils;
|
use HttpUtils;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
# try to use JSON::MaybeXS wrapper
|
# try to use JSON::MaybeXS wrapper
|
||||||
# for chance of better performance + open code
|
# for chance of better performance + open code
|
||||||
@ -170,6 +171,8 @@ GP_Export(
|
|||||||
my %paths = (
|
my %paths = (
|
||||||
'statussoe' => 'system_status/soe',
|
'statussoe' => 'system_status/soe',
|
||||||
'aggregates' => 'meters/aggregates',
|
'aggregates' => 'meters/aggregates',
|
||||||
|
'meterssite' => 'meters/site',
|
||||||
|
'meterssolar' => 'meters/solar',
|
||||||
'siteinfo' => 'site_info',
|
'siteinfo' => 'site_info',
|
||||||
'sitemaster' => 'sitemaster',
|
'sitemaster' => 'sitemaster',
|
||||||
'powerwallsstop' => 'sitemaster/stop',
|
'powerwallsstop' => 'sitemaster/stop',
|
||||||
@ -438,7 +441,22 @@ sub Write($) {
|
|||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
HttpUtils_NonblockingGet(
|
#### temporär
|
||||||
|
# HttpUtils_NonblockingGet(
|
||||||
|
# {
|
||||||
|
# url => 'http://' . $uri,
|
||||||
|
# timeout => 5,
|
||||||
|
# method => $method,
|
||||||
|
# data => $data,
|
||||||
|
# header => $header,
|
||||||
|
# hash => $hash,
|
||||||
|
# setCmd => $path,
|
||||||
|
# doTrigger => 1,
|
||||||
|
# callback => \&ErrorHandling,
|
||||||
|
# }
|
||||||
|
# );
|
||||||
|
|
||||||
|
ErrorHandling(
|
||||||
{
|
{
|
||||||
url => 'http://' . $uri,
|
url => 'http://' . $uri,
|
||||||
timeout => 5,
|
timeout => 5,
|
||||||
@ -449,7 +467,9 @@ sub Write($) {
|
|||||||
setCmd => $path,
|
setCmd => $path,
|
||||||
doTrigger => 1,
|
doTrigger => 1,
|
||||||
callback => \&ErrorHandling,
|
callback => \&ErrorHandling,
|
||||||
}
|
},
|
||||||
|
undef,
|
||||||
|
'{"none": "none"}'
|
||||||
);
|
);
|
||||||
|
|
||||||
Log3 $name, 4, "TeslaPowerwall2AC ($name) - Send with URI: http://$uri";
|
Log3 $name, 4, "TeslaPowerwall2AC ($name) - Send with URI: http://$uri";
|
||||||
@ -459,6 +479,239 @@ sub ErrorHandling($$$) {
|
|||||||
my ( $param, $err, $data ) = @_;
|
my ( $param, $err, $data ) = @_;
|
||||||
my $hash = $param->{hash};
|
my $hash = $param->{hash};
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
my $path = $param->{setCmd}; # temporär
|
||||||
|
|
||||||
|
|
||||||
|
#### temporär
|
||||||
|
if ( $path eq 'statussoe' ) {
|
||||||
|
$data = '{"percentage":69.1675560298826}';
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'aggregates' ) {
|
||||||
|
$data = '{
|
||||||
|
"site":{
|
||||||
|
"last_communication_time":"2018-04-02T16:11:41.885377469-07:00",
|
||||||
|
"instant_power":-21.449996948242188,
|
||||||
|
"instant_reactive_power":-138.8300018310547,
|
||||||
|
"instant_apparent_power":140.47729986545957,
|
||||||
|
"frequency":60.060001373291016,
|
||||||
|
"energy_exported":1136916.6875890202,
|
||||||
|
"energy_imported":3276432.6625890196,
|
||||||
|
"instant_average_voltage":239.81999969482422,
|
||||||
|
"instant_total_current":0,
|
||||||
|
"i_a_current":0,
|
||||||
|
"i_b_current":0,
|
||||||
|
"i_c_current":0
|
||||||
|
},
|
||||||
|
"battery":{
|
||||||
|
"last_communication_time":"2018-04-02T16:11:41.89022247-07:00",
|
||||||
|
"instant_power":-2350,
|
||||||
|
"instant_reactive_power":0,
|
||||||
|
"instant_apparent_power":2350,
|
||||||
|
"frequency":60.033,
|
||||||
|
"energy_exported":1169030,
|
||||||
|
"energy_imported":1638140,
|
||||||
|
"instant_average_voltage":239.10000000000002,
|
||||||
|
"instant_total_current":45.8,
|
||||||
|
"i_a_current":0,
|
||||||
|
"i_b_current":0,
|
||||||
|
"i_c_current":0
|
||||||
|
},
|
||||||
|
"load":{
|
||||||
|
"last_communication_time":"2018-04-02T16:11:41.885377469-07:00",
|
||||||
|
"instant_power":1546.2712597712405,
|
||||||
|
"instant_reactive_power":-71.43153973801415,
|
||||||
|
"instant_apparent_power":1547.920305979569,
|
||||||
|
"frequency":60.060001373291016,
|
||||||
|
"energy_exported":0,
|
||||||
|
"energy_imported":7191016.994444443,
|
||||||
|
"instant_average_voltage":239.81999969482422,
|
||||||
|
"instant_total_current":6.44763264839839,
|
||||||
|
"i_a_current":0,
|
||||||
|
"i_b_current":0,
|
||||||
|
"i_c_current":0
|
||||||
|
},
|
||||||
|
"solar":{
|
||||||
|
"last_communication_time":"2018-04-02T16:11:41.885541803-07:00",
|
||||||
|
"instant_power":3906.1700439453125,
|
||||||
|
"instant_reactive_power":53.26999855041504,
|
||||||
|
"instant_apparent_power":3906.533259164868,
|
||||||
|
"frequency":60.060001373291016,
|
||||||
|
"energy_exported":5534272.949724403,
|
||||||
|
"energy_imported":13661.930279959455,
|
||||||
|
"instant_average_voltage":239.8699951171875,
|
||||||
|
"instant_total_current":0,
|
||||||
|
"i_a_current":0,
|
||||||
|
"i_b_current":0,
|
||||||
|
"i_c_current":0
|
||||||
|
},
|
||||||
|
"busway":{
|
||||||
|
"last_communication_time":"0001-01-01T00:00:00Z",
|
||||||
|
"instant_power":0,
|
||||||
|
"instant_reactive_power":0,
|
||||||
|
"instant_apparent_power":0,
|
||||||
|
"frequency":0,
|
||||||
|
"energy_exported":0,
|
||||||
|
"energy_imported":0,
|
||||||
|
"instant_average_voltage":0,
|
||||||
|
"instant_total_current":0,
|
||||||
|
"i_a_current":0,
|
||||||
|
"i_b_current":0,
|
||||||
|
"i_c_current":0
|
||||||
|
},
|
||||||
|
"frequency":{
|
||||||
|
"last_communication_time":"0001-01-01T00:00:00Z",
|
||||||
|
"instant_power":0,
|
||||||
|
"instant_reactive_power":0,
|
||||||
|
"instant_apparent_power":0,
|
||||||
|
"frequency":0,
|
||||||
|
"energy_exported":0,
|
||||||
|
"energy_imported":0,
|
||||||
|
"instant_average_voltage":0,
|
||||||
|
"instant_total_current":0,
|
||||||
|
"i_a_current":0,
|
||||||
|
"i_b_current":0,
|
||||||
|
"i_c_current":0
|
||||||
|
},
|
||||||
|
"generator":{
|
||||||
|
"last_communication_time":"0001-01-01T00:00:00Z",
|
||||||
|
"instant_power":0,
|
||||||
|
"instant_reactive_power":0,
|
||||||
|
"instant_apparent_power":0,
|
||||||
|
"frequency":0,
|
||||||
|
"energy_exported":0,
|
||||||
|
"energy_imported":0,
|
||||||
|
"instant_average_voltage":0,
|
||||||
|
"instant_total_current":0,
|
||||||
|
"i_a_current":0,
|
||||||
|
"i_b_current":0,
|
||||||
|
"i_c_current":0
|
||||||
|
}
|
||||||
|
}';
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'siteinfo' ) {
|
||||||
|
$data = '{"site":{"last_communication_time":"2019-09-22T00:21:15.389963162-07:00","instant_power":24.451171875,"instant_reactive_power":53.17060422897339,"instant_apparent_power":58.52326853598416,"frequency":49.99971389770508,"energy_exported":8317850.641600119,"energy_imported":3906677.3213223405,"instant_average_voltage":228.2313995361328,"instant_total_current":0,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"battery":{"last_communication_time":"2019-09-22T00:21:15.501660598-07:00","instant_power":1350,"instant_reactive_power":-30,"instant_apparent_power":1350.3332921912279,"frequency":49.994,"energy_exported":3816030,"energy_imported":4422670,"instant_average_voltage":235,"instant_total_current":-31.8,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"load":{"last_communication_time":"2019-09-22T00:21:15.389963162-07:00","instant_power":5728.583274805815,"instant_reactive_power":-175.17854151916174,"instant_apparent_power":5731.261105358374,"frequency":49.99971389770508,"energy_exported":0,"energy_imported":13885698.406388888,"instant_average_voltage":228.2313995361328,"instant_total_current":25.0998911037168,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000},"solar":{"last_communication_time":"2019-09-22T00:21:15.506420255-07:00","instant_power":4363.2269287109375,"instant_reactive_power":-196.4273910522461,"instant_apparent_power":4367.646156842822,"frequency":49.99971389770508,"energy_exported":18947820.8881397,"energy_imported":44309.16147303224,"instant_average_voltage":227.83099365234375,"instant_total_current":0,"i_a_current":0,"i_b_current":0,"i_c_current":0,"timeout":1500000000}}';
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'sitemaster' ) {
|
||||||
|
$data = '{"running":true,"uptime":"166594s,","connected_to_tesla":true}';
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'powerwalls' ) {
|
||||||
|
$data = '{"powerwalls":[{"PackagePartNumber":"1092170-03-E","PackageSerialNumber":"T1234567890"},{"PackagePartNumber":"1092170-03-E","PackageSerialNumber":"T1234567891"}],"has_sync":true}';
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'status' ) {
|
||||||
|
$data = '{"start_time":"2018-03-16 19:08:46 +0800","up_time_seconds":"402h8m19.937911668s","is_new":false,"version":"1.15.0\n","git_hash":"dc337851c6cad15a7e9c7223d60fff719eb8da4d\n"}';
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'meterssite' ) {
|
||||||
|
$data = '[
|
||||||
|
{
|
||||||
|
"id":0,
|
||||||
|
"location":"site",
|
||||||
|
"type":"neurio_tcp",
|
||||||
|
"cts":[
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"inverted":[
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"connection":{
|
||||||
|
"ip_address":"Neurio-39546",
|
||||||
|
"port":443,
|
||||||
|
"short_id":"39546",
|
||||||
|
"device_serial":"OBB3364102752",
|
||||||
|
"neurio_connected":true,
|
||||||
|
"https_conf":{
|
||||||
|
"client_cert":"/etc/site/certs/neurio/neurio.crt",
|
||||||
|
"client_key":"/etc/site/certs/neurio/neurio.key",
|
||||||
|
"server_ca_cert":"/etc/site/certs/neurio/neurio-ca-chain.cert.pem",
|
||||||
|
"max_idle_conns_per_host":1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Cached_readings":{
|
||||||
|
"last_communication_time":"2018-06-10T16:51:46.187715089+01:00",
|
||||||
|
"instant_power":13.94000026769936,
|
||||||
|
"instant_reactive_power":14.070000305771828,
|
||||||
|
"instant_apparent_power":19.80627466405224,
|
||||||
|
"frequency":49.95000076293945,
|
||||||
|
"energy_exported":3724.253888912031,
|
||||||
|
"energy_imported":26003.843888912033,
|
||||||
|
"instant_average_voltage":247.52999755740166,
|
||||||
|
"instant_total_current":0,
|
||||||
|
"i_a_current":0,
|
||||||
|
"i_b_current":0,
|
||||||
|
"i_c_current":0,
|
||||||
|
"v_l1n":247.3300018310547,
|
||||||
|
"v_l2n":0.2199999988079071,
|
||||||
|
"serial_number":"0x000004714B008720",
|
||||||
|
"version":"Tesla-0.0.7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]';
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'meterssolar' ) {
|
||||||
|
$data = '[
|
||||||
|
{
|
||||||
|
"id":0,
|
||||||
|
"location":"solar",
|
||||||
|
"type":"neurio_tcp",
|
||||||
|
"cts":[
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
],
|
||||||
|
"inverted":[
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"connection":{
|
||||||
|
"ip_address":"Neurio-39546",
|
||||||
|
"port":443,
|
||||||
|
"short_id":"39546",
|
||||||
|
"device_serial":"OBB3364102752",
|
||||||
|
"neurio_connected":true,
|
||||||
|
"https_conf":{
|
||||||
|
"client_cert":"/etc/site/certs/neurio/neurio.crt",
|
||||||
|
"client_key":"/etc/site/certs/neurio/neurio.key",
|
||||||
|
"server_ca_cert":"/etc/site/certs/neurio/neurio-ca-chain.cert.pem",
|
||||||
|
"max_idle_conns_per_host":1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Cached_readings":{
|
||||||
|
"last_communication_time":"2018-06-10T16:52:57.788560639+01:00",
|
||||||
|
"instant_power":318.8599853515625,
|
||||||
|
"instant_reactive_power":129.94000244140625,
|
||||||
|
"instant_apparent_power":344.3197561756678,
|
||||||
|
"frequency":49.95000076293945,
|
||||||
|
"energy_exported":3.8174999999938235,
|
||||||
|
"energy_imported":125317.00444444444,
|
||||||
|
"instant_average_voltage":246.82000732421875,
|
||||||
|
"instant_total_current":0,
|
||||||
|
"i_a_current":0,
|
||||||
|
"i_b_current":0,
|
||||||
|
"i_c_current":0,
|
||||||
|
"v_l1n":246.8800048828125,
|
||||||
|
"serial_number":"0x000004714B008720",
|
||||||
|
"version":"Tesla-0.0.7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Begin Error Handling
|
### Begin Error Handling
|
||||||
|
|
||||||
@ -545,15 +798,21 @@ sub ResponseProcessing($$$) {
|
|||||||
|
|
||||||
if ( $path eq 'aggregates' ) {
|
if ( $path eq 'aggregates' ) {
|
||||||
$readings = ReadingsProcessing_Aggregates( $hash, $decode_json );
|
$readings = ReadingsProcessing_Aggregates( $hash, $decode_json );
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $path eq 'powerwalls' ) {
|
elsif ( $path eq 'powerwalls' ) {
|
||||||
$readings = ReadingsProcessing_Powerwalls( $hash, $decode_json );
|
$readings = ReadingsProcessing_Powerwalls( $hash, $decode_json );
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'siteinfo' ) {
|
||||||
|
$readings = ReadingsProcessing_Site_Info( $hash, $decode_json );
|
||||||
}
|
}
|
||||||
elsif ( $path eq 'login' ) {
|
elsif ( $path eq 'login' ) {
|
||||||
return $hash->{TOKEN} = $decode_json->{token};
|
return $hash->{TOKEN} = $decode_json->{token};
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'meterssite' ) {
|
||||||
|
$readings = ReadingsProcessing_Meters_Site( $hash, $decode_json );
|
||||||
|
}
|
||||||
|
elsif ( $path eq 'meterssolar' ) {
|
||||||
|
$readings = ReadingsProcessing_Meters_Solar( $hash, $decode_json );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$readings = $decode_json;
|
$readings = $decode_json;
|
||||||
@ -614,7 +873,6 @@ sub ReadingsProcessing_Aggregates($$) {
|
|||||||
$readings{ $obj . '-' . $r } = $v;
|
$readings{ $obj . '-' . $r } = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$readings{'error'} = 'aggregates response is not a Hash';
|
$readings{'error'} = 'aggregates response is not a Hash';
|
||||||
@ -632,7 +890,6 @@ sub ReadingsProcessing_Powerwalls($$) {
|
|||||||
and scalar( @{ $decode_json->{powerwalls} } ) > 0 )
|
and scalar( @{ $decode_json->{powerwalls} } ) > 0 )
|
||||||
{
|
{
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
|
|
||||||
foreach my $powerwall ( @{ $decode_json->{powerwalls} } ) {
|
foreach my $powerwall ( @{ $decode_json->{powerwalls} } ) {
|
||||||
if ( ref($powerwall) eq 'HASH' ) {
|
if ( ref($powerwall) eq 'HASH' ) {
|
||||||
|
|
||||||
@ -645,7 +902,6 @@ sub ReadingsProcessing_Powerwalls($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$readings{'numberOfWalls'} = $i;
|
$readings{'numberOfWalls'} = $i;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$readings{'error'} = 'aggregates response is not a Array';
|
$readings{'error'} = 'aggregates response is not a Array';
|
||||||
@ -654,6 +910,125 @@ sub ReadingsProcessing_Powerwalls($$) {
|
|||||||
return \%readings;
|
return \%readings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub ReadingsProcessing_Site_Info($$) {
|
||||||
|
my ( $hash, $decode_json ) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my %readings;
|
||||||
|
|
||||||
|
if ( ref($decode_json) eq 'HASH' ) {
|
||||||
|
while ( my $obj = each %{$decode_json} ) {
|
||||||
|
while ( my ( $r, $v ) = each %{ $decode_json->{$obj} } ) {
|
||||||
|
$readings{ $obj . '-' . $r } = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$readings{'error'} = 'siteinfo response is not a Hash';
|
||||||
|
}
|
||||||
|
|
||||||
|
return \%readings;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub ReadingsProcessing_Meters_Site($$) {
|
||||||
|
my ( $hash, $decode_json ) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my %readings;
|
||||||
|
|
||||||
|
# print('Ausgabe1: ' . Dumper $decode_json . "\n");
|
||||||
|
|
||||||
|
if ( ref( $decode_json ) eq 'ARRAY'
|
||||||
|
and scalar( @{ $decode_json } ) > 0 )
|
||||||
|
{
|
||||||
|
if ( ref($decode_json->[0]) eq 'HASH' ) {
|
||||||
|
while ( my $obj = each %{$decode_json->[0]} ) {
|
||||||
|
# print('Ausgabe2: ' . Dumper $obj . "\n");
|
||||||
|
if ( ref($decode_json->[0]->{$obj}) eq 'ARRAY'
|
||||||
|
or ref($decode_json->[0]->{$obj}) eq 'HASH' )
|
||||||
|
{
|
||||||
|
if ( ref($decode_json->[0]->{$obj}) eq 'HASH' ) {
|
||||||
|
# print('Ausgabe3: ' . Dumper $obj . "\n");
|
||||||
|
while ( my ( $r, $v ) = each %{ $decode_json->[0]->{$obj} } ) {
|
||||||
|
if ( ref($v) ne 'HASH' ) {
|
||||||
|
# print('Ausgabe4: ' . $obj . '-' . $r . ' = ' . $v . "\n");
|
||||||
|
$readings{ $obj . '-' . $r } = $v;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# print('Ausgabe5: ' . Dumper $decode_json->[0]->{$obj}->{$r} . "\n");
|
||||||
|
while ( my ( $r2, $v2 ) = each %{ $decode_json->[0]->{$obj}->{$r} } ) {
|
||||||
|
# print('Ausgabe6: ' . $obj . '-' . $r2 . ' = ' . $v2 . "\n");
|
||||||
|
$readings{ $obj . '-' . $r . '-' . $r2 } = $v2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ( ref($decode_json->[0]->{$obj}) eq 'ARRAY' ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# print('Ausgabe7: ' . Dumper $decode_json->[0]->{$obj} . "\n");
|
||||||
|
$readings{ $obj } = $decode_json->[0]->{$obj};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# print('Ausgabe8: ' . "\n");
|
||||||
|
$readings{'error'} = 'metes site response is not a Array';
|
||||||
|
}
|
||||||
|
|
||||||
|
return \%readings;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub ReadingsProcessing_Meters_Solar($$) {
|
||||||
|
my ( $hash, $decode_json ) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my %readings;
|
||||||
|
|
||||||
|
if ( ref( $decode_json ) eq 'ARRAY'
|
||||||
|
and scalar( @{ $decode_json } ) > 0 )
|
||||||
|
{
|
||||||
|
if ( ref($decode_json->[0]) eq 'HASH' ) {
|
||||||
|
while ( my $obj = each %{$decode_json->[0]} ) {
|
||||||
|
# print('Ausgabe2: ' . Dumper $obj . "\n");
|
||||||
|
if ( ref($decode_json->[0]->{$obj}) eq 'ARRAY'
|
||||||
|
or ref($decode_json->[0]->{$obj}) eq 'HASH' )
|
||||||
|
{
|
||||||
|
if ( ref($decode_json->[0]->{$obj}) eq 'HASH' ) {
|
||||||
|
# print('Ausgabe3: ' . Dumper $obj . "\n");
|
||||||
|
while ( my ( $r, $v ) = each %{ $decode_json->[0]->{$obj} } ) {
|
||||||
|
if ( ref($v) ne 'HASH' ) {
|
||||||
|
# print('Ausgabe4: ' . $obj . '-' . $r . ' = ' . $v . "\n");
|
||||||
|
$readings{ $obj . '-' . $r } = $v;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# print('Ausgabe5: ' . Dumper $decode_json->[0]->{$obj}->{$r} . "\n");
|
||||||
|
while ( my ( $r2, $v2 ) = each %{ $decode_json->[0]->{$obj}->{$r} } ) {
|
||||||
|
# print('Ausgabe6: ' . $obj . '-' . $r2 . ' = ' . $v2 . "\n");
|
||||||
|
$readings{ $obj . '-' . $r . '-' . $r2 } = $v2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ( ref($decode_json->[0]->{$obj}) eq 'ARRAY' ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# print('Ausgabe7: ' . Dumper $decode_json->[0]->{$obj} . "\n");
|
||||||
|
$readings{ $obj } = $decode_json->[0]->{$obj};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# print('Ausgabe8: ' . "\n");
|
||||||
|
$readings{'error'} = 'metes solar response is not a Array';
|
||||||
|
}
|
||||||
|
|
||||||
|
return \%readings;
|
||||||
|
}
|
||||||
|
|
||||||
sub CreateUri($$) {
|
sub CreateUri($$) {
|
||||||
my ( $hash, $path ) = @_;
|
my ( $hash, $path ) = @_;
|
||||||
my $host = $hash->{HOST};
|
my $host = $hash->{HOST};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user