Snapmaker: Unterschied zwischen den Versionen
Zeile 27: | Zeile 27: | ||
Bei den Readings gibt es diverse Daten, die vom Snapmaker geliefert werden - andere werden als userReadings aus diesen zusammengebaut oder als elektrische Leistung von der Funksteckdose SnapMaker.Power geholt. | Bei den Readings gibt es diverse Daten, die vom Snapmaker geliefert werden - andere werden als userReadings aus diesen zusammengebaut oder als elektrische Leistung von der Funksteckdose SnapMaker.Power geholt. | ||
attr Snapmaker reading01JSON fileName | attr Snapmaker reading01JSON fileName | ||
attr Snapmaker reading01Name job_file_name | attr Snapmaker reading01Name job_file_name | ||
attr Snapmaker reading02JSON progress | attr Snapmaker reading02JSON progress | ||
attr Snapmaker reading02Name progress_completion | attr Snapmaker reading02Name progress_completion | ||
attr Snapmaker reading02OExpr int($val*100)."%" | attr Snapmaker reading02OExpr int($val*100)."%" | ||
attr Snapmaker reading03JSON estimatedTime | attr Snapmaker reading03JSON estimatedTime | ||
attr Snapmaker reading03Name progress_printTime | attr Snapmaker reading03Name progress_printTime | ||
attr Snapmaker reading03OExpr sprintf("%02d:%02d:%02d",int($val/3600),int($val/60-60*int($val/3600)),int($val%60)) | attr Snapmaker reading03OExpr sprintf("%02d:%02d:%02d",int($val/3600),int($val/60-60*int($val/3600)),int($val%60)) | ||
attr Snapmaker reading04JSON elapsedTime | attr Snapmaker reading04JSON elapsedTime | ||
attr Snapmaker reading04Name progress_printTimeElapsed | attr Snapmaker reading04Name progress_printTimeElapsed | ||
attr Snapmaker reading04OExpr sprintf("%02d:%02d:%02d",int($val/3600),int($val/60-60*int($val/3600)),int($val%60)) | attr Snapmaker reading04OExpr sprintf("%02d:%02d:%02d",int($val/3600),int($val/60-60*int($val/3600)),int($val%60)) | ||
attr Snapmaker reading05JSON remainingTime | attr Snapmaker reading05JSON remainingTime | ||
attr Snapmaker reading05Name progress_printTimeRemaining | attr Snapmaker reading05Name progress_printTimeRemaining | ||
attr Snapmaker reading05OExpr sprintf("%02d:%02d:%02d",int($val/3600),int($val/60-60*int($val/3600)),int($val%60)) | attr Snapmaker reading05OExpr sprintf("%02d:%02d:%02d",int($val/3600),int($val/60-60*int($val/3600)),int($val%60)) | ||
attr Snapmaker reading06JSON printStatus | attr Snapmaker reading06JSON printStatus | ||
attr Snapmaker reading06Name status | attr Snapmaker reading06Name status | ||
attr Snapmaker reading07JSON status | attr Snapmaker reading07JSON status | ||
attr Snapmaker reading07Name status2 | attr Snapmaker reading07Name status2 | ||
attr Snapmaker reading08JSON series | attr Snapmaker reading08JSON series | ||
attr Snapmaker reading08Name model | attr Snapmaker reading08Name model | ||
attr Snapmaker reading09JSON bed_temperature_current | attr Snapmaker reading09JSON bed_temperature_current | ||
attr Snapmaker reading09Name temperature_bed_actual | attr Snapmaker reading09Name temperature_bed_actual | ||
attr Snapmaker reading10JSON bed_temperature_target | attr Snapmaker reading10JSON bed_temperature_target | ||
attr Snapmaker reading10Name temperature_bed_target | attr Snapmaker reading10Name temperature_bed_target | ||
attr Snapmaker reading11JSON heads_01_extruders_01_hotend_temperature_current | attr Snapmaker reading11JSON heads_01_extruders_01_hotend_temperature_current | ||
attr Snapmaker reading11Name temperature_tool0_actual | attr Snapmaker reading11Name temperature_tool0_actual | ||
attr Snapmaker reading12JSON heads_01_extruders_01_hotend_temperature_target | attr Snapmaker reading12JSON heads_01_extruders_01_hotend_temperature_target | ||
attr Snapmaker reading12Name temperature_tool0_target | attr Snapmaker reading12Name temperature_tool0_target | ||
attr Snapmaker reading13JSON heads_01_extruders_02_hotend_temperature_current | attr Snapmaker reading13JSON heads_01_extruders_02_hotend_temperature_current | ||
attr Snapmaker reading13Name temperature_tool1_actual | attr Snapmaker reading13Name temperature_tool1_actual | ||
attr Snapmaker reading14JSON heads_01_extruders_02_hotend_temperature_target | attr Snapmaker reading14JSON heads_01_extruders_02_hotend_temperature_target | ||
attr Snapmaker reading14Name temperature_tool1_target | attr Snapmaker reading14Name temperature_tool1_target | ||
attr Snapmaker reading15JSON spindleSpeed | attr Snapmaker reading15JSON spindleSpeed | ||
attr Snapmaker reading15Name spindle_speed | attr Snapmaker reading15Name spindle_speed | ||
attr Snapmaker reading16JSON workSpeed | attr Snapmaker reading16JSON workSpeed | ||
attr Snapmaker reading16Name head_speed | attr Snapmaker reading16Name head_speed | ||
attr Snapmaker reading17JSON token | attr Snapmaker reading17JSON token | ||
attr Snapmaker reading17Name token | attr Snapmaker reading17Name token | ||
attr Snapmaker reading18JSON toolHead | attr Snapmaker reading18JSON toolHead | ||
attr Snapmaker reading18Name toolHead | attr Snapmaker reading18Name toolHead | ||
attr Snapmaker reading22JSON laser10WErrorState | attr Snapmaker reading22JSON laser10WErrorState | ||
attr Snapmaker reading22Name laser_10W_ErrorState | attr Snapmaker reading22Name laser_10W_ErrorState | ||
attr Snapmaker reading23JSON laserCamera | attr Snapmaker reading23JSON laserCamera | ||
attr Snapmaker reading23Name laser_Camera | attr Snapmaker reading23Name laser_Camera | ||
attr Snapmaker reading24JSON laserFocalLength | attr Snapmaker reading24JSON laserFocalLength | ||
attr Snapmaker reading24Name laser_FocalLength | attr Snapmaker reading24Name laser_FocalLength | ||
attr Snapmaker reading25JSON laserPower | attr Snapmaker reading25JSON laserPower | ||
attr Snapmaker reading25Name laser_Power | attr Snapmaker reading25Name laser_Power | ||
[[Datei:Snapmaker2.png|links|mini|480x480px]] | [[Datei:Snapmaker2.png|links|mini|480x480px]] | ||
attr SnapMaker userReadings printer_power:.* {sprintf("%3.0f W",ReadingsVal("SnapMaker.Power","power_0",0))}, | attr SnapMaker userReadings printer_power:.* {sprintf("%3.0f W",ReadingsVal("SnapMaker.Power","power_0",0))}, | ||
progress_printTimeEnding:progress_printTimeElapsed.* {my $e=ReadingsVal("SnapMaker | progress_printTimeEnding:progress_printTimeElapsed.* {my $e=ReadingsVal("SnapMaker","progress_printTimeElapsed",""); | ||
$e=~/(\d\d)\:(\d\d)\:(\d\d)/;my $es=$1*3600+$2*60+$3;my $t=ReadingsVal("SnapMaker | $e=~/(\d\d)\:(\d\d)\:(\d\d)/;my $es=$1*3600+$2*60+$3;my $t=ReadingsVal("SnapMaker","progress_printTime",""); | ||
$t=~/(\d\d)\:(\d\d)\:(\d\d)/;my $ts=$1*3600+$2*60+$3;my $val=$ts-$es; | $t=~/(\d\d)\:(\d\d)\:(\d\d)/;my $ts=$1*3600+$2*60+$3;my $val=$ts-$es; | ||
POSIX::strftime("%H:%M: %S",localtime(time+$val))} | POSIX::strftime("%H:%M: %S",localtime(time+$val))} |
Version vom 13. September 2023, 10:15 Uhr
Achtung: Work in Progress, wird laufend erweitert.
Der Snapmaker ist eine Kombination aus 3D-Drucker, Lasercutter und CNC-Fräser des gleichnamigen Herstellers in verschiedenen Ausführungen.
Ziel der Anbindung an FHEM ist nicht die komplette Steuerung des Druckers - dafür gibt es Luban (Anwendungssoftware für alle drei Teilsysteme), Cura (als Slicer und Frontend für den 3D-Druck), LightBurn (für Laserschneiden) sowie ggf. Octoprint (zur Jobsteuerung), Für Octoprint gibt es auch ein FHEM-Modul, allerdings nutzt nicht jeder Octoprint. Sondern hier geht es um die direkte Überwachung des Druckers in FHEM.
Überwachung mit FHEM
Für die Überwachung empfiehlt sich die Verwendung des Moduls HTTPMOD, mit einem Überwachungsintervall von zunächst 60 Sekunden
define SnapMaker HTTPMOD http://192.168.0.xxx/api/v1/print_job 60 attr SnapMaker bodyEncode utf8 attr SnapMaker devStateIcon .*ffline.*:it_printer@red Opening.*:it_printer@yellow Operational:it_printer@blue Printing.*:it_printer@green attr SnapMaker extractAllJSON 0
Das FHEM-Device kennt nur zwei set-Befehle. Diese dienen nicht der Steuerung des Druckers, sondern dem Ein- und Ausschalten einer Funksteckdose für die Stromversorgung (Power Supply Unit = PSU)des Snapmakers. Im Beispiel ist das ein Shelly-Device mit der Bezeichnung SnapMaker.Power, falls man eine andere Funksteckdose verwendet, kann als set0xURL auch ein REST-Call an FHEM abgesetzt werden. Für das Anschalten gibt es ein Icon in der Übersichtszeile.
attr SnapMaker set01Name turnPSUOn attr SnapMaker set01NoArg 1 attr SnapMaker set01URL http://192.168.0.yyy/relay/0?turn=on attr SnapMaker set02Name turnPSUOff attr SnapMaker set02NoArg 1 attr SnapMaker set02URL http://192.168.0.yyy/relay/0?turn=off attr SnapMaker webCmd turnPSUOn attr SnapMaker cmdIcon turnPSUOn:general_an
Das FHEM-Device kennt nur einen get-Befehl, mit dem der Status des Druckers abgefragt wird
attr SnapMaker get01Name printer_status attr SnapMaker get01URL http://192.168.0.xxx/api/v1/printer attr SnapMaker getHeader1 Content-Type: application/json attr SnapMaker getHeader2 Accept: */*
Readings
Bei den Readings gibt es diverse Daten, die vom Snapmaker geliefert werden - andere werden als userReadings aus diesen zusammengebaut oder als elektrische Leistung von der Funksteckdose SnapMaker.Power geholt.
attr Snapmaker reading01JSON fileName attr Snapmaker reading01Name job_file_name attr Snapmaker reading02JSON progress attr Snapmaker reading02Name progress_completion attr Snapmaker reading02OExpr int($val*100)."%" attr Snapmaker reading03JSON estimatedTime attr Snapmaker reading03Name progress_printTime attr Snapmaker reading03OExpr sprintf("%02d:%02d:%02d",int($val/3600),int($val/60-60*int($val/3600)),int($val%60)) attr Snapmaker reading04JSON elapsedTime attr Snapmaker reading04Name progress_printTimeElapsed attr Snapmaker reading04OExpr sprintf("%02d:%02d:%02d",int($val/3600),int($val/60-60*int($val/3600)),int($val%60)) attr Snapmaker reading05JSON remainingTime attr Snapmaker reading05Name progress_printTimeRemaining attr Snapmaker reading05OExpr sprintf("%02d:%02d:%02d",int($val/3600),int($val/60-60*int($val/3600)),int($val%60)) attr Snapmaker reading06JSON printStatus attr Snapmaker reading06Name status attr Snapmaker reading07JSON status attr Snapmaker reading07Name status2 attr Snapmaker reading08JSON series attr Snapmaker reading08Name model attr Snapmaker reading09JSON bed_temperature_current attr Snapmaker reading09Name temperature_bed_actual attr Snapmaker reading10JSON bed_temperature_target attr Snapmaker reading10Name temperature_bed_target attr Snapmaker reading11JSON heads_01_extruders_01_hotend_temperature_current attr Snapmaker reading11Name temperature_tool0_actual attr Snapmaker reading12JSON heads_01_extruders_01_hotend_temperature_target attr Snapmaker reading12Name temperature_tool0_target attr Snapmaker reading13JSON heads_01_extruders_02_hotend_temperature_current attr Snapmaker reading13Name temperature_tool1_actual attr Snapmaker reading14JSON heads_01_extruders_02_hotend_temperature_target attr Snapmaker reading14Name temperature_tool1_target attr Snapmaker reading15JSON spindleSpeed attr Snapmaker reading15Name spindle_speed attr Snapmaker reading16JSON workSpeed attr Snapmaker reading16Name head_speed attr Snapmaker reading17JSON token attr Snapmaker reading17Name token attr Snapmaker reading18JSON toolHead attr Snapmaker reading18Name toolHead attr Snapmaker reading22JSON laser10WErrorState attr Snapmaker reading22Name laser_10W_ErrorState attr Snapmaker reading23JSON laserCamera attr Snapmaker reading23Name laser_Camera attr Snapmaker reading24JSON laserFocalLength attr Snapmaker reading24Name laser_FocalLength attr Snapmaker reading25JSON laserPower attr Snapmaker reading25Name laser_Power
attr SnapMaker userReadings printer_power:.* {sprintf("%3.0f W",ReadingsVal("SnapMaker.Power","power_0",0))}, progress_printTimeEnding:progress_printTimeElapsed.* {my $e=ReadingsVal("SnapMaker","progress_printTimeElapsed",""); $e=~/(\d\d)\:(\d\d)\:(\d\d)/;my $es=$1*3600+$2*60+$3;my $t=ReadingsVal("SnapMaker","progress_printTime",""); $t=~/(\d\d)\:(\d\d)\:(\d\d)/;my $ts=$1*3600+$2*60+$3;my $val=$ts-$es; POSIX::strftime("%H:%M: %S",localtime(time+$val))}
Damit ergeben sich die nebenstehenden Readings, die ein deutliches Bild des Druckjobs geben.
Zustandsanzeige
Die Zustandsanzeige ist komplex und mehrzeilig
attr Snapmaker stateFormat {my $v=ReadingsVal("SnapMaker","status","");\ my $w=ReadingsVal("SnapMaker","job_file_name",""); \ $w=~s/.gcode//; \ my $x=ReadingsVal("SnapMaker","progress_completion","");\ my $y="";\ if($v eq "Printing"){\ $y=sprintf("3D-Druck (%d %%)\n</br>%s",$x,$w);\ }elsif($v eq "Idle"){\ $y=sprintf("Bereit");\ };\ my $z=ReadingsVal("SnapMaker","printer_power",0);\ sprintf("<p align=\"left\">\n%s\n%s\n<br/>%s</p>",$v,$z,$y)}
(to be continued)