Skip to content

Commit

Permalink
Merge pull request #4 from RobertD502/fix_no_cat_in_location
Browse files Browse the repository at this point in the history
set error time sensor to unavailable if no error log, bump lavviebotaio to 0.1, use zip releases
  • Loading branch information
RobertD502 authored Oct 24, 2023
2 parents 2c42358 + 7c3e617 commit 7d9f90e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]"

- 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/[email protected]
with:
files: ${{ github.workspace }}/custom_components/purrsong/purrsong.zip
4 changes: 2 additions & 2 deletions custom_components/purrsong/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
14 changes: 10 additions & 4 deletions custom_components/purrsong/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

5 changes: 4 additions & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 7d9f90e

Please sign in to comment.