mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-25 03:44:52 +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:
parent
51073a8faf
commit
9665fefa1b
@ -4889,7 +4889,7 @@ desc:use this to control a rooted vacuum with valetudo V2. For further details v
|
||||
order:X_03b
|
||||
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: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';\
|
||||
# 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"}\
|
||||
|
@ -117,12 +117,20 @@ sub valetudo_c {
|
||||
}
|
||||
|
||||
if ($cmd eq 'goto') {
|
||||
if (ReadingsVal($NAME,'valetudo_release','') lt '2022.05.0') {
|
||||
my $json = ReadingsVal($NAME,'.locationsPresets',q{});
|
||||
my $decoded = decode_j($json);
|
||||
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 return an array of segment id's according to selected Names from json_segments (complex json)
|
||||
@ -176,8 +184,8 @@ sub valetudo_z {
|
||||
sub valetudo_f {
|
||||
my $NAME = shift; # Devicename of the robot
|
||||
my $substr = shift; # requested Feature like GoToLocation or MapSegmentation
|
||||
# my $ip = ReadingsVal($NAME,'ip4',(split ',',ReadingsVal($NAME,'ips','error'))[0]);
|
||||
my $ip = ( split '_', InternalVal($NAME,ReadingsVal($NAME,'IODev','').'_CONN','error') )[1] ;
|
||||
my $ip = ReadingsVal($NAME,'ip4',(split ',',ReadingsVal($NAME,'ips','error'))[0]);
|
||||
#my $ip = ( split '_', InternalVal($NAME,ReadingsVal($NAME,'IODev','').'_CONN','error') )[-2] ;
|
||||
my $string = GetHttpFile($ip, '/api/v2/robot/capabilities');
|
||||
index($string, $substr) == -1 ? 0:1;
|
||||
}
|
||||
@ -233,7 +241,7 @@ sub valetudo_g {
|
||||
my $NAME = shift;
|
||||
my ($cmd,$load) = split q{ }, shift, 2;
|
||||
#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'){
|
||||
my $url = '/api/v2/robot/capabilities/MapSegmentationCapability';
|
||||
my $json = GetHttpFile($ip, $url);
|
||||
|
Loading…
x
Reference in New Issue
Block a user