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

Dev #3

Merged
merged 13 commits into from
Jan 4, 2023
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ ecovacs:
password:
country:
continent:
bumper: true/false (optional, defaults false)
bumper_server: (optional, defaults null)
verify_ssl: true/false, false if using bumper (optional, defaults true)
verify_ssl: true/false, use false if using bumper (optional, defaults true)
```
Any username, password, country, and continent should work if bumper is true. Set bumper_server to the ip_address where you're running bumper and set verify_ssl to false for bumper. If you're not using bumper this SHOULD technically work no different than the Home Assistant ecovacs integration but I haven't looked at it enough to be sure and I haven't tested it.
Any username, password, country, and continent should work if using bumper. Set verify_ssl to false for bumper. If you're not using bumper this SHOULD technically work no different than the Home Assistant ecovacs integration but I haven't looked at it enough to be sure and I haven't tested it.

### Example Config
```
Expand All @@ -53,8 +51,6 @@ ecovacs:
password: bumper
country: us
continent: na
bumper: true
bumper_server: "192.168.1.55"
verify_ssl: false
```
Just finished getting this working late 12/13/22 so not sure if everything works yet but will commit changes here if I update it or at least document issues.
Expand Down
65 changes: 23 additions & 42 deletions custom_components/ecovacs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
"""Support for Ecovacs Deebot vacuums."""
import logging
import random
import string

##import asyncio ## to do


#just included the modified sucks in component
from .sucksbumper import EcoVacsAPI, VacBot
import voluptuous as vol
#import asyncio ## to do will need to convert to slixmpp to do this i believe

from homeassistant.const import (
CONF_PASSWORD,
CONF_USERNAME,
CONF_VERIFY_SSL, # added
CONF_PASSWORD,
CONF_COUNTRY,
CONF_VERIFY_SSL,
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
import voluptuous as vol
#just included the modified sucks in component
from .sucksbumper import EcoVacsAPI, VacBot
from .const import (
ECOVACS_DEVICES,
DOMAIN,

_LOGGER = logging.getLogger(__name__)

DOMAIN = "ecovacs"

CONF_COUNTRY = "country"
CONF_CONTINENT = "continent"
#bumper config vars
CONF_BUMPER = "bumper"
CONF_BUMPER_SERVER = "bumper_server"
server_address = None
CONF_CONTINENT,
LOGGER
)

CONFIG_SCHEMA = vol.Schema(
{
Expand All @@ -41,33 +34,23 @@
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),
vol.Optional(CONF_BUMPER, default=False): cv.boolean,
vol.Optional(CONF_BUMPER_SERVER): cv.string,
vol.Optional(CONF_VERIFY_SSL, default=True): cv.boolean, # can probably get rid of this and set verify ssl false if bumper true
vol.Optional(CONF_VERIFY_SSL, default=True): cv.boolean, # can probably get rid of this and set verify ssl false if
}
)
},
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: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Ecovacs component."""
_LOGGER.debug("Creating new Ecovacs component")

LOGGER.debug("Creating new Ecovacs component")
hass.data[ECOVACS_DEVICES] = []
# if we're using bumper then define the server address
if CONF_BUMPER == True:
server_address = (config[DOMAIN].get(CONF_BUMPER_SERVER), 5223)
# if not make sure it's null
else:
server_address = None
SERVER_ADDRESS = None

ecovacs_api = EcoVacsAPI(
ECOVACS_API_DEVICEID,
Expand All @@ -79,10 +62,10 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
)

devices = ecovacs_api.devices()
_LOGGER.debug("Ecobot devices: %s", devices)
LOGGER.debug("Ecobot devices: %s", devices)

for device in devices:
_LOGGER.info(
LOGGER.info(
"Discovered Ecovacs device on account: %s with nickname %s",
device.get("did"),
device.get("nick"),
Expand All @@ -94,26 +77,24 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
ecovacs_api.user_access_token,
device,
config[DOMAIN].get(CONF_CONTINENT).lower(),
server_address, # include server address in class, if it's null shoul be no effect
config[DOMAIN].get(CONF_VERIFY_SSL), # verify ssl or not
monitor=True,
SERVER_ADDRESS, # include server address in class, if it's null should be no effect
config[DOMAIN].get(CONF_VERIFY_SSL), # add to class call
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(
LOGGER.info(
"Shutting down connection to Ecovacs device %s",
device.vacuum.get("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")
LOGGER.debug("Starting vacuum components")
discovery.load_platform(hass, Platform.VACUUM, DOMAIN, {}, config)

return True
8 changes: 8 additions & 0 deletions custom_components/ecovacs/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import logging
LOGGER = logging.getLogger(__name__)

#ecovacs constants
#init constants
ECOVACS_DEVICES = "ecovacs_devices"
DOMAIN = "ecovacs"
CONF_CONTINENT = "continent"
6 changes: 3 additions & 3 deletions custom_components/ecovacs/manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"domain": "ecovacs",
"name": "Ecovacs Bumper",
"version": "1.3.4",
"version": "1.3.7",
"documentation": "https://github.com/bittles/ha_ecovacs_bumper",
"issue_tracker": "https://github.com/bittles/ha_ecovacs_bumper/issues",
"requirements": ["sleekxmppfs==1.4.1", "click>=6", "requests>=2.18", "pycryptodome>=3.4", "pycountry-convert>=0.5", "paho-mqtt>=1.4", "stringcase>=1.2"],
"requirements": ["sleekxmppfs==1.4.1", "requests>=2.18", "pycryptodome>=3.4", "pycountry-convert>=0.5", "paho-mqtt>=1.4", "stringcase>=1.2"],
"codeowners": ["bittles"],
"iot_class": "local_polling",
"loggers": ["sleekxmppfs", "sucksbumper"]
"loggers": ["sleekxmppfs", "ecovacs"]
}
Loading