mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
99_roborockUtils.pm:Helper for MQTT2 based Xiaomi Vacuum RockRobo Device
git-svn-id: https://svn.fhem.de/fhem/trunk@24410 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d22fff7357
commit
cd2a9dccc0
86
fhem/contrib/AttrTemplate/99_roborockUtils.pm
Normal file
86
fhem/contrib/AttrTemplate/99_roborockUtils.pm
Normal file
@ -0,0 +1,86 @@
|
||||
##############################################
|
||||
# $Id$
|
||||
# from myUtilsTemplate.pm 21509 2020-03-25 11:20:51Z rudolfkoenig
|
||||
# utils for Xiaomi Vaccum MQTT Implementation
|
||||
# They are then available in every Perl expression.
|
||||
|
||||
package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use JSON;
|
||||
|
||||
sub
|
||||
roborockUtils_Initialize {
|
||||
my $hash = shift;
|
||||
return;
|
||||
}
|
||||
# Enter you functions below _this_ line.
|
||||
|
||||
# strip the names for spots and zones and return a list
|
||||
sub valetudoREdest {
|
||||
my $EVENT = shift;
|
||||
my ($text,%h);
|
||||
$text=decode_json($EVENT);
|
||||
for ('spots','zones') {
|
||||
my @a;
|
||||
for my $i (0..$#{$text->{$_}}) {
|
||||
push @a, $text->{$_}->[$i]->{name}
|
||||
}
|
||||
$h{$_} = join q{,}, @a
|
||||
}
|
||||
return \%h
|
||||
}
|
||||
|
||||
# return the last part topic and payload for mqtt message for certain custom_commands
|
||||
sub valetudoRE {
|
||||
my $EVENT = shift;
|
||||
my $ret = 'error';
|
||||
my ($cmd,$load) = split(q{ }, $EVENT,2);
|
||||
# my $topic = ReadingsVal($NAME,'devicetopic','valetudo/rockrobo');
|
||||
if (@_) {Log 1,"sub valetudoRE - Befehl:$cmd Load:$load";return q{}}
|
||||
my (@zid,@l,%consum);
|
||||
|
||||
if ($cmd eq 'zoned_cleanup') {@zid = split q{,},$load}
|
||||
if ($cmd eq 'map') {@l = split q{ },$load}
|
||||
for (qw(main_brush_work_time side_brush_work_time filter_work_time sensor_dirty_time))
|
||||
{$consum{(split q{_})[0]}=$_};
|
||||
|
||||
my %Hcmd = (
|
||||
goto => { command => 'go_to',spot_id => $load },
|
||||
get_dest => { command => 'get_destinations' },
|
||||
map => { command => $l[0].'_map',name => $l[1] },
|
||||
reset_consumable => { command => 'reset_consumable',consumable => $consum{$load} },
|
||||
zone => { command => 'zoned_cleanup',zone_ids => \@zid },
|
||||
);
|
||||
if ($cmd eq 'x_raw_payload') {$ret=$load}
|
||||
else {$ret = toJSON $Hcmd{$cmd}}
|
||||
return '/custom_command '.$ret
|
||||
}
|
||||
|
||||
1;
|
||||
=pod
|
||||
=item summary generic MQTT2 Xiaomi Roborock Devices rooted with valetudo RE
|
||||
=item summary_DE generische MQTT2 Xiaomi Roborock Devices gerootet mit valetudo RE
|
||||
=begin html
|
||||
Some Subroutines for generic MQTT2 Xiaomi Roborock Devices rooted with valetudo RE.
|
||||
<a id="MQTT2 Xiaomi Roborock"></a>
|
||||
<h3>MQTT2 Xiaomi Roborock</h3>
|
||||
<ul>
|
||||
RoboRockUtils.
|
||||
<br> <br>
|
||||
|
||||
<a id="MQTT2_DEVICE-setList"></a>
|
||||
<b>attr</b>
|
||||
<ul>
|
||||
<code>{valetudoRE($EVENT)}</code>
|
||||
<br><br>
|
||||
To enable below.<br>
|
||||
</ul>
|
||||
<br>
|
||||
</ul>
|
||||
=end html
|
||||
=begin html_DE
|
||||
Enthaelt einige Subroutinen fuer generische MQTT2 Xiaomi Roborock Devices gerootet mit valetudo RE.
|
||||
=end html_DE
|
||||
=cut
|
Loading…
Reference in New Issue
Block a user