Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev' into dev_extra…
Browse files Browse the repository at this point in the history
…cted_libraries

# Conflicts:
#	custom_components/xiaomi_cloud_map_extractor/camera.py
#	custom_components/xiaomi_cloud_map_extractor/common/image_handler.py
#	custom_components/xiaomi_cloud_map_extractor/manifest.json
#	custom_components/xiaomi_cloud_map_extractor/vacuum_platforms/backoff.py
#	custom_components/xiaomi_cloud_map_extractor/vacuum_platforms/xiaomi_cloud_connector.py
  • Loading branch information
PiotrMachowski committed Jan 11, 2025
2 parents c5bcfc2 + c9ae97e commit 0bc0cca
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 20 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
---
name: Release

on:
release:
types: [published]

env:
COMPONENT_NAME: xiaomi_cloud_map_extractor

jobs:
release:
name: Prepare release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Download repo
uses: actions/checkout@v1
uses: actions/checkout@v4.2.2

- name: Adjust version number
shell: bash
run: |
version="${{ github.event.release.tag_name }}"
yq e -P -o=json \
-i ".version = \"${version}\"" \
"${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}/manifest.json"
- name: Zip xiaomi_cloud_map_extractor dir
- name: Zip ${{ env.COMPONENT_NAME }} dir
run: |
cd /home/runner/work/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/custom_components/xiaomi_cloud_map_extractor
zip xiaomi_cloud_map_extractor.zip -r ./
cd "${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}"
zip ${{ env.COMPONENT_NAME }}.zip -r ./
- name: Upload zip to release
uses: svenstaro/upload-release-action@v1-release
uses: softprops/action-gh-release@v2.1.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: /home/runner/work/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_map_extractor.zip
asset_name: xiaomi_cloud_map_extractor.zip
tag: ${{ github.ref }}
overwrite: true
files: ${{ github.workspace }}/custom_components/${{ env.COMPONENT_NAME }}/${{ env.COMPONENT_NAME }}.zip
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ This integration was tested on following vacuums:
- `roborock.vacuum.a15` (Roborock S7)
- `roborock.vacuum.a19` (Roborocka S4 Max)
- `roborock.vacuum.a27` (Roborock S7 MaxV)
- `roborock.vacuum.a70` (Roborock S8 Pro Ultra)
- Viomi map format:
- `viomi.vacuum.v6` (Viomi Vacuum V2 Pro, Xiaomi Mijia STYJ02YM, Mi Robot Vacuum Mop Pro)
- `viomi.vacuum.v7` (Mi Robot Vacuum-Mop Pro)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ action:
- condition: trigger
id: 0
- service: |
{% if trigger.to_state.state in ["unavailable", "unknown", "docked"] %}
{% if trigger.to_state.state in ["unavailable", "unknown", "docked", "idle", "paused", "charging"] %}
camera.turn_off
{% else %}
camera.turn_on
Expand Down
6 changes: 3 additions & 3 deletions custom_components/xiaomi_cloud_map_extractor/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import PIL.Image as Image
import voluptuous as vol
from homeassistant.components.camera import Camera, ENTITY_ID_FORMAT, PLATFORM_SCHEMA, SUPPORT_ON_OFF
from homeassistant.components.camera import Camera, CameraEntityFeature, ENTITY_ID_FORMAT, PLATFORM_SCHEMA
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import generate_entity_id
Expand Down Expand Up @@ -205,8 +205,8 @@ def turn_off(self):
self._should_poll = False

@property
def supported_features(self) -> int:
return SUPPORT_ON_OFF
def supported_features(self):
return CameraEntityFeature.ON_OFF

@property
def extra_state_attributes(self) -> dict[str, any]:
Expand Down
7 changes: 4 additions & 3 deletions custom_components/xiaomi_cloud_map_extractor/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"domain": "xiaomi_cloud_map_extractor",
"name": "Xiaomi Cloud Map Extractor",
"documentation": "https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor",
"issue_tracker": "https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/issues",
"dependencies": [],
"codeowners": [
"@PiotrMachowski"
],
"dependencies": [],
"documentation": "https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/issues",
"requirements": [
"Pillow",
"pybase64",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def get_devices_iter(self, country: Optional[str] = None):
)
yield from devices

def get_device_details(self, token: str, country: Optional[str] = None):
def get_device_details_from_home(self, token: str, country: Optional[str] = None):
devices = self.get_devices_iter(country)
matching_token = filter(lambda device: device.token == token, devices)
if match := next(matching_token, None):
Expand All @@ -228,7 +228,32 @@ def get_other_info(self, device_id: str, method: str, parameters: dict) -> any:
return self.execute_api_call_encrypted(url, params)


def execute_api_call_encrypted(self, url: str, params: dict[str, str]) -> any:
def get_device_details(self, token: str,
country: Optional[str]) -> Tuple[Optional[str], Optional[str], Optional[str], Optional[str]]:
countries_to_check = CONF_AVAILABLE_COUNTRIES
if country is not None:
countries_to_check = [country]
for c in countries_to_check:
devices = self.get_devices(c)
if devices is None:
continue
found = list(filter(lambda d: str(d["token"]).casefold() == str(token).casefold(),
devices["result"]["list"]))
if len(found) > 0:
user_id = found[0]["uid"]
device_id = found[0]["did"]
model = found[0]["model"]
return c, user_id, device_id, model
return self.get_device_details_from_home(token, country)

def get_devices(self, country: str) -> Any:
url = self.get_api_url(country) + "/home/device_list"
params = {
"data": '{"getVirtualModel":false,"getHuamiDevices":0}'
}
return self.execute_api_call_encrypted(url, params)

def execute_api_call_encrypted(self, url: str, params: Dict[str, str]) -> Any:
headers = {
"Accept-Encoding": "identity",
"User-Agent": self._agent,
Expand Down

0 comments on commit 0bc0cca

Please # to comment.