mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-25 09:55:38 +00:00
74_GardenaSmartDevice: fix patch code scheduling by hhhdg
git-svn-id: https://svn.fhem.de/fhem/trunk@28833 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
49bd370f61
commit
151a1a6995
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it
|
# Do not insert empty lines here, update check depends on it
|
||||||
|
- bugfix: 74_GardenaSmartDevice: fix patch code scheduling by hhhdg
|
||||||
- feature: 74_AutomowerConnect.pm: new mower schedule editor
|
- feature: 74_AutomowerConnect.pm: new mower schedule editor
|
||||||
- bugfix: 76_SolarForecast: possible Illegal division by zero if Attr
|
- bugfix: 76_SolarForecast: possible Illegal division by zero if Attr
|
||||||
ctrlGenPVdeviation is set to continuously
|
ctrlGenPVdeviation is set to continuously
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Developed with VSCodium and richterger perl plugin.
|
# Developed with VSCodium and richterger perl plugin.
|
||||||
#
|
#
|
||||||
# (c) 2017-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
|
# (c) 2017-2024 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
|
||||||
# All rights reserved
|
# All rights reserved
|
||||||
#
|
#
|
||||||
# Special thanks goes to comitters:
|
# Special thanks goes to comitters:
|
||||||
@ -75,9 +75,9 @@ eval { use IO::Socket::SSL; 1 }
|
|||||||
# 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
|
||||||
eval {
|
eval {
|
||||||
require JSON::MaybeXS;
|
require JSON::MaybeXS;
|
||||||
import JSON::MaybeXS qw( decode_json encode_json );
|
import JSON::MaybeXS qw( decode_json encode_json );
|
||||||
1;
|
1;
|
||||||
} or do {
|
} or do {
|
||||||
|
|
||||||
# try to use JSON wrapper
|
# try to use JSON wrapper
|
||||||
@ -629,31 +629,32 @@ sub ErrorHandling {
|
|||||||
if ($decode_json) {
|
if ($decode_json) {
|
||||||
if ( ref( $decode_json->{errors} ) eq "ARRAY"
|
if ( ref( $decode_json->{errors} ) eq "ARRAY"
|
||||||
&& exists( $decode_json->{errors} ) )
|
&& exists( $decode_json->{errors} ) )
|
||||||
# replace defined with exists
|
|
||||||
# && defined( $decode_json->{errors} ) )
|
# replace defined with exists
|
||||||
|
# && defined( $decode_json->{errors} ) )
|
||||||
{
|
{
|
||||||
# $decode_json->{errors} -> ARRAY
|
# $decode_json->{errors} -> ARRAY
|
||||||
# $decode_json->{errors}[0] -> HASH
|
# $decode_json->{errors}[0] -> HASH
|
||||||
if (exists ($decode_json->{errors}[0]{error}) ) {
|
if ( exists( $decode_json->{errors}[0]{error} ) ) {
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$dhash,
|
$dhash,
|
||||||
"state",
|
"state",
|
||||||
$decode_json->{errors}[0]{error} . ' '
|
$decode_json->{errors}[0]{error} . ' '
|
||||||
. $decode_json->{errors}[0]{attribute},
|
. $decode_json->{errors}[0]{attribute},
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
readingsBulkUpdate(
|
readingsBulkUpdate(
|
||||||
$dhash,
|
$dhash,
|
||||||
"lastRequestState",
|
"lastRequestState",
|
||||||
$decode_json->{errors}[0]{error} . ' '
|
$decode_json->{errors}[0]{error} . ' '
|
||||||
. $decode_json->{errors}[0]{attribute},
|
. $decode_json->{errors}[0]{attribute},
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
Log3 $dname, 5,
|
Log3 $dname, 5,
|
||||||
"GardenaSmartBridge ($dname) - RequestERROR: "
|
"GardenaSmartBridge ($dname) - RequestERROR: "
|
||||||
. $decode_json->{errors}[0]{error} . " "
|
. $decode_json->{errors}[0]{error} . " "
|
||||||
. $decode_json->{errors}[0]{attribute};
|
. $decode_json->{errors}[0]{attribute};
|
||||||
} # fi exists error
|
} # fi exists error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1059,6 +1060,20 @@ sub WriteReadings {
|
|||||||
if ( ref($v) eq 'ARRAY' );
|
if ( ref($v) eq 'ARRAY' );
|
||||||
|
|
||||||
#$v = encode_utf8($v);
|
#$v = encode_utf8($v);
|
||||||
|
$v = ' ' if ( !defined $v );
|
||||||
|
Log3 $name, 4,
|
||||||
|
"Gardena DEBUG DEBUG DEBUG stage 1 "
|
||||||
|
. $decode_json->{abilities}[0]{properties}[$properties]
|
||||||
|
{name}
|
||||||
|
if ( $decode_json->{abilities}[0]{properties}[$properties]
|
||||||
|
{name} !~ /ethernet_status|wifi_status/ );
|
||||||
|
Log3 $name, 4, "Gardena DEBUG DEBUG DEBUG stage 2" . $t
|
||||||
|
if ( $decode_json->{abilities}[0]{properties}[$properties]
|
||||||
|
{name} !~ /ethernet_status|wifi_status/ );
|
||||||
|
Log3 $name, 4, "Gardena DEBUG DEBUG DEBUG stage 3" . $v
|
||||||
|
if ( $decode_json->{abilities}[0]{properties}[$properties]
|
||||||
|
{name} !~ /ethernet_status|wifi_status/ );
|
||||||
|
|
||||||
readingsBulkUpdateIfChanged(
|
readingsBulkUpdateIfChanged(
|
||||||
$hash,
|
$hash,
|
||||||
$decode_json->{abilities}[0]{properties}[$properties]
|
$decode_json->{abilities}[0]{properties}[$properties]
|
||||||
@ -1076,16 +1091,22 @@ sub WriteReadings {
|
|||||||
)
|
)
|
||||||
&& ref($v) eq 'HASH'
|
&& ref($v) eq 'HASH'
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ($v->{is_connected} ) {
|
if ( $v->{is_connected} ) {
|
||||||
readingsBulkUpdateIfChanged( $hash,
|
readingsBulkUpdateIfChanged(
|
||||||
$decode_json->{abilities}[0]{properties}[$properties]{name}.'-ip', $v->{ip} )
|
$hash,
|
||||||
if ( ref( $v->{ip} ) ne 'HASH' );
|
$decode_json->{abilities}[0]{properties}
|
||||||
readingsBulkUpdateIfChanged( $hash,
|
[$properties]{name} . '-ip',
|
||||||
$decode_json->{abilities}[0]{properties}[$properties]{name}.'-isconnected', $v->{is_connected} )
|
$v->{ip}
|
||||||
if ( $v->{is_connected} );
|
) if ( ref( $v->{ip} ) ne 'HASH' );
|
||||||
|
readingsBulkUpdateIfChanged(
|
||||||
|
$hash,
|
||||||
|
$decode_json->{abilities}[0]{properties}
|
||||||
|
[$properties]{name} . '-isconnected',
|
||||||
|
$v->{is_connected}
|
||||||
|
) if ( $v->{is_connected} );
|
||||||
}
|
}
|
||||||
} # fi ethernet and wifi
|
} # fi ethernet and wifi
|
||||||
}
|
}
|
||||||
$properties--;
|
$properties--;
|
||||||
|
|
||||||
@ -1315,17 +1336,16 @@ sub createHttpValueStrings {
|
|||||||
} # park until next schedules or override
|
} # park until next schedules or override
|
||||||
elsif (defined($abilities)
|
elsif (defined($abilities)
|
||||||
&& defined($payload)
|
&& defined($payload)
|
||||||
&& $abilities eq 'mower_timer' )
|
&& $abilities eq 'mower' )
|
||||||
{
|
{
|
||||||
my $valve_id;
|
my $valve_id;
|
||||||
$method = 'PUT';
|
|
||||||
|
|
||||||
$uri .=
|
$uri .=
|
||||||
'/devices/'
|
'/devices/'
|
||||||
. $deviceId
|
. $deviceId
|
||||||
. '/abilities/'
|
. '/abilities/'
|
||||||
. $abilities
|
. $abilities
|
||||||
. '/properties/mower_timer';
|
. '/commands/manual_start';
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif (defined($abilities)
|
elsif (defined($abilities)
|
||||||
@ -1561,7 +1581,7 @@ sub DeletePassword {
|
|||||||
],
|
],
|
||||||
"release_status": "stable",
|
"release_status": "stable",
|
||||||
"license": "GPL_2",
|
"license": "GPL_2",
|
||||||
"version": "v2.6.1",
|
"version": "v2.6.2",
|
||||||
"author": [
|
"author": [
|
||||||
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
|
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
|
||||||
],
|
],
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Developed with VSCodium and richterger perl plugin.
|
# Developed with VSCodium and richterger perl plugin.
|
||||||
#
|
#
|
||||||
# (c) 2017-2022 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
|
# (c) 2017-2024 Copyright: Marko Oldenburg (fhemdevelopment at cooltux dot net)
|
||||||
# All rights reserved
|
# All rights reserved
|
||||||
#
|
#
|
||||||
# Special thanks goes to comitters:
|
# Special thanks goes to comitters:
|
||||||
@ -324,8 +324,9 @@ sub Set {
|
|||||||
elsif ( lc $cmd eq 'parkuntilnexttimer' ) {
|
elsif ( lc $cmd eq 'parkuntilnexttimer' ) {
|
||||||
$payload = '"name":"park_until_next_timer"';
|
$payload = '"name":"park_until_next_timer"';
|
||||||
if ( $mainboard_version > 10.30 ) {
|
if ( $mainboard_version > 10.30 ) {
|
||||||
$payload = '"properties":{"name":"mower_timer","value":0}';
|
$payload =
|
||||||
$abilities = 'mower_timer';
|
'"mowerTimer":0,"startingPointDistance":null,"areaId":null';
|
||||||
|
$abilities = 'mower';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ( lc $cmd eq 'startresumeschedule' ) {
|
elsif ( lc $cmd eq 'startresumeschedule' ) {
|
||||||
@ -339,13 +340,15 @@ sub Set {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ( lc $cmd eq 'startoverridetimer' ) {
|
elsif ( lc $cmd eq 'startoverridetimer' ) {
|
||||||
$payload = '"name":"start_override_timer","parameters":{"duration":'
|
|
||||||
. $aArg->[0] * 60 . '}';
|
# $payload = '"name":"start_override_timer","parameters":{"duration":'
|
||||||
if ( $mainboard_version > 10.30 ) {
|
# . $aArg->[0] * 60 . '}';
|
||||||
$payload = '"properties":{"name":"mower_timer","value":'
|
# if ( $mainboard_version > 10.30 ) {
|
||||||
. $aArg->[0] * 60 . '}';
|
$payload = '"startingPointDistance":null,"areaId":null, "mowerTimer": '
|
||||||
$abilities = 'mower_timer';
|
. $aArg->[0] * 60;
|
||||||
}
|
$abilities = 'mower';
|
||||||
|
|
||||||
|
# } removed code < 10.30 api changes March 2024
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( lc $cmd eq 'startpoint' ) {
|
elsif ( lc $cmd eq 'startpoint' ) {
|
||||||
@ -735,7 +738,8 @@ sub WriteReadings {
|
|||||||
. RigReadingsValue( $hash,
|
. RigReadingsValue( $hash,
|
||||||
$propertie->{value} ) # cast all data to string with ""
|
$propertie->{value} ) # cast all data to string with ""
|
||||||
)
|
)
|
||||||
if ( exists( $propertie->{value} )
|
if (
|
||||||
|
exists( $propertie->{value} )
|
||||||
&& $decode_json->{abilities}[$abilities]{name} . '-'
|
&& $decode_json->{abilities}[$abilities]{name} . '-'
|
||||||
. $propertie->{name} ne 'radio-quality'
|
. $propertie->{name} ne 'radio-quality'
|
||||||
&& $decode_json->{abilities}[$abilities]{name} . '-'
|
&& $decode_json->{abilities}[$abilities]{name} . '-'
|
||||||
@ -754,7 +758,10 @@ sub WriteReadings {
|
|||||||
. $propertie->{name} ne 'ic24-valves_connected'
|
. $propertie->{name} ne 'ic24-valves_connected'
|
||||||
&& $decode_json->{abilities}[$abilities]{name} . '-'
|
&& $decode_json->{abilities}[$abilities]{name} . '-'
|
||||||
. $propertie->{name} ne 'ic24-valves_master_config'
|
. $propertie->{name} ne 'ic24-valves_master_config'
|
||||||
&& ref( $propertie->{value} ) ne "HASH" );
|
&& ( $decode_json->{abilities}[$abilities]{name} . '-'
|
||||||
|
. $propertie->{name} ) !~ /scheduling-timeslot_state_\d/
|
||||||
|
&& ref( $propertie->{value} ) ne "HASH"
|
||||||
|
);
|
||||||
|
|
||||||
readingsBulkUpdateIfChanged(
|
readingsBulkUpdateIfChanged(
|
||||||
$hash,
|
$hash,
|
||||||
@ -851,7 +858,30 @@ sub WriteReadings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ic24 and other watering devices calc irrigation left in sec
|
# decode timeslot_state_N arrays code by hhhdg
|
||||||
|
if ( defined( $propertie->{value} )
|
||||||
|
&& $decode_json->{abilities}[$abilities]{name} . '-'
|
||||||
|
. $propertie->{name} =~ /scheduling-timeslot_state_\d/
|
||||||
|
&& ref( $propertie->{value} ) eq "ARRAY" )
|
||||||
|
{
|
||||||
|
while ( my ( $r, $v ) = each @{ $propertie->{value} } ) {
|
||||||
|
if ( ref($v) eq "HASH" ) {
|
||||||
|
my $entry = $r + 1;
|
||||||
|
while ( my ( $i_r, $i_v ) = each %{$v} ) {
|
||||||
|
readingsBulkUpdateIfChanged(
|
||||||
|
$hash,
|
||||||
|
$decode_json->{abilities}[$abilities]{name}
|
||||||
|
. '-'
|
||||||
|
. $propertie->{name} . '_'
|
||||||
|
. $entry . '_'
|
||||||
|
. $i_r,
|
||||||
|
RigReadingsValue( $hash, $i_v )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} # fi defined
|
||||||
|
# ic24 and other watering devices calc irrigation left in sec
|
||||||
readingsBulkUpdateIfChanged(
|
readingsBulkUpdateIfChanged(
|
||||||
$hash,
|
$hash,
|
||||||
$decode_json->{abilities}[$abilities]{name} . '-'
|
$decode_json->{abilities}[$abilities]{name} . '-'
|
||||||
@ -907,15 +937,15 @@ sub WriteReadings {
|
|||||||
foreach my $dev_schedules ( sort keys %{ $hash->{READINGS} } ) {
|
foreach my $dev_schedules ( sort keys %{ $hash->{READINGS} } ) {
|
||||||
my $dev_reading = ReadingsVal( $name, $dev_schedules, "error" );
|
my $dev_reading = ReadingsVal( $name, $dev_schedules, "error" );
|
||||||
push @ist, $dev_reading
|
push @ist, $dev_reading
|
||||||
if $dev_schedules =~ /schedule.*\d_id/; # push reading _id
|
if $dev_schedules =~ /schedule.*\d+_id/; # push reading _id
|
||||||
push @ist, $1
|
push @ist, $1
|
||||||
if $dev_schedules =~
|
if $dev_schedules =~
|
||||||
/schedule.*_(\d)_id/; # push readigs d from x_id
|
/schedule.*_(\d+)_id/; # push readigs d from x_id
|
||||||
|
|
||||||
Log3 $name, 5,
|
Log3 $name, 5,
|
||||||
"[DEBUG] $name - Schedule - Key ist : $dev_schedules ";
|
"[DEBUG] $name - Schedule - Key ist : $dev_schedules ";
|
||||||
Log3 $name, 5, "[DEBUG] $name - Schedule - ID FOUND $dev_reading"
|
Log3 $name, 5, "[DEBUG] $name - Schedule - ID FOUND $dev_reading"
|
||||||
if $dev_schedules =~ /schedule.*_\d_id/; # cloud hat SOLL
|
if $dev_schedules =~ /schedule.*_\d+_id/; # cloud hat SOLL
|
||||||
}
|
}
|
||||||
|
|
||||||
#Log3 $name, 5, "[DEBUG] Cloud:".Dumper(@soll) . "- Internal:". Dumper(@ist);
|
#Log3 $name, 5, "[DEBUG] Cloud:".Dumper(@soll) . "- Internal:". Dumper(@ist);
|
||||||
@ -951,15 +981,13 @@ sub WriteReadings {
|
|||||||
&& scalar(@soll) != scalar( @ist / 2 ) )
|
&& scalar(@soll) != scalar( @ist / 2 ) )
|
||||||
{
|
{
|
||||||
while ( my $old_schedule_id = shift(@ist) ) {
|
while ( my $old_schedule_id = shift(@ist) ) {
|
||||||
if ( length($old_schedule_id) == 1 ) {
|
foreach ( keys %{ $hash->{READINGS} } ) {
|
||||||
foreach ( keys %{ $hash->{READINGS} } ) {
|
delete $hash->{READINGS}->{$_}
|
||||||
delete $hash->{READINGS}->{$_}
|
if ( $_ =~
|
||||||
if ( $_ =~
|
/scheduling-schedules_event_${old_schedule_id}_.*/ );
|
||||||
/scheduling-schedules_event_$old_schedule_id.*/ );
|
|
||||||
}
|
|
||||||
} # fi
|
} # fi
|
||||||
Log3 $name, 5,
|
Log3 $name, 5,
|
||||||
"[DEBUG] - $name : deletereading scheduling-schedules_event_$old_schedule_id.*"
|
"[DEBUG] - $name : deletereading scheduling-schedules_event_${old_schedule_id}_.*"
|
||||||
if length($old_schedule_id) == 1;
|
if length($old_schedule_id) == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2684,7 +2712,7 @@ sub SetPredefinedStartPoints {
|
|||||||
],
|
],
|
||||||
"release_status": "stable",
|
"release_status": "stable",
|
||||||
"license": "GPL_2",
|
"license": "GPL_2",
|
||||||
"version": "v2.6.1",
|
"version": "v2.6.3",
|
||||||
"author": [
|
"author": [
|
||||||
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
|
"Marko Oldenburg <fhemdevelopment@cooltux.net>"
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user