Skip to content

Commit

Permalink
Added fanSpeed and feedrate
Browse files Browse the repository at this point in the history
  • Loading branch information
klein0r committed Mar 7, 2022
1 parent b77512d commit 2d6a793
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

Adapter to connect OctoPrint to ioBroker

**Tested with [OctoPrint](https://github.com/OctoPrint/OctoPrint/releases) 1.7.3**

## Installation

Please use the "adapter list" in ioBroker to install a stable version of this adapter. You can also use the CLI to install this adapter:
Expand Down Expand Up @@ -46,6 +44,7 @@ Tested with OctoPrint 1.7.3

* (klein0r) Added print times as readable states (seconds to string)
* (klein0r) Added formatted date when print job will finish
* (klein0r) Added fan speed and feedrate from plugin Display Layer Progress

### 3.1.0 (2022-02-24)

Expand Down
2 changes: 2 additions & 0 deletions docs/de/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# ioBroker.octoprint

**Getestet mit [OctoPrint](https://github.com/OctoPrint/OctoPrint/releases) 1.7.3**

## Features

### Informationen
Expand Down
2 changes: 2 additions & 0 deletions docs/en/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# ioBroker.octoprint

**Tested with [OctoPrint](https://github.com/OctoPrint/OctoPrint/releases) 1.7.3**

## Features

### Information
Expand Down
59 changes: 59 additions & 0 deletions lib/plugins/displaylayerprogress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
/* jslint node: true */
'use strict';

// https://github.com/OllisGit/OctoPrint-DisplayLayerProgress

async function refreshValues(adapter) {

await adapter.setObjectNotExistsAsync('plugins.displayLayerProgress', {
Expand Down Expand Up @@ -80,6 +82,55 @@ async function refreshValues(adapter) {
native: {}
});

await adapter.setObjectNotExistsAsync('plugins.displayLayerProgress.feedrate', {
type: 'state',
common: {
name: {
en: 'Feedrate',
de: 'Vorschubgeschwindigkeit',
ru: 'Скорость подачи',
pt: 'Taxa de alimentação',
nl: 'Voedingssnelheid',
fr: 'Vitesse d\'avance',
it: 'avanzamento',
es: 'Velocidad de avance',
pl: 'Szybkość posuwu',
'zh-cn': '进给率'
},
type: 'number',
role: 'value',
read: true,
write: false,
def: 0
},
native: {}
});

await adapter.setObjectNotExistsAsync('plugins.displayLayerProgress.fanSpeed', {
type: 'state',
common: {
name: {
en: 'Fan speed',
de: 'Lüftergeschwindigkeit',
ru: 'Скорость вентилятора',
pt: 'Velocidade do ventilador',
nl: 'Ventilator snelheid',
fr: 'Vitesse du ventilateur',
it: 'Velocità della ventola',
es: 'Velocidad del ventilador',
pl: 'Prędkość wiatraka',
'zh-cn': '风扇转速'
},
type: 'number',
role: 'value',
read: true,
write: false,
unit: '%',
def: 0
},
native: {}
});

adapter.buildPluginRequest(
'DisplayLayerProgress/values'
).then(response => {
Expand All @@ -91,6 +142,14 @@ async function refreshValues(adapter) {
if (response.data.layer.total != '-') {
adapter.setStateAsync('plugins.displayLayerProgress.layer.total', {val: parseInt(response.data.layer.total), ack: true});
}

if (response.data.feedrate != '-') {
adapter.setStateAsync('plugins.displayLayerProgress.feedrate', {val: parseInt(response.data.feedrate.replace(/[^\d.]/g, '')), ack: true});
}

if (response.data.fanSpeed != '-') {
adapter.setStateAsync('plugins.displayLayerProgress.fanSpeed', {val: parseInt(response.data.fanSpeed.replace(/[^\d.]/g, '')), ack: true});
}
} else {
adapter.log.error(`(DisplayLayerProgress/values) status ${response.status}: ${JSON.stringify(response.data)}`);
}
Expand Down

0 comments on commit 2d6a793

Please sign in to comment.