Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacs Support and New Features #26

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
12 changes: 12 additions & 0 deletions custom_components/ vacuum-styj02ym-ha/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"domain": "miio2",
"name": "Xiaomi miio vacuum STYJ02YM",
"documentation": "https://github.com/weslleycsil/vacuum-styj02ym-ha",
"version": "1.0.0",
"requirements": [
"construct==2.10.56",
"python-miio==0.5.12"
],
"dependencies": [],
"codeowners": ["@weslleycsil"]
}
25 changes: 19 additions & 6 deletions vacuum.py → ..._components/ vacuum-styj02ym-ha/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from functools import partial
import logging

from miio import DeviceException, Vacuum # pylint: disable=import-error
from miio import DeviceException, RoborockVacuum # pylint: disable=import-error
import voluptuous as vol

from homeassistant.components.vacuum import (
Expand All @@ -25,7 +25,7 @@
SUPPORT_START,
SUPPORT_STATE,
SUPPORT_STOP,
StateVacuumDevice,
StateVacuumEntity,
)
from homeassistant.const import (
ATTR_ENTITY_ID,
Expand Down Expand Up @@ -120,7 +120,16 @@
}

ALL_PROPS = ["run_state", "mode", "err_state", "battary_life", "box_type", "mop_type", "s_time",
"s_area", "suction_grade", "water_grade", "remember_map", "has_map", "is_mop", "has_newmap"]
"s_area", "suction_grade", "water_grade", "remember_map", "has_map", "is_mop", "has_newmap",
"side_brush_life", "side_brush_hours", "main_brush_life", "main_brush_hours", "hypa_life", "hypa_hours", "mop_life", "mop_hours", "water_percent","hw_info", "sw_info", "start_time", "order_time", "v_state", "zone_data", "repeat_state", "light_state", "is_charge", "is_work", "cur_mapid", "mop_route", "map_num"]

VACUUM_CARD_PROPS_REFERENCES = {
'main_brush_left': 'main_brush_hours',
'side_brush_left': 'side_brush_hours',
'filter_left': 'hypa_hours',
'sensor_dirty_left': 'mop_hours',
'cleaned_area': 's_area',
'cleaning_time': 's_time'}


async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
Expand All @@ -134,7 +143,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=

# Create handler
_LOGGER.info("Initializing with host %s (token %s...)", host, token[:5])
vacuum = Vacuum(host, token)
vacuum = RoborockVacuum(host, token)

mirobo = MiroboVacuum2(name, vacuum)
hass.data[DATA_KEY][host] = mirobo
Expand Down Expand Up @@ -176,7 +185,8 @@ async def async_service_handler(service):
)


class MiroboVacuum2(StateVacuumDevice):
#class MiroboVacuum2(StateVacuumDevice):
class MiroboVacuum2(StateVacuumEntity):
"""Representation of a Xiaomi Vacuum cleaner robot."""

def __init__(self, name, vacuum):
Expand Down Expand Up @@ -369,6 +379,9 @@ def update(self):

self.vacuum_state = dict(zip(ALL_PROPS, state))

for prop in VACUUM_CARD_PROPS_REFERENCES.keys():
self.vacuum_state[prop] = self.vacuum_state[VACUUM_CARD_PROPS_REFERENCES[prop]]

self._available = True

# Automatically set mop based on mop_type
Expand Down Expand Up @@ -410,4 +423,4 @@ async def async_clean_point(self, point):
x, y = point
self._last_clean_point = point
await self._try_command("Unable to clean point: %s", self._vacuum.raw_command, 'set_uploadmap', [0]) \
and await self._try_command("Unable to clean point: %s", self._vacuum.raw_command, 'set_pointclean', [1, x, y])
and await self._try_command("Unable to clean point: %s", self._vacuum.raw_command, 'set_pointclean', [1, x, y])
11 changes: 0 additions & 11 deletions manifest.json

This file was deleted.