From 9267d83024e82d12c06458b614a212bdd04e0fbb Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 10 Sep 2020 10:01:02 +0100 Subject: [PATCH 01/19] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 9a498df..8820057 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,15 @@ Code to read weight measurements from Xiaomi Body Scales. +## BREAKING CHANGE: +Please note there was a breaking change in 0.1.8. The MQTT message json attributes are now in lower snake_case to be compliant with Home-Assistant Attributes. +This means Home-Assistant sensor configuration needs to be adjusted. +For example +`value_template: "{{ value_json['Weight'] }}"` +Needs to be replaced with +`value_template: "{{ value_json['weight'] }}"` +(note the lowercase `w` in `weight`) + ## Supported Scales: Name | Model | Picture --- | --- | :---: From 698d2f11a4c6f9dd387d3d527f35c271a2799bd7 Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 10 Sep 2020 10:30:22 +0100 Subject: [PATCH 02/19] XMTZCO1HM now supported --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8820057..fb35042 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Needs to be replaced with ## Supported Scales: Name | Model | Picture --- | --- | :---: -[Mi Smart Scale 2](https://www.mi.com/global/scale)                                                                                               | XMTZC04HM | ![Mi Scale_2](Screenshots/Mi_Smart_Scale_2_Thumb.png) +[Mi Smart Scale 2](https://www.mi.com/global/scale)                                                                                               | XMTZCO1HM, XMTZC04HM | ![Mi Scale_2](Screenshots/Mi_Smart_Scale_2_Thumb.png) [Mi Body Composition Scale](https://www.mi.com/global/mi-body-composition-scale/) | XMTZC02HM | ![Mi Scale](Screenshots/Mi_Body_Composition_Scale_Thumb.png) [Mi Body Composition Scale 2](https://c.mi.com/thread-2289389-1-0.html) | XMTZC05HM | ![Mi Body Composition Scale 2](Screenshots/Mi_Body_Composition_Scale_2_Thumb.png) From c2952c31db7b12a88c773c379d81535252df8740 Mon Sep 17 00:00:00 2001 From: aiir Date: Fri, 20 Nov 2020 20:37:21 +0300 Subject: [PATCH 03/19] Use numbers in json for numeric values. --- src/Xiaomi_Scale.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Xiaomi_Scale.py b/src/Xiaomi_Scale.py index f3e2a24..4d83822 100644 --- a/src/Xiaomi_Scale.py +++ b/src/Xiaomi_Scale.py @@ -276,23 +276,23 @@ class ScanProcessor(): lib = Xiaomi_Scale_Body_Metrics.bodyMetrics(calcweight, height, age, sex, 0) message = '{' - message += '"weight":"' + "{:.2f}".format(weight) + '"' + message += '"weight":' + "{:.2f}".format(weight) message += ',"weight_unit":"' + str(unit) + '"' - message += ',"bmi":"' + "{:.2f}".format(lib.getBMI()) + '"' - message += ',"basal_metabolism":"' + "{:.2f}".format(lib.getBMR()) + '"' - message += ',"visceral_fat":"' + "{:.2f}".format(lib.getVisceralFat()) + '"' + message += ',"bmi":' + "{:.2f}".format(lib.getBMI()) + message += ',"basal_metabolism":' + "{:.2f}".format(lib.getBMR()) + message += ',"visceral_fat":' + "{:.2f}".format(lib.getVisceralFat()) if hasImpedance: lib = Xiaomi_Scale_Body_Metrics.bodyMetrics(calcweight, height, age, sex, int(miimpedance)) bodyscale = ['Obese', 'Overweight', 'Thick-set', 'Lack-exerscise', 'Balanced', 'Balanced-muscular', 'Skinny', 'Balanced-skinny', 'Skinny-muscular'] - message += ',"lean_body_mass":"' + "{:.2f}".format(lib.getLBMCoefficient()) + '"' - message += ',"body_fat":"' + "{:.2f}".format(lib.getFatPercentage()) + '"' - message += ',"water":"' + "{:.2f}".format(lib.getWaterPercentage()) + '"' - message += ',"bone_mass":"' + "{:.2f}".format(lib.getBoneMass()) + '"' - message += ',"muscle_mass":"' + "{:.2f}".format(lib.getMuscleMass()) + '"' - message += ',"protein":"' + "{:.2f}".format(lib.getProteinPercentage()) + '"' + message += ',"lean_body_mass":' + "{:.2f}".format(lib.getLBMCoefficient()) + message += ',"body_fat":' + "{:.2f}".format(lib.getFatPercentage()) + message += ',"water":' + "{:.2f}".format(lib.getWaterPercentage()) + message += ',"bone_mass":' + "{:.2f}".format(lib.getBoneMass()) + message += ',"muscle_mass":' + "{:.2f}".format(lib.getMuscleMass()) + message += ',"protein":' + "{:.2f}".format(lib.getProteinPercentage()) message += ',"body_type":"' + str(bodyscale[lib.getBodyType()]) + '"' - message += ',"metabolic_age":"' + "{:.0f}".format(lib.getMetabolicAge()) + '"' + message += ',"metabolic_age":' + "{:.0f}".format(lib.getMetabolicAge()) message += ',"timestamp":"' + mitdatetime + '"' message += '}' From 04271c89af75e238d0ef8104d75f19f38ab4ee9f Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Mon, 23 Nov 2020 13:12:40 +0000 Subject: [PATCH 04/19] Add 60 sec sleep to connect to Wifi --- src/wrapper.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wrapper.sh b/src/wrapper.sh index 068d3ee..a0d2002 100644 --- a/src/wrapper.sh +++ b/src/wrapper.sh @@ -1,5 +1,6 @@ #!/bin/bash +sleep 60 # Give the system time after a reboot to connect to WiFi before continuing export MISCALE_MAC=00:00:00:00:00:00 # Mac address of your scale export MQTT_PREFIX=miScale From a3c429ff681f6b4a3a65970937be00d95c07df3b Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Mon, 23 Nov 2020 13:15:37 +0000 Subject: [PATCH 05/19] Remove hard coded discovery, change last updated format --- src/Xiaomi_Scale.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Xiaomi_Scale.py b/src/Xiaomi_Scale.py index 4d83822..e57a8c3 100644 --- a/src/Xiaomi_Scale.py +++ b/src/Xiaomi_Scale.py @@ -193,7 +193,7 @@ OLD_MEASURE = '' def discovery(): for MQTTUser in (USER1_NAME,USER2_NAME,USER3_NAME): message = '{"name": "' + MQTTUser + ' Weight",' - message+= '"state_topic": "miscale/' + MQTTUser + '/weight","value_template": "{{ value_json.weight }}","unit_of_measurement": "kg",' + message+= '"state_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/weight","value_template": "{{ value_json.weight }}"' message+= '"json_attributes_topic": "miscale/' + MQTTUser + '/weight","icon": "mdi:scale-bathroom"}' publish.single( MQTT_DISCOVERY_PREFIX + '/sensor/' + MQTT_PREFIX + '/' + MQTTUser + '/config', @@ -222,16 +222,14 @@ class ScanProcessor(): ### Xiaomi V1 Scale ### if data.startswith('1d18') and sdid == 22: measunit = data[4:6] - sys.stdout.write(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Measuring Unit: {measunit}\n") measured = int((data[8:10] + data[6:8]), 16) * 0.01 - sys.stdout.write(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Measured Raw Weight: {measured}\n") unit = '' if measunit.startswith(('03', 'a3')): unit = 'lbs' if measunit.startswith(('12', 'b2')): unit = 'jin' if measunit.startswith(('22', 'a2')): unit = 'kg' ; measured = measured / 2 if unit: if OLD_MEASURE != round(measured, 2): - self._publish(round(measured, 2), unit, str(datetime.today().strftime('%Y-%m-%d-%H:%M:%S')), "", "") + self._publish(round(measured, 2), unit, str(datetime.now()), "", "") OLD_MEASURE = round(measured, 2) ### Xiaomi V2 Scale ### @@ -250,7 +248,7 @@ class ScanProcessor(): miimpedance = str(int((data[24:26] + data[22:24]), 16)) if unit and isStabilized: if OLD_MEASURE != round(measured, 2) + int(miimpedance): - self._publish(round(measured, 2), unit, str(datetime.today().strftime('%Y-%m-%d-%H:%M:%S')), hasImpedance, miimpedance) + self._publish(round(measured, 2), unit, str(datetime.now()), hasImpedance, miimpedance) OLD_MEASURE = round(measured, 2) + int(miimpedance) From df770e28596137a572cbb9a5963a2e0f6acc7619 Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Mon, 23 Nov 2020 19:05:51 +0000 Subject: [PATCH 06/19] Create main.yml --- .github/workflows/main.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..bbc2af8 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,31 @@ +name: Publish Docker image +on: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build image + run: | + docker buildx build --no-cache --push \ + --tag lolouk44/xiaomi-mi-scale:${{ github.event.release.tag_name }} \ + --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 . From 30192a5a2bffef5502dc2b7d2dc2ecfe65f77758 Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Mon, 23 Nov 2020 19:46:24 +0000 Subject: [PATCH 07/19] Create CHANGELOG.md --- CHANGELOG.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..52ec0c4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,53 @@ +## [0.1.11] - 2020-11-23 +### Changed +- Remove additional logging for Scale V1 that was used for testing +- Changed timestamp to default python format (fixes https://github.com/lolouk44/xiaomi_mi_scale/issues/29) +- Removed hard-coded 'unit_f_measurement' in the MQTT Discovery (fixes https://github.com/lolouk44/hassio-addons/issues/22) +- Fixed hard coded MQTT Discovery Prefix (fixes https://github.com/lolouk44/xiaomi_mi_scale/issues/35) +- Change measures format to be numbers instead of string where applicable (https://github.com/lolouk44/xiaomi_mi_scale/pull/36) +### Added +- Created workflow to automatically build docker images on new releases (Thanks [@AiiR42](https://github.com/AiiR42) for your help) + + +## [0.1.10] - 2020-09-09 +### Changed +- Fixed issue with detection of boolean in MQTT_DISCOVERY (https://github.com/lolouk44/hassio-addons/issues/16 and https://github.com/lolouk44/xiaomi_mi_scale/issues/31) + +## [0.1.9] - 2020-09-08 +### Changed +- Fixed typo in MQTT message following the **breaking change** to snake_case attributes in 0.1.8 + +## [0.1.8] - 2020-09-08 +### Breaking Changes +- Attributes are now snake_case (fixes https://github.com/lolouk44/xiaomi_mi_scale/issues/24) +### Changed +- Fixed default MQTT Prefix in config.json typo (fixes https://github.com/lolouk44/hassio-addons/issues/6) +- Fixed MQTT Discovery value check to discover +- Changed timestamp to default python format +- Changes the bluetooth reset from reset to down-wait-up (fixes https://github.com/lolouk44/hassio-addons/issues/13) +- Fixed hard coded hci0 to provided hci interface when performing a reset +- Fixed weight in Lbs not detected on Scale V1 (XMTZCO1HM) (fixes https://github.com/lolouk44/xiaomi_mi_scale/issues/28) +- Fixed body calculations for non kg weights +- Updated README +### Added +- Added unit to attributes + +## [0.1.7] - 2020-07-06 +### Added +- repository.json to make it a real add-on repo (fixes https://github.com/lolouk44/hassio-addons/issues/4) +## Changed +- Now truly handles optional config entries(fixes https://github.com/lolouk44/hassio-addons/issues/3) +- MQTT Discovery set wtih retain flag (fixes https://github.com/lolouk44/hassio-addons/issues/2) +- README updated to use Xiaomi Mi Fit App to retrieve the MAC Address (fixes https://github.com/lolouk44/xiaomi_mi_scale/pull/25) + +## [0.1.6] - 2020-07-01 +### Added +- Docker Image so install is quicker (no local build required). + +## [0.1.5] - 2020-07-01 +### Added +- MQTT Discovery Support. + +## [0.1.4] - 2020-06-29 +### Added +- First release (version in line with non Add-On script for ease of maintenance). From 548571a5d843334d51ef70bd499bbd5008bfa7cd Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Mon, 23 Nov 2020 19:47:03 +0000 Subject: [PATCH 08/19] stand alone from hass.io docker containers --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e8c2134..d8e9481 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.8-slim -LABEL io.hass.version="0.1.7" io.hass.type="addon" io.hass.arch="armhf|aarch64|i386|amd64" + WORKDIR /opt/miscale COPY src /opt/miscale From 96244218302a565fcac2d2c95400fb594c956e5e Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Mon, 23 Nov 2020 20:32:11 +0000 Subject: [PATCH 09/19] workflow - multiple docker tags --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bbc2af8..7efec86 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,4 +28,5 @@ jobs: run: | docker buildx build --no-cache --push \ --tag lolouk44/xiaomi-mi-scale:${{ github.event.release.tag_name }} \ - --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 . + --tag lolouk44/xiaomi-mi-scale:latest \ + --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 . \ No newline at end of file From c16e432ae9e486252c1aa297bb2edde58357ed92 Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Mon, 23 Nov 2020 20:47:06 +0000 Subject: [PATCH 10/19] 0.1.12 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52ec0c4..ad884c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.1.12] - 2020-11-23 +### Changed +- Updated workflow to automatically build docker images on new releases with version and latest tags + ## [0.1.11] - 2020-11-23 ### Changed - Remove additional logging for Scale V1 that was used for testing From 4bf56d8085f84116ef05a3fa5d2dac9de5cec0c9 Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Mon, 23 Nov 2020 21:54:30 +0000 Subject: [PATCH 11/19] 0.1.12 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb35042..4ea9866 100644 --- a/README.md +++ b/README.md @@ -136,4 +136,4 @@ Thanks to @syssi (https://gist.github.com/syssi/4108a54877406dc231d95514e538bde9 Special thanks to [@ned-kelly](https://github.com/ned-kelly) for his help turning a "simple" python script into a fully fledged docker container -Thanks to [@bpaulin](https://github.com/bpaulin) for his PRs and collaboration +Thanks to [@bpaulin](https://github.com/bpaulin), [@AiiR42](https://github.com/AiiR42) for their PRs and collaboration From 9b6519f299f3b4c26352068f1994c7e2af5f4402 Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 26 Nov 2020 09:47:10 +0000 Subject: [PATCH 12/19] 0.1.14a --- .github/workflows/main.yml | 10 ++++++---- CHANGELOG.md | 4 ++++ Dockerfile | 3 ++- src/Xiaomi_Scale.py | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7efec86..78c0368 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Publish Docker image on: release: types: [published] - + jobs: push_to_registry: name: Push Docker image to Docker Hub @@ -14,7 +14,7 @@ jobs: - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 - + - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -28,5 +28,7 @@ jobs: run: | docker buildx build --no-cache --push \ --tag lolouk44/xiaomi-mi-scale:${{ github.event.release.tag_name }} \ - --tag lolouk44/xiaomi-mi-scale:latest \ - --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 . \ No newline at end of file + --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 . + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/CHANGELOG.md b/CHANGELOG.md index ad884c0..1294a95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.1.13] - 2020-11-26 +### Changed +- Fixed MQTT Discovery Message + ## [0.1.12] - 2020-11-23 ### Changed - Updated workflow to automatically build docker images on new releases with version and latest tags diff --git a/Dockerfile b/Dockerfile index d8e9481..7b02881 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.8-slim WORKDIR /opt/miscale COPY src /opt/miscale -RUN apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install no-install-recommends -y \ bluez \ python-pip \ libglib2.0-dev && \ @@ -14,5 +14,6 @@ RUN pip install -r requirements.txt # Copy in docker scripts to root of container... COPY dockerscripts/ / +RUN chmod +x /entrypoint.sh && chmod +x /cmd.sh ENTRYPOINT ["/entrypoint.sh"] CMD ["/cmd.sh"] \ No newline at end of file diff --git a/src/Xiaomi_Scale.py b/src/Xiaomi_Scale.py index e57a8c3..398e512 100644 --- a/src/Xiaomi_Scale.py +++ b/src/Xiaomi_Scale.py @@ -193,8 +193,8 @@ OLD_MEASURE = '' def discovery(): for MQTTUser in (USER1_NAME,USER2_NAME,USER3_NAME): message = '{"name": "' + MQTTUser + ' Weight",' - message+= '"state_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/weight","value_template": "{{ value_json.weight }}"' - message+= '"json_attributes_topic": "miscale/' + MQTTUser + '/weight","icon": "mdi:scale-bathroom"}' + message+= '"state_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/weight","value_template": "{{ value_json['weight'] }}",' + message+= '"json_attributes_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/weight","icon": "mdi:scale-bathroom"}' publish.single( MQTT_DISCOVERY_PREFIX + '/sensor/' + MQTT_PREFIX + '/' + MQTTUser + '/config', message, From f303708992a7cca910b3cf72a106c323d3fdf8de Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 26 Nov 2020 09:53:54 +0000 Subject: [PATCH 13/19] 0.1.13b --- CHANGELOG.md | 4 ---- Dockerfile | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1294a95..ad884c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,3 @@ -## [0.1.13] - 2020-11-26 -### Changed -- Fixed MQTT Discovery Message - ## [0.1.12] - 2020-11-23 ### Changed - Updated workflow to automatically build docker images on new releases with version and latest tags diff --git a/Dockerfile b/Dockerfile index 7b02881..3c615a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.8-slim WORKDIR /opt/miscale COPY src /opt/miscale -RUN apt-get update && apt-get install no-install-recommends -y \ +RUN apt-get update && apt-get install --no-install-recommends -y \ bluez \ python-pip \ libglib2.0-dev && \ From c386f973718d38c0196bddd1099fb4ca429c4633 Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 26 Nov 2020 11:42:31 +0000 Subject: [PATCH 14/19] 0.1.114c --- Dockerfile | 2 +- src/Xiaomi_Scale.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3c615a4..4e33141 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.8-slim WORKDIR /opt/miscale COPY src /opt/miscale -RUN apt-get update && apt-get install --no-install-recommends -y \ +RUN apt-get update && apt-get install -y \ bluez \ python-pip \ libglib2.0-dev && \ diff --git a/src/Xiaomi_Scale.py b/src/Xiaomi_Scale.py index 398e512..58cf233 100644 --- a/src/Xiaomi_Scale.py +++ b/src/Xiaomi_Scale.py @@ -193,7 +193,7 @@ OLD_MEASURE = '' def discovery(): for MQTTUser in (USER1_NAME,USER2_NAME,USER3_NAME): message = '{"name": "' + MQTTUser + ' Weight",' - message+= '"state_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/weight","value_template": "{{ value_json['weight'] }}",' + message+= '"state_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/weight","value_template": "{{ value_json.weight }}",' message+= '"json_attributes_topic": "' + MQTT_PREFIX + '/' + MQTTUser + '/weight","icon": "mdi:scale-bathroom"}' publish.single( MQTT_DISCOVERY_PREFIX + '/sensor/' + MQTT_PREFIX + '/' + MQTTUser + '/config', From 589d4ceafc9e542834a2952fd077b77683e1b47e Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 26 Nov 2020 12:28:34 +0000 Subject: [PATCH 15/19] 0.1.113 --- .github/workflows/main.yml | 1 + CHANGELOG.md | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 78c0368..4b06265 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,7 @@ jobs: run: | docker buildx build --no-cache --push \ --tag lolouk44/xiaomi-mi-scale:${{ github.event.release.tag_name }} \ + --tag lolouk44/xiaomi-mi-scale:latest \ --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 . - name: Image digest diff --git a/CHANGELOG.md b/CHANGELOG.md index ad884c0..1294a95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.1.13] - 2020-11-26 +### Changed +- Fixed MQTT Discovery Message + ## [0.1.12] - 2020-11-23 ### Changed - Updated workflow to automatically build docker images on new releases with version and latest tags From 441084f57475fac4c11fe2172a46695ed4c0607e Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 26 Nov 2020 15:43:01 +0000 Subject: [PATCH 16/19] 0.1.14a --- .github/workflows/main.yml | 2 +- Dockerfile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4b06265..3cd069f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: run: | docker buildx build --no-cache --push \ --tag lolouk44/xiaomi-mi-scale:${{ github.event.release.tag_name }} \ - --tag lolouk44/xiaomi-mi-scale:latest \ + --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 . - name: Image digest diff --git a/Dockerfile b/Dockerfile index 4e33141..9e137cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ FROM python:3.8-slim WORKDIR /opt/miscale COPY src /opt/miscale -RUN apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install --no-install-recommends -y \ + build-essential \ bluez \ python-pip \ libglib2.0-dev && \ From dcaedf1cfd8b8fd7d55458e0b558346e2c53e792 Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 26 Nov 2020 15:54:57 +0000 Subject: [PATCH 17/19] 0.1.14b --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3cd069f..78c0368 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,6 @@ jobs: run: | docker buildx build --no-cache --push \ --tag lolouk44/xiaomi-mi-scale:${{ github.event.release.tag_name }} \ - --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 . - name: Image digest From 6542a02525b5f6b7c32e2c0cea97eb00b91be584 Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 26 Nov 2020 16:11:46 +0000 Subject: [PATCH 18/19] 0.1.14 --- .github/workflows/main.yml | 1 + CHANGELOG.md | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 78c0368..4b06265 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,7 @@ jobs: run: | docker buildx build --no-cache --push \ --tag lolouk44/xiaomi-mi-scale:${{ github.event.release.tag_name }} \ + --tag lolouk44/xiaomi-mi-scale:latest \ --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 . - name: Image digest diff --git a/CHANGELOG.md b/CHANGELOG.md index 1294a95..abca157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.1.14] - 2020-11-26 +### Changed +- Reduced docker image size + ## [0.1.13] - 2020-11-26 ### Changed - Fixed MQTT Discovery Message From a5ddd5d334fd1968baabd510ef93d47484d31fbb Mon Sep 17 00:00:00 2001 From: lolouk44 Date: Thu, 10 Dec 2020 11:36:55 +0000 Subject: [PATCH 19/19] Update wrapper.sh --- src/wrapper.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wrapper.sh b/src/wrapper.sh index a0d2002..c8f556d 100644 --- a/src/wrapper.sh +++ b/src/wrapper.sh @@ -2,7 +2,15 @@ sleep 60 # Give the system time after a reboot to connect to WiFi before continuing export MISCALE_MAC=00:00:00:00:00:00 # Mac address of your scale -export MQTT_PREFIX=miScale +export HCI_DEV=hci0 # Bluetooth hci device to use +export MQTT_HOST=127.0.0.1 # MQTT Server (defaults to 127.0.0.1) +export MQTT_PREFIX=miscale # MQTT Topic Prefix. Defaults to miscale +export MQTT_USERNAME= # Username for MQTT server (comment out if not required) +export MQTT_PASSWORD= # Password for MQTT (comment out if not required) +export MQTT_PORT=1883 # Defaults to 1883 +export TIME_INTERVAL=30 # Time in sec between each query to the scale, to allow other applications to use the Bluetooth module. Defaults to 30 +export MQTT_DISCOVERY=true # Home Assistant Discovery (true/false), defaults to true +export MQTT_DISCOVERY_PREFIX= # Home Assistant Discovery Prefix, defaults to homeassistant export USER1_GT=70 # If the weight is greater than this number, we'll assume that we're weighing User #1 export USER1_SEX=male