2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 09:55:38 +00:00

mqtt2.template,99_valetudoUtils.pm:bugfix in valetudo template

git-svn-id: https://svn.fhem.de/fhem/trunk@26640 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Otto123 2022-11-01 15:45:27 +00:00
parent 51073a8faf
commit 9665fefa1b
2 changed files with 14 additions and 6 deletions

View File

@ -4889,7 +4889,7 @@ desc:use this to control a rooted vacuum with valetudo V2. For further details v
order:X_03b order:X_03b
par:BASE_TOPIC;BASE_TOPIC typically is valetudo;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,([^\/:]+)[\/].*, ? $1 : undef } par:BASE_TOPIC;BASE_TOPIC typically is valetudo;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,([^\/:]+)[\/].*, ? $1 : undef }
par:DEV_ID;DEV_ID is random by Firmware;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^\/]+\/([^\/:]+).*, ? $1 : undef } par:DEV_ID;DEV_ID is random by Firmware;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^\/]+\/([^\/:]+).*, ? $1 : undef }
par:IP4;Device IP Adress;{(split q{,}, ReadingsVal("DEVICE",'ips',undef))[0] || (split q{_}, InternalVal("DEVICE",ReadingsVal("DEVICE",'IODev',undef).'_CONN',undef))[1] || undef } par:IP4;Device IP Adress;{(split q{,}, ReadingsVal("DEVICE",'ips',undef))[0] || (split q{_}, InternalVal("DEVICE",ReadingsVal("DEVICE",'IODev',undef).'_CONN',undef))[-2] || undef }
{ $data{f}='99_valetudoUtils.pm';\ { $data{f}='99_valetudoUtils.pm';\
# Svn_GetFile() works asynch #{ Svn_GetFile("contrib/AttrTemplate/$data{f}", $data{f}, sub(){CommandReload(undef, $data{f})}) }\ # Svn_GetFile() works asynch #{ Svn_GetFile("contrib/AttrTemplate/$data{f}", $data{f}, sub(){CommandReload(undef, $data{f})}) }\
{$data{u}="https://svn.fhem.de/trac/browser/trunk/fhem/contrib/AttrTemplate/$data{f}?format=txt"}\ {$data{u}="https://svn.fhem.de/trac/browser/trunk/fhem/contrib/AttrTemplate/$data{f}?format=txt"}\

View File

@ -117,11 +117,19 @@ sub valetudo_c {
} }
if ($cmd eq 'goto') { if ($cmd eq 'goto') {
if (ReadingsVal($NAME,'valetudo_release','') lt '2022.05.0') {
my $json = ReadingsVal($NAME,'.locationsPresets',q{}); my $json = ReadingsVal($NAME,'.locationsPresets',q{});
my $decoded = decode_j($json); my $decoded = decode_j($json);
for (keys %{$decoded}) { for (keys %{$decoded}) {
if ( $decoded->{$_}->{'name'} eq $load ) {$ret = $devicetopic.'/GoToLocationCapability/go/set '.$_ } if ( $decoded->{$_}->{'name'} eq $load ) {$ret = $devicetopic.'/GoToLocationCapability/go/set '.$_ }
} }
} else {
my $json = ReadingsVal($NAME,'.locations',q{});
my $decoded = decode_j($json);
for (keys %{$decoded}) {
if ( $_ eq $load ) {$ret = $devicetopic.'/GoToLocationCapability/go/set '.toJSON $decoded->{$_} }
}
}
} }
# this part is for study purpose to read the full json segments with the REST API # this part is for study purpose to read the full json segments with the REST API
@ -176,8 +184,8 @@ sub valetudo_z {
sub valetudo_f { sub valetudo_f {
my $NAME = shift; # Devicename of the robot my $NAME = shift; # Devicename of the robot
my $substr = shift; # requested Feature like GoToLocation or MapSegmentation my $substr = shift; # requested Feature like GoToLocation or MapSegmentation
# my $ip = ReadingsVal($NAME,'ip4',(split ',',ReadingsVal($NAME,'ips','error'))[0]); my $ip = ReadingsVal($NAME,'ip4',(split ',',ReadingsVal($NAME,'ips','error'))[0]);
my $ip = ( split '_', InternalVal($NAME,ReadingsVal($NAME,'IODev','').'_CONN','error') )[1] ; #my $ip = ( split '_', InternalVal($NAME,ReadingsVal($NAME,'IODev','').'_CONN','error') )[-2] ;
my $string = GetHttpFile($ip, '/api/v2/robot/capabilities'); my $string = GetHttpFile($ip, '/api/v2/robot/capabilities');
index($string, $substr) == -1 ? 0:1; index($string, $substr) == -1 ? 0:1;
} }
@ -233,7 +241,7 @@ sub valetudo_g {
my $NAME = shift; my $NAME = shift;
my ($cmd,$load) = split q{ }, shift, 2; my ($cmd,$load) = split q{ }, shift, 2;
#Log3(undef, 1, "Name $NAME, cmd $cmd, load $load"); #Log3(undef, 1, "Name $NAME, cmd $cmd, load $load");
my $ip = (split q{ },$load)[1] || ReadingsVal($NAME,'ip4',(split q{_}, InternalVal($NAME,ReadingsVal($NAME,'IODev','').'_CONN','') )[1] || return 'error no ip'); my $ip = (split q{ },$load)[1] || ReadingsVal($NAME,'ip4',(split q{_}, InternalVal($NAME,ReadingsVal($NAME,'IODev','').'_CONN','') )[-2] || return 'error no ip');
if ($load eq 'segments'){ if ($load eq 'segments'){
my $url = '/api/v2/robot/capabilities/MapSegmentationCapability'; my $url = '/api/v2/robot/capabilities/MapSegmentationCapability';
my $json = GetHttpFile($ip, $url); my $json = GetHttpFile($ip, $url);