diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..91c0bf7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: "Release" + +on: + release: + types: [published, edited] + +permissions: {} + +jobs: + release: + name: "Release" + runs-on: "ubuntu-latest" + permissions: + contents: write + steps: + - name: "Checkout the repository" + uses: "actions/checkout@v3.5.3" + + - name: "Adjust version number" + shell: "bash" + run: | + yq -i -o json '.version="${{ github.event.release.tag_name }}"' \ + "${{ github.workspace }}/custom_components/purrsong/manifest.json" + + - name: "ZIP the integration directory" + shell: "bash" + run: | + cd "${{ github.workspace }}/custom_components/purrsong" + zip purrsong.zip -r ./ + + - name: "Upload the ZIP file to the release" + uses: softprops/action-gh-release@v0.1.15 + with: + files: ${{ github.workspace }}/custom_components/purrsong/purrsong.zip diff --git a/custom_components/purrsong/manifest.json b/custom_components/purrsong/manifest.json index 0228abe..473be22 100644 --- a/custom_components/purrsong/manifest.json +++ b/custom_components/purrsong/manifest.json @@ -8,6 +8,6 @@ "integration_type": "hub", "iot_class": "cloud_polling", "issue_tracker": "https://github.com/RobertD502/home-assistant-lavviebot/issues", - "requirements": ["lavviebotaio==0.0.1.3"], - "version": "0.1.9" + "requirements": ["lavviebotaio==0.1"], + "version": "0.1.10" } diff --git a/custom_components/purrsong/sensor.py b/custom_components/purrsong/sensor.py index ab2aed4..9fdd6a2 100644 --- a/custom_components/purrsong/sensor.py +++ b/custom_components/purrsong/sensor.py @@ -1304,10 +1304,7 @@ def entity_category(self) -> EntityCategory: def native_value(self) -> datetime | str: """ Returns datetime of the most recent error """ - if self.device_data.error_log: - return datetime.utcfromtimestamp(int(self.device_data.error_log[0]['creationTime']) / 1000).replace(tzinfo=timezone.utc) - else: - return "No errors in log" + return datetime.utcfromtimestamp(int(self.device_data.error_log[0]['creationTime']) / 1000).replace(tzinfo=timezone.utc) @property def device_class(self) -> SensorDeviceClass: @@ -1320,4 +1317,13 @@ def icon(self) -> str: """Set icon""" return 'mdi:calendar-clock' + + @property + def available(self) -> bool: + """Make entity available if there is an error log""" + + if self.device_data.error_log: + return True + else: + return False diff --git a/hacs.json b/hacs.json index 7ea969b..69d4f1d 100644 --- a/hacs.json +++ b/hacs.json @@ -2,5 +2,8 @@ { "name": "Lavviebot S", "render_readme": true, - "homeassistant": "2022.11.0b0" + "country": "US", + "homeassistant": "2022.11.0b0", + "zip_release": true, + "filename": "purrsong.zip" }