From cf125d1de1b67fb6aebad0383974966ca6fe1625 Mon Sep 17 00:00:00 2001 From: Ellert <> Date: Thu, 18 Apr 2024 09:14:14 +0000 Subject: [PATCH] 74_AutomowerConnect.pm: new attribute mowerPanel git-svn-id: https://svn.fhem.de/fhem/trunk@28806 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/74_AutomowerConnect.pm | 107 ++++++++++++++-------- fhem/lib/FHEM/Devices/AMConnect/Common.pm | 16 ++++ fhem/www/pgm2/automowerconnect.js | 5 + 4 files changed, 92 insertions(+), 37 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 0d93c594c..0974d44a9 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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 + - feature: 74_AutomowerConnect.pm: new attribute mowerPanel - bugfix: 76_SolarForecast: possible Illegal division by zero if Battery SOC management is activated - change: 76_SolarForecast: minor change calculation Today PV deviation diff --git a/fhem/FHEM/74_AutomowerConnect.pm b/fhem/FHEM/74_AutomowerConnect.pm index 3eeb3b52d..319868290 100644 --- a/fhem/FHEM/74_AutomowerConnect.pm +++ b/fhem/FHEM/74_AutomowerConnect.pm @@ -45,42 +45,44 @@ require FHEM::Devices::AMConnect::Common; sub Initialize() { my ($hash) = @_; - $hash->{DefFn} = \&FHEM::Devices::AMConnect::Common::Define; - $hash->{GetFn} = \&FHEM::Devices::AMConnect::Common::Get; - $hash->{UndefFn} = \&FHEM::Devices::AMConnect::Common::Undefine; - $hash->{DeleteFn} = \&FHEM::Devices::AMConnect::Common::Delete; - $hash->{ShutdownFn} = \&FHEM::Devices::AMConnect::Common::Shutdown; - $hash->{RenameFn} = \&FHEM::Devices::AMConnect::Common::Rename; - $hash->{FW_detailFn}= \&FHEM::Devices::AMConnect::Common::FW_detailFn; - $hash->{ReadFn} = \&FHEM::Devices::AMConnect::Common::wsRead; - $hash->{ReadyFn} = \&FHEM::Devices::AMConnect::Common::wsReady; - $hash->{SetFn} = \&FHEM::Devices::AMConnect::Common::Set; - $hash->{AttrFn} = \&FHEM::Devices::AMConnect::Common::Attr; - $hash->{AttrList} = "disable:1,0 " . - "debug:1,0 " . - "disabledForIntervals " . - "mapImagePath " . - "mapImageWidthHeight " . - "mapImageCoordinatesToRegister:textField-long " . - "mapImageCoordinatesUTM:textField-long " . - "mapImageZoom " . - "mapBackgroundColor " . - "mapDesignAttributes:textField-long " . - "mapZones:textField-long " . - "showMap:1,0 " . - "chargingStationCoordinates " . - "chargingStationImagePosition:left,top,right,bottom,center " . - "scaleToMeterXY " . - "mowerCuttingWidth " . - "mowerSchedule:textField-long " . - "mowingAreaLimits:textField-long " . - "mowingAreaHull:textField-long " . - "propertyLimits:textField-long " . - "weekdaysToResetWayPoints " . - "numberOfWayPointsToDisplay " . - "addPollingMinInterval " . - "addPositionPolling:1,0 " . - $::readingFnAttributes; + $hash->{DefFn} = \&FHEM::Devices::AMConnect::Common::Define; + $hash->{GetFn} = \&FHEM::Devices::AMConnect::Common::Get; + $hash->{UndefFn} = \&FHEM::Devices::AMConnect::Common::Undefine; + $hash->{DeleteFn} = \&FHEM::Devices::AMConnect::Common::Delete; + $hash->{ShutdownFn} = \&FHEM::Devices::AMConnect::Common::Shutdown; + $hash->{RenameFn} = \&FHEM::Devices::AMConnect::Common::Rename; + $hash->{FW_detailFn} = \&FHEM::Devices::AMConnect::Common::FW_detailFn; + # $hash->{FW_summaryFn} = \&FHEM::Devices::AMConnect::Common::FW_summaryFn; + $hash->{ReadFn} = \&FHEM::Devices::AMConnect::Common::wsRead; + $hash->{ReadyFn} = \&FHEM::Devices::AMConnect::Common::wsReady; + $hash->{SetFn} = \&FHEM::Devices::AMConnect::Common::Set; + $hash->{AttrFn} = \&FHEM::Devices::AMConnect::Common::Attr; + $hash->{AttrList} = "disable:1,0 " . + "debug:1,0 " . + "disabledForIntervals " . + "mapImagePath " . + "mapImageWidthHeight " . + "mapImageCoordinatesToRegister:textField-long " . + "mapImageCoordinatesUTM:textField-long " . + "mapImageZoom " . + "mapBackgroundColor " . + "mapDesignAttributes:textField-long " . + "mapZones:textField-long " . + "showMap:1,0 " . + "chargingStationCoordinates " . + "chargingStationImagePosition:left,top,right,bottom,center " . + "scaleToMeterXY " . + "mowerCuttingWidth " . + "mowerPanel:textField-long,85 " . + "mowerSchedule:textField-long " . + "mowingAreaLimits:textField-long " . + "mowingAreaHull:textField-long " . + "propertyLimits:textField-long " . + "weekdaysToResetWayPoints " . + "numberOfWayPointsToDisplay " . + "addPollingMinInterval " . + "addPositionPolling:1,0 " . + $::readingFnAttributes; $::data{FWEXT}{AutomowerConnect}{SCRIPT} = 'automowerconnect.js'; $::data{FWEXT}{AutomowerConnectA}{SCRIPT} = '/automowerconnect/hull.js'; @@ -463,7 +465,22 @@ __END__ The design attribute hullSubtract can be set to a natural number {ℕ}, it depicts the recursion depth in which polygon points removed from way points.
This reduces spikes in border region.
hullSubtract="" removes the button 'Subtract Hull'.
- + + +
  • mowerPanel
    + attr <name> mowerPanel <html code>
    + Shows user defined html beneath the map. usefull for a panel with shortcuts
    + The command attribute has to contain the mower command, without set <name>
    + command="Start 210" stands for set <name> Start 210
    + Directives as comment in the first line allow positioning.
    + + Example:
    + + <!-- ON_TOP -->
    + <button command="Start 210" >Start für 3 1/2 h</button>
    +
  • disable
  • @@ -912,6 +929,22 @@ __END__ Wenn hullSubtract="" gesetzt wird, dann wird der Button 'Subtract Hull' entfernt.
    +
  • mowerPanel
    + attr <name> mowerPanel <html code>
    + Zeigt HTML Kode unterhalb der Karte z.B. für ein Panel mit Kurzbefehlen.
    + Das command Attribut beinhaltet den Mäherbefehl, ohne set <name>
    + command="Start 210" steht für set <name> Start 210
    + Direktiven als Kommentar erlauben die Positionierung.
    + + Beispiel:
    + + <!-- ON_TOP -->
    + <button command="Start 210" >Start für 3 1/2 h</button>
    +
    +
  • +
  • disable
  • disabledForIntervals
  • diff --git a/fhem/lib/FHEM/Devices/AMConnect/Common.pm b/fhem/lib/FHEM/Devices/AMConnect/Common.pm index b336be1be..abae25ea2 100644 --- a/fhem/lib/FHEM/Devices/AMConnect/Common.pm +++ b/fhem/lib/FHEM/Devices/AMConnect/Common.pm @@ -478,6 +478,17 @@ sub Get { } } +######################### +sub FW_summaryFn { + my ($FW_wname, $name, $room, $pageHash) = @_; # pageHash is set for summaryFn. + my $hash = $defs{$name}; + my $type = $hash->{TYPE}; + my $content = AttrVal($name, 'mowerPanel', ''); + return '' if( AttrVal($name, 'disable', 0) || !$content || !$::init_done); + $content =~ s/command=['"](.*?)['"]/onclick="AutomowerConnectPanelCmd('set $name $1')"/g; + return $content if ( $content =~ /IN_STATE/ ); +} + ######################### sub FW_detailFn { my ($FW_wname, $name, $room, $pageHash) = @_; # pageHash is set for summaryFn. @@ -580,6 +591,10 @@ sub FW_detailFn { .${type}_${name}_canvas_1{ position: absolute; left: 0; top: 0; z-index: 1;} "; + my $content = AttrVal($name, 'mowerPanel', ''); + my $contentflg = $content =~ /ON_TOP/; + $content =~ s/command=['"](.*?)['"]/onclick="AutomowerConnectPanelCmd('set $name $1')"/g; + $ret .= $content if ( $contentflg ); $ret .= "
    "; $ret .= ""; $ret .= ""; @@ -588,6 +603,7 @@ sub FW_detailFn { if ( -e "$FW_dir/$hash->{helper}{FWEXTA}{path}/$hash->{helper}{FWEXTA}{file}" && !AttrVal( $name,'mowingAreaHull','' ) && $$mapDesign =~ m/hullCalculate="1"/g ); $ret .= "" if ( -e "$FW_dir/$hash->{helper}{FWEXTA}{path}/$hash->{helper}{FWEXTA}{file}" && AttrVal( $name,'mowingAreaHull','' ) && $$mapDesign =~ m/hullSubtract="\d+"/g ); + $ret .= $content if ( !$contentflg ); $ret .= "
    "; $hash->{helper}{detailFnFirst} = 1; my $mid = $hash->{helper}{map_init_delay}; diff --git a/fhem/www/pgm2/automowerconnect.js b/fhem/www/pgm2/automowerconnect.js index 25d1ac7fd..eba954c32 100644 --- a/fhem/www/pgm2/automowerconnect.js +++ b/fhem/www/pgm2/automowerconnect.js @@ -457,6 +457,11 @@ function AutomowerConnectSubtractHull ( path ) { } +function AutomowerConnectPanelCmd ( panelcmd ) { + if ( typeof FW_cmd === "function" ) + FW_cmd( FW_root+"?cmd="+panelcmd+"&XHR=1" ); +} + //AutomowerConnectUpdateDetail (, , , , , , , , , , ) function AutomowerConnectUpdateDetail (dev, type, detailfnfirst, picx, picy, scalx, scaly, errdesc, pos, erray, hullxy) { const colorat = {