core/homeassistant/components/roomba/vacuum.py

28 lines
967 B
Python
Raw Normal View History

"""Support for Wi-Fi enabled iRobot Roombas."""
Add config_flow for Roomba (#33302) * Add config_flow for roomba * Get options to connect * Fix options in config flow * Fix syntax in config_flow * Remove name (not necessary) * Add bin sensor * Add Battery sensor * Add async_connect * Fix typo * Add Model and Software version * Update Roombapy 1.5.0 * Add validate_input * Add connect and disconnect functions * Remove test config flow * Add variables after loop * Fix translate * Fix typo * Fix state of bin * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Remove invalid auth * Add call function reported_state * Add options reload * Fix tracelog * Set entry_id for config_entry * Fix DOMAIN unsed-import * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Add unique_id for entry * Fix device info * Add config_flow for roomba * Get options to connect * Fix options in config flow * Fix syntax in config_flow * Remove name (not necessary) * Add bin sensor * Add Battery sensor * Add async_connect * Fix typo * Add Model and Software version * Update Roombapy 1.5.0 * Add validate_input * Add connect and disconnect functions * Remove test config flow * Add variables after loop * Fix translate * Fix typo * Fix state of bin * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Remove invalid auth * Add call function reported_state * Add options reload * Fix tracelog * Set entry_id for config_entry * Fix DOMAIN unsed-import * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Add unique_id for entry * Fix device info * syntax for mac (pyupgrade) * Change single key to BLID * Resolve dict conflict * Update homeassistant/components/roomba/binary_sensor.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/sensor.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/.translations/en.json Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/strings.json Co-Authored-By: J. Nick Koston <nick@koston.org> * Add description * Revert "Remove test config flow" This reverts commit 26a89422e89d7c88dd3c0ec3066e607afdc99f09. * Add tests * Remove check if user none * Replace CONF_USERNAME to CONF_BLID (breaking change) * Update test_config_flow.py * Add code owners * Remove CONF_USERNAME (unused) * Add multiple vacuum * Add multiple vacuum * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Fix syntax name * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Remove CONF_PREFIX (unused) * Update homeassistant/components/roomba/sensor.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Add import UNIT_PERCENTAGE * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> Co-authored-by: J. Nick Koston <nick@koston.org>
2020-04-11 15:55:00 +00:00
from . import roomba_reported_state
from .braava import BraavaJet
Add config_flow for Roomba (#33302) * Add config_flow for roomba * Get options to connect * Fix options in config flow * Fix syntax in config_flow * Remove name (not necessary) * Add bin sensor * Add Battery sensor * Add async_connect * Fix typo * Add Model and Software version * Update Roombapy 1.5.0 * Add validate_input * Add connect and disconnect functions * Remove test config flow * Add variables after loop * Fix translate * Fix typo * Fix state of bin * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Remove invalid auth * Add call function reported_state * Add options reload * Fix tracelog * Set entry_id for config_entry * Fix DOMAIN unsed-import * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Add unique_id for entry * Fix device info * Add config_flow for roomba * Get options to connect * Fix options in config flow * Fix syntax in config_flow * Remove name (not necessary) * Add bin sensor * Add Battery sensor * Add async_connect * Fix typo * Add Model and Software version * Update Roombapy 1.5.0 * Add validate_input * Add connect and disconnect functions * Remove test config flow * Add variables after loop * Fix translate * Fix typo * Fix state of bin * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Remove invalid auth * Add call function reported_state * Add options reload * Fix tracelog * Set entry_id for config_entry * Fix DOMAIN unsed-import * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Add unique_id for entry * Fix device info * syntax for mac (pyupgrade) * Change single key to BLID * Resolve dict conflict * Update homeassistant/components/roomba/binary_sensor.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/sensor.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/.translations/en.json Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/strings.json Co-Authored-By: J. Nick Koston <nick@koston.org> * Add description * Revert "Remove test config flow" This reverts commit 26a89422e89d7c88dd3c0ec3066e607afdc99f09. * Add tests * Remove check if user none * Replace CONF_USERNAME to CONF_BLID (breaking change) * Update test_config_flow.py * Add code owners * Remove CONF_USERNAME (unused) * Add multiple vacuum * Add multiple vacuum * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Fix syntax name * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Remove CONF_PREFIX (unused) * Update homeassistant/components/roomba/sensor.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Add import UNIT_PERCENTAGE * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> Co-authored-by: J. Nick Koston <nick@koston.org>
2020-04-11 15:55:00 +00:00
from .const import BLID, DOMAIN, ROOMBA_SESSION
from .roomba import RoombaVacuum, RoombaVacuumCarpetBoost
Add config_flow for Roomba (#33302) * Add config_flow for roomba * Get options to connect * Fix options in config flow * Fix syntax in config_flow * Remove name (not necessary) * Add bin sensor * Add Battery sensor * Add async_connect * Fix typo * Add Model and Software version * Update Roombapy 1.5.0 * Add validate_input * Add connect and disconnect functions * Remove test config flow * Add variables after loop * Fix translate * Fix typo * Fix state of bin * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Remove invalid auth * Add call function reported_state * Add options reload * Fix tracelog * Set entry_id for config_entry * Fix DOMAIN unsed-import * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Add unique_id for entry * Fix device info * Add config_flow for roomba * Get options to connect * Fix options in config flow * Fix syntax in config_flow * Remove name (not necessary) * Add bin sensor * Add Battery sensor * Add async_connect * Fix typo * Add Model and Software version * Update Roombapy 1.5.0 * Add validate_input * Add connect and disconnect functions * Remove test config flow * Add variables after loop * Fix translate * Fix typo * Fix state of bin * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Remove invalid auth * Add call function reported_state * Add options reload * Fix tracelog * Set entry_id for config_entry * Fix DOMAIN unsed-import * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/config_flow.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Add unique_id for entry * Fix device info * syntax for mac (pyupgrade) * Change single key to BLID * Resolve dict conflict * Update homeassistant/components/roomba/binary_sensor.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/sensor.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/.translations/en.json Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/strings.json Co-Authored-By: J. Nick Koston <nick@koston.org> * Add description * Revert "Remove test config flow" This reverts commit 26a89422e89d7c88dd3c0ec3066e607afdc99f09. * Add tests * Remove check if user none * Replace CONF_USERNAME to CONF_BLID (breaking change) * Update test_config_flow.py * Add code owners * Remove CONF_USERNAME (unused) * Add multiple vacuum * Add multiple vacuum * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Fix syntax name * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Remove CONF_PREFIX (unused) * Update homeassistant/components/roomba/sensor.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Add import UNIT_PERCENTAGE * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> * Update homeassistant/components/roomba/__init__.py Co-Authored-By: J. Nick Koston <nick@koston.org> Co-authored-by: J. Nick Koston <nick@koston.org>
2020-04-11 15:55:00 +00:00
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the iRobot Roomba vacuum cleaner."""
domain_data = hass.data[DOMAIN][config_entry.entry_id]
roomba = domain_data[ROOMBA_SESSION]
blid = domain_data[BLID]
# Get the capabilities of our unit
state = roomba_reported_state(roomba)
capabilities = state.get("cap", {})
cap_carpet_boost = capabilities.get("carpetBoost")
detected_pad = state.get("detectedPad")
if detected_pad is not None:
constructor = BraavaJet
elif cap_carpet_boost == 1:
constructor = RoombaVacuumCarpetBoost
else:
constructor = RoombaVacuum
roomba_vac = constructor(roomba, blid)
async_add_entities([roomba_vac], True)