Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fan speed from companion plugin websocket messages #3375

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 15
labels:
- dependencies
# Check for updates to GitHub Actions every week
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
4 changes: 2 additions & 2 deletions .github/workflows/approve-and-merge-dependency-updates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Auto Approve
uses: hmarr/auto-approve-action@v2
uses: hmarr/auto-approve-action@v3
if: github.actor == 'dependabot[bot]'
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
Expand All @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Auto Merge
uses: pascalgn/automerge-action@v0.13.1
uses: pascalgn/automerge-action@v0.16.0
if: github.actor == 'dependabot[bot]'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v2
env:
Expand All @@ -25,7 +25,7 @@ jobs:
restore-keys: |
octodash-build-${{ env.cache-name }}-
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14'
- name: Install latest npm
Expand All @@ -40,7 +40,7 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v2
env:
Expand All @@ -51,7 +51,7 @@ jobs:
restore-keys: |
octodash-build-${{ env.cache-name }}-
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14'
- name: Install latest npm
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v3
env:
cache-name: octodash-node-modules
with:
Expand All @@ -20,16 +20,20 @@ jobs:
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '14'
- name: Install latest npm
run: sudo npm install -g npm@latest
- name: Installing Dependencies
run: npm ci
- name: Building Application
run: npm run build:prod
- name: Packaging Application
run: npm run electron:pack
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
path: package/octodash*.deb
4 changes: 3 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ function createWindow() {

if (dev) {
url = 'http://localhost:4200';
window.webContents.openDevTools();
let devtools = new BrowserWindow();
window.webContents.setDevToolsWebContents(devtools.webContents);
window.webContents.openDevTools({ mode: 'detach' });
} else {
url = `file://${__dirname}/dist/${locale}/index.html`;
window.setFullScreen(true);
Expand Down
24 changes: 12 additions & 12 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,13 @@ text_input() {



arch=$(uname -m)
if [[ $arch == x86_64 ]]; then
releaseURL=$(curl -s "https://api.github.com/repos/UnchartedBull/OctoDash/releases/latest" | grep "browser_download_url.*amd64.deb" | cut -d '"' -f 4)
elif [[ $arch == aarch64 ]]; then
releaseURL=$(curl -s "https://api.github.com/repos/UnchartedBull/OctoDash/releases/latest" | grep "browser_download_url.*arm64.deb" | cut -d '"' -f 4)
elif [[ $arch == arm* ]]; then
arch=$(dpkg --print-architecture)
if [[ $arch == armhf ]]; then
releaseURL=$(curl -s "https://api.github.com/repos/UnchartedBull/OctoDash/releases/latest" | grep "browser_download_url.*armv7l.deb" | cut -d '"' -f 4)
elif [[ $arch == arm64 ]]; then
releaseURL=$(curl -s "https://api.github.com/repos/UnchartedBull/OctoDash/releases/latest" | grep "browser_download_url.*arm64.deb" | cut -d '"' -f 4)
elif [[ $arch == amd64 ]]; then
releaseURL=$(curl -s "https://api.github.com/repos/UnchartedBull/OctoDash/releases/latest" | grep "browser_download_url.*amd64.deb" | cut -d '"' -f 4)
fi
dependencies="libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 xdg-utils libatspi2.0-0 libuuid1 libappindicator3-1 libsecret-1-0 xserver-xorg ratpoison x11-xserver-utils xinit libgtk-3-0 bc desktop-file-utils libavahi-compat-libdnssd1 libpam0g-dev libx11-dev"
IFS='/' read -ra version <<< "$releaseURL"
Expand All @@ -695,12 +695,12 @@ echo "Installing Dependencies ..."
exit -1
}

if [ -d "/home/pi/OctoPrint/venv" ]; then
DIRECTORY="/home/pi/OctoPrint/venv"
elif [ -d "/home/pi/oprint" ]; then
DIRECTORY="/home/pi/oprint"
if [ -d "$HOME/OctoPrint/venv" ]; then
DIRECTORY="$HOME/OctoPrint/venv"
elif [ -d "$HOME/oprint" ]; then
DIRECTORY="$HOME/oprint"
else
echo "Neither /home/pi/OctoPrint/venv nor /home/pi/oprint can be found."
echo "Neither $HOME/OctoPrint/venv nor $HOME/oprint can be found."
echo "If your OctoPrint instance is running on a different machine just type - in the following prompt."
text_input "Please specify OctoPrints full virtualenv path manually (no trailing slash)." DIRECTORY
fi;
Expand Down Expand Up @@ -834,7 +834,7 @@ EOF
sudo chmod +x ~/scripts/update-octodash

sudo bash -c 'cat >> /etc/sudoers.d/update-octodash' <<EOF
pi ALL=NOPASSWD: /home/pi/scripts/update-octodash
pi ALL=NOPASSWD: $HOME/scripts/update-octodash
EOF
fi

Expand Down
3 changes: 3 additions & 0 deletions src/app/config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export const defaultConfig: Config = {
topic: 'topic',
relayNumber: null,
},
companionPlugin: {
enabled: false,
},
},
octodash: {
customActions: [
Expand Down
1 change: 1 addition & 0 deletions src/app/config/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ interface Plugins {
tpLinkSmartPlug: TPLinkSmartPlugPlugin;
tasmota: TasmotaPlugin;
tasmotaMqtt: TasmotaMqttPlugin;
companionPlugin: Plugin;
}

interface Plugin {
Expand Down
4 changes: 4 additions & 0 deletions src/app/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ export class ConfigService {
return this.config.plugins.displayLayerProgress.enabled;
}

public isCompanionPluginEnabled(): boolean {
return this.config.plugins.companionPlugin.enabled;
}

public isPreheatPluginEnabled(): boolean {
return this.config.plugins.preheatButton.enabled;
}
Expand Down
9 changes: 9 additions & 0 deletions src/app/config/setup/plugins/plugins.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

<div class="setup__plugin-list">
<div class="scroll__thumb-inactive"></div>
<span>
<app-toggle-switch
[value]="companionPlugin"
(valueChange)="companionPluginChange.emit(!companionPlugin)"
>
</app-toggle-switch>
<ng-container i18n="@@plugin-octodash-companion">OctoDash Companion</ng-container>
</span>

<span>
<app-toggle-switch
[value]="displayLayerProgressPlugin"
Expand Down
2 changes: 2 additions & 0 deletions src/app/config/setup/plugins/plugins.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class PluginsComponent {
@Input() tpLinkSmartPlugPlugin: boolean;
@Input() tasmotaPlugin: boolean;
@Input() tasmotaMqttPlugin: boolean;
@Input() companionPlugin: boolean;

@Output() displayLayerProgressPluginChange = new EventEmitter<boolean>();
@Output() enclosurePluginChange = new EventEmitter<boolean>();
Expand All @@ -29,4 +30,5 @@ export class PluginsComponent {
@Output() tpLinkSmartPlugPluginChange = new EventEmitter<boolean>();
@Output() tasmotaPluginChange = new EventEmitter<boolean>();
@Output() tasmotaMqttPluginChange = new EventEmitter<boolean>();
@Output() companionPluginChange = new EventEmitter<boolean>();
}
1 change: 1 addition & 0 deletions src/app/model/octoprint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './printer-commands.model';
export * from './printer-profile.model';
export * from './socket.model';

export * from './plugins/companion.model';
export * from './plugins/display-layer-progress.model';
export * from './plugins/enclosure.model';
export * from './plugins/filament-manager.model';
Expand Down
3 changes: 3 additions & 0 deletions src/app/model/octoprint/plugins/companion.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface CompanionData {
fanspeed: object;
}
22 changes: 18 additions & 4 deletions src/app/services/socket/socket.octoprint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
SocketAuth,
} from '../../model';
import {
CompanionData,
DisplayLayerProgressData,
OctoprintFilament,
OctoprintPluginMessage,
Expand Down Expand Up @@ -81,7 +82,8 @@ export class OctoPrintSocketService implements SocketService {
set: 0,
unit: '°C',
},
fanSpeed: this.configService.isDisplayLayerProgressEnabled() ? 0 : -1,
fanSpeed:
this.configService.isDisplayLayerProgressEnabled() || this.configService.isCompanionPluginEnabled() ? 0 : -1,
} as PrinterStatus;
this.printerStatusSubject.next(this.printerStatus);
}
Expand Down Expand Up @@ -168,6 +170,10 @@ export class OctoPrintSocketService implements SocketService {
check: (plugin: string) => ['action_command_prompt', 'action_command_notification'].includes(plugin),
handler: (message: unknown) => this.handlePrinterNotification(message as PrinterNotification),
},
{
check: (plugin: string) => plugin === 'octodash' && this.configService.isCompanionPluginEnabled(),
handler: (message: unknown) => this.extractFanSpeed(message as CompanionData),
},
];

plugins.forEach(plugin => plugin.check(pluginMessage.plugin.plugin) && plugin.handler(pluginMessage.plugin.data));
Expand Down Expand Up @@ -254,9 +260,17 @@ export class OctoPrintSocketService implements SocketService {
this.printerStatusSubject.next(this.printerStatus);
}

public extractFanSpeed(message: DisplayLayerProgressData): void {
this.printerStatus.fanSpeed =
message.fanspeed === 'Off' ? 0 : message.fanspeed === '-' ? 0 : Number(message.fanspeed.replace('%', '').trim());
public extractFanSpeed(message: DisplayLayerProgressData | CompanionData): void {
if (typeof message.fanspeed === 'object') {
this.printerStatus.fanSpeed = Number(Math.round(message.fanspeed['1']));
} else {
this.printerStatus.fanSpeed =
message.fanspeed === 'Off'
? 0
: message.fanspeed === '-'
? 0
: Number(message.fanspeed.replace('%', '').trim());
}
}

//==== Job Status ====//
Expand Down
9 changes: 9 additions & 0 deletions src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,15 @@
<span i18n="@@settings-plugins">plugins</span>
</span>
<div class="settings__scroll">
<span class="settings__heading-2" i18n="@@settings-octodash-companion">OctoDash Companion</span>
<div
class="settings__checkbox-container"
(click)="config.plugins.companionPlugin.enabled = !config.plugins.companionPlugin.enabled">
<span class="settings__checkbox">
<span class="settings__checkbox-checked" *ngIf="config.plugins.companionPlugin.enabled"></span>
</span>
<span class="settings__checkbox-descriptor" i18n="@@settings-octodash-companion-enabled">enabled</span>
</div>
<span class="settings__heading-2" i18n="@@settings-display-layer-progress">Display Layer Progress</span>
<div
class="settings__checkbox-container"
Expand Down
Loading