Skip to content

Commit

Permalink
Dev branch, release tags, readme changes, + debug log start
Browse files Browse the repository at this point in the history
  • Loading branch information
sondregronas committed Jul 8, 2024
1 parent 3ea1266 commit 4b89542
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/hassfest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Validate with hassfest
name: Validate

on:
push:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
release:
workflow_dispatch:
jobs:
hacs:
name: HACS Action
runs-on: "ubuntu-latest"
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set version to release tag
run: |
sed -i "s/GITHUB_RELEASE_VERSION/${{ github.event.release.tag_name }}/g" custom_components/ankermake/manifest.json
sed -i "s/GITHUB_RELEASE_VERSION/${{ github.event.release.tag_name }}/g" custom_components/ankermake/const.py
- name: Zip custom_components/ankermake
run: zip -r ankermake.zip custom_components/ankermake

- name: Upload release asset to the existing release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./ankermake.zip
asset_name: ankermake.zip
asset_content_type: application/zip
token: ${{ secrets.GITHUB_TOKEN }}
overwrite: true
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# AnkerMake Home Assistant Component

[![Validation](https://github.com/sondregronas/ankermake-hass-component/actions/workflows/hassfest.yml/badge.svg)](https://github.com/sondregronas/ankermake-hass-component/actions/workflows/hassfest.yml)
[![Tests](https://github.com/sondregronas/ankermake-hass-component/actions/workflows/tests.yml/badge.svg)](https://github.com/sondregronas/ankermake-hass-component/actions/workflows/tests.yml)
[![Release](https://github.com/sondregronas/ankermake-hass-component/actions/workflows/release.yml/badge.svg)](https://github.com/sondregronas/ankermake-hass-component/actions/workflows/release.yml)

Ever wanted a quick way to check the status of your AnkerMake M5 3D printer? This Home Assistant component allows you to
do just that! It listens to the mqtt socket of an [ankerctl](https://github.com/Ankermgmt/ankermake-m5-protocol)
instance and updates the status of your printer in real-time.
Expand All @@ -19,7 +23,9 @@ instance and updates the status of your printer in real-time.

Download and install the component via hacs (alternatively copy the `custom_components/ankermake` folder to your Home
Assistant config) and reboot. You will then be able to add the AnkerMake integration in the Home Assistant integrations
page.
page (or by clicking the badge below).

[![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=ankermake)

> Note: You can add as many instances as you'd like (but you will need an ankerctl instance running for each one).
Expand Down
6 changes: 6 additions & 0 deletions custom_components/ankermake/ankermake_mqtt_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
In other words, this module is the "brain" of the AnkerMake integration.
"""
import os
import re
from dataclasses import dataclass
from datetime import datetime, timedelta
Expand All @@ -19,6 +20,8 @@
ERROR_CODES)

_LOGGER = getLogger(__name__)
if os.environ.get("ANKERMAKE_DEBUG", False):
_LOGGER.setLevel("DEBUG")

RESET_STATES = [AnkerStatus.OFFLINE, AnkerStatus.IDLE]

Expand Down Expand Up @@ -197,6 +200,9 @@ def _remove_error(self):
def update(self, websocket_message: dict):
"""Update the AnkerData object with a new message from the AnkerMake printer."""
command_type = websocket_message.get("commandType")
# Debug logging for all messages except those that spam
if command_type not in [1081, 1084, 1003, 1004]:
_LOGGER.debug(f"Received message: {websocket_message}")
match command_type:
# Print schedule is broadcast at fixed intervals (every 5 seconds or so)
# Not to be confused with print started (unused) that contains mostly the same data
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ankermake/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME = 'AnkerMake'
VERSION = '0.4.0'
VERSION = 'GITHUB_RELEASE_VERSION'
ISSUEURL = 'https://github.com/sondregronas/ankermake-hass-component/issues'

DOMAIN = 'ankermake'
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ankermake/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"documentation": "https://github.com/sondregronas/ankermake-hass-component",
"iot_class": "local_polling",
"issue_tracker": "https://github.com/sondregronas/ankermake-hass-component/issues",
"version": "0.4.0"
"version": "GITHUB_RELEASE_VERSION"
}
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ services:
restart: unless-stopped
environment:
- TZ=Europe/Oslo
- ANKERMAKE_DEBUG=true
ports:
- "8123:8123"
5 changes: 4 additions & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"name": "AnkerMake",
"render_readme": true
"render_readme": true,
"content_in_root": false,
"zip_release": true,
"filename": "ankermake.zip"
}

0 comments on commit 4b89542

Please sign in to comment.