mirror of
https://github.com/home-assistant/core.git
synced 2025-08-19 02:10:12 +00:00
.github
docs
homeassistant
auth
components
ads
alarm_control_panel
alexa
auth
automation
axis
binary_sensor
blink
bmw_connected_drive
calendar
camera
cast
climate
cloud
config
conversation
counter
cover
deconz
device_tracker
dialogflow
elkm1
emulated_hue
fan
frontend
geo_location
google_assistant
group
habitica
hangouts
hassio
homekit
homekit_controller
homematic
homematicip_cloud
http
hue
ifttt
ihc
image_processing
insteon
ios
lifx
light
lock
lovelace
mailbox
mailgun
media_player
mqtt
mysensors
nest
notify
onboarding
opentherm_gw
openuv
persistent_notification
rainmachine
recorder
remember_the_milk
remote
scene
sensor
simplisafe
smhi
sonos
switch
system_log
telegram_bot
tibber
timer
tradfri
tts
twilio
unifi
upnp
vacuum
water_heater
weather
websocket_api
wink
zha
zone
zoneminder
zwave
__init__.py
abode.py
alarmdecoder.py
alert.py
amcrest.py
android_ip_webcam.py
apcupsd.py
api.py
apple_tv.py
aqualogic.py
arduino.py
arlo.py
asterisk_mbox.py
august.py
bbb_gpio.py
bloomsky.py
browser.py
canary.py
cloudflare.py
coinbase.py
comfoconnect.py
configurator.py
daikin.py
datadog.py
demo.py
device_sun_light_trigger.py
digital_ocean.py
discovery.py
dominos.py
doorbird.py
downloader.py
duckdns.py
dweet.py
dyson.py
ecobee.py
ecovacs.py
edp_redy.py
egardia.py
eight_sleep.py
emoncms_history.py
enocean.py
envisalink.py
eufy.py
evohome.py
feedreader.py
ffmpeg.py
folder_watcher.py
foursquare.py
freedns.py
fritzbox.py
gc100.py
goalfeed.py
google.py
google_domains.py
graphite.py
greeneye_monitor.py
hdmi_cec.py
history.py
history_graph.py
hive.py
huawei_lte.py
hydrawise.py
influxdb.py
input_boolean.py
input_datetime.py
input_number.py
input_select.py
input_text.py
insteon_local.py
insteon_plm.py
intent_script.py
introduction.py
iota.py
isy994.py
joaoapps_join.py
juicenet.py
keyboard.py
keyboard_remote.py
kira.py
knx.py
konnected.py
lametric.py
linode.py
lirc.py
litejet.py
logbook.py
logentries.py
logger.py
logi_circle.py
lutron.py
lutron_caseta.py
map.py
matrix.py
maxcube.py
media_extractor.py
melissa.py
microsoft_face.py
mochad.py
modbus.py
mqtt_eventstream.py
mqtt_statestream.py
mychevy.py
mycroft.py
namecheapdns.py
neato.py
netatmo.py
netgear_lte.py
no_ip.py
nuheat.py
nuimo_controller.py
octoprint.py
panel_custom.py
panel_iframe.py
pilight.py
plant.py
prometheus.py
proximity.py
python_script.py
qwikswitch.py
rachio.py
rainbird.py
raincloud.py
raspihats.py
rest_command.py
rflink.py
rfxtrx.py
ring.py
route53.py
rpi_gpio.py
rpi_pfio.py
rss_feed_template.py
sabnzbd.py
satel_integra.py
script.py
scsgate.py
sense.py
services.yaml
shell_command.py
shiftr.py
shopping_list.py
sisyphus.py
skybell.py
sleepiq.py
smappee.py
snips.py
spaceapi.py
spc.py
spider.py
splunk.py
statsd.py
sun.py
tado.py
tahoma.py
tellduslive.py
tellstick.py
tesla.py
thethingsnetwork.py
thingspeak.py
toon.py
tplink_lte.py
tuya.py
upcloud.py
updater.py
usps.py
velbus.py
velux.py
vera.py
verisure.py
volvooncall.py
vultr.py
wake_on_lan.py
waterfurnace.py
watson_iot.py
webhook.py
weblink.py
wemo.py
wirelesstag.py
xiaomi_aqara.py
zabbix.py
zeroconf.py
zigbee.py
helpers
scripts
util
__init__.py
__main__.py
bootstrap.py
config.py
config_entries.py
const.py
core.py
data_entry_flow.py
exceptions.py
loader.py
monkey_patch.py
package_constraints.txt
requirements.py
setup.py
script
tests
virtualization
.coveragerc
.dockerignore
.gitattributes
.gitignore
.hound.yml
.ignore
.isort.cfg
.readthedocs.yml
.travis.yml
CLA.md
CODEOWNERS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile
LICENSE.md
MANIFEST.in
README.rst
mypy.ini
pylintrc
requirements_all.txt
requirements_docs.txt
requirements_test.txt
requirements_test_all.txt
setup.cfg
setup.py
tox.ini

* Bump sucks (Ecovacs) lib to 0.9.3 Changed code that was in place as a workaround pre-0.9.2. This version bump fixes a few issues. * Update requirements_all
89 lines
2.8 KiB
Python
89 lines
2.8 KiB
Python
"""Parent component for Ecovacs Deebot vacuums.
|
|
|
|
For more details about this platform, please refer to the documentation at
|
|
https://home-assistant.io/components/ecovacs/
|
|
"""
|
|
|
|
import logging
|
|
import random
|
|
import string
|
|
|
|
import voluptuous as vol
|
|
|
|
import homeassistant.helpers.config_validation as cv
|
|
from homeassistant.helpers import discovery
|
|
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, \
|
|
EVENT_HOMEASSISTANT_STOP
|
|
|
|
REQUIREMENTS = ['sucks==0.9.3']
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
DOMAIN = "ecovacs"
|
|
|
|
CONF_COUNTRY = "country"
|
|
CONF_CONTINENT = "continent"
|
|
|
|
CONFIG_SCHEMA = vol.Schema({
|
|
DOMAIN: vol.Schema({
|
|
vol.Required(CONF_USERNAME): cv.string,
|
|
vol.Required(CONF_PASSWORD): cv.string,
|
|
vol.Required(CONF_COUNTRY): vol.All(vol.Lower, cv.string),
|
|
vol.Required(CONF_CONTINENT): vol.All(vol.Lower, cv.string),
|
|
})
|
|
}, extra=vol.ALLOW_EXTRA)
|
|
|
|
ECOVACS_DEVICES = "ecovacs_devices"
|
|
|
|
# Generate a random device ID on each bootup
|
|
ECOVACS_API_DEVICEID = ''.join(
|
|
random.choice(string.ascii_uppercase + string.digits) for _ in range(8)
|
|
)
|
|
|
|
|
|
def setup(hass, config):
|
|
"""Set up the Ecovacs component."""
|
|
_LOGGER.debug("Creating new Ecovacs component")
|
|
|
|
hass.data[ECOVACS_DEVICES] = []
|
|
|
|
from sucks import EcoVacsAPI, VacBot
|
|
|
|
ecovacs_api = EcoVacsAPI(ECOVACS_API_DEVICEID,
|
|
config[DOMAIN].get(CONF_USERNAME),
|
|
EcoVacsAPI.md5(config[DOMAIN].get(CONF_PASSWORD)),
|
|
config[DOMAIN].get(CONF_COUNTRY),
|
|
config[DOMAIN].get(CONF_CONTINENT))
|
|
|
|
devices = ecovacs_api.devices()
|
|
_LOGGER.debug("Ecobot devices: %s", devices)
|
|
|
|
for device in devices:
|
|
_LOGGER.info(
|
|
"Discovered Ecovacs device on account: %s with nickname %s",
|
|
device['did'], device['nick'])
|
|
vacbot = VacBot(ecovacs_api.uid,
|
|
ecovacs_api.REALM,
|
|
ecovacs_api.resource,
|
|
ecovacs_api.user_access_token,
|
|
device,
|
|
config[DOMAIN].get(CONF_CONTINENT).lower(),
|
|
monitor=True)
|
|
hass.data[ECOVACS_DEVICES].append(vacbot)
|
|
|
|
def stop(event: object) -> None:
|
|
"""Shut down open connections to Ecovacs XMPP server."""
|
|
for device in hass.data[ECOVACS_DEVICES]:
|
|
_LOGGER.info("Shutting down connection to Ecovacs device %s",
|
|
device.vacuum['did'])
|
|
device.disconnect()
|
|
|
|
# Listen for HA stop to disconnect.
|
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop)
|
|
|
|
if hass.data[ECOVACS_DEVICES]:
|
|
_LOGGER.debug("Starting vacuum components")
|
|
discovery.load_platform(hass, "vacuum", DOMAIN, {}, config)
|
|
|
|
return True
|