Skip to content
Merged
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
10 changes: 5 additions & 5 deletions homeassistant/components/bbb_gpio/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Beaglebone Black GPIO devices."""
pins = config.get(CONF_PINS)
pins = config[CONF_PINS]

binary_sensors = []

Expand All @@ -50,10 +50,10 @@ class BBBGPIOBinarySensor(BinarySensorDevice):
def __init__(self, pin, params):
"""Initialize the Beaglebone Black binary sensor."""
self._pin = pin
self._name = params.get(CONF_NAME) or DEVICE_DEFAULT_NAME
self._bouncetime = params.get(CONF_BOUNCETIME)
self._pull_mode = params.get(CONF_PULL_MODE)
self._invert_logic = params.get(CONF_INVERT_LOGIC)
self._name = params[CONF_NAME] or DEVICE_DEFAULT_NAME
self._bouncetime = params[CONF_BOUNCETIME]
self._pull_mode = params[CONF_PULL_MODE]
self._invert_logic = params[CONF_INVERT_LOGIC]

bbb_gpio.setup_input(self._pin, self._pull_mode)
self._state = bbb_gpio.read_input(self._pin)
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/bbb_gpio/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the BeagleBone Black GPIO devices."""
pins = config.get(CONF_PINS)
pins = config[CONF_PINS]

switches = []
for pin, params in pins.items():
Expand All @@ -44,9 +44,9 @@ class BBBGPIOSwitch(ToggleEntity):
def __init__(self, pin, params):
"""Initialize the pin."""
self._pin = pin
self._name = params.get(CONF_NAME) or DEVICE_DEFAULT_NAME
self._state = params.get(CONF_INITIAL)
self._invert_logic = params.get(CONF_INVERT_LOGIC)
self._name = params[CONF_NAME] or DEVICE_DEFAULT_NAME
self._state = params[CONF_INITIAL]
self._invert_logic = params[CONF_INVERT_LOGIC]

bbb_gpio.setup_output(self._pin)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bbox/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
_LOGGER.error(error)
return False

name = config.get(CONF_NAME)
name = config[CONF_NAME]

sensors = []
for variable in config[CONF_MONITORED_VARIABLES]:
Expand Down
14 changes: 7 additions & 7 deletions homeassistant/components/bh1750/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the BH1750 sensor."""

name = config.get(CONF_NAME)
bus_number = config.get(CONF_I2C_BUS)
i2c_address = config.get(CONF_I2C_ADDRESS)
operation_mode = config.get(CONF_OPERATION_MODE)
name = config[CONF_NAME]
bus_number = config[CONF_I2C_BUS]
i2c_address = config[CONF_I2C_ADDRESS]
operation_mode = config[CONF_OPERATION_MODE]

bus = smbus.SMBus(bus_number)

Expand All @@ -76,16 +76,16 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
bus,
i2c_address,
operation_mode=operation_mode,
measurement_delay=config.get(CONF_DELAY),
sensitivity=config.get(CONF_SENSITIVITY),
measurement_delay=config[CONF_DELAY],
sensitivity=config[CONF_SENSITIVITY],
logger=_LOGGER,
)
)
if not sensor.sample_ok:
_LOGGER.error("BH1750 sensor not detected at %s", i2c_address)
return False

dev = [BH1750Sensor(sensor, name, SENSOR_UNIT, config.get(CONF_MULTIPLIER))]
dev = [BH1750Sensor(sensor, name, SENSOR_UNIT, config[CONF_MULTIPLIER])]
_LOGGER.info(
"Setup of BH1750 light sensor at %s in mode %s is complete",
i2c_address,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bitcoin/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Bitcoin sensors."""

currency = config.get(CONF_CURRENCY)
currency = config[CONF_CURRENCY]

if currency not in exchangerates.get_ticker():
_LOGGER.warning("Currency %s is not available. Using USD", currency)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bizkaibus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Bizkaibus public transport sensor."""
name = config.get(CONF_NAME)
name = config[CONF_NAME]
stop = config[CONF_STOP_ID]
route = config[CONF_ROUTE]

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/blinksticklight/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up Blinkstick device specified by serial number."""

name = config.get(CONF_NAME)
serial = config.get(CONF_SERIAL)
name = config[CONF_NAME]
serial = config[CONF_SERIAL]

stick = blinkstick.find_by_serial(serial)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/blinkt/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
# ensure that the lights are off when exiting
blinkt.set_clear_on_exit()

name = config.get(CONF_NAME)
name = config[CONF_NAME]

add_entities(
[BlinktLight(blinkt, name, index) for index in range(blinkt.NUM_PIXELS)]
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/blockchain/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Blockchain.com sensors."""

addresses = config.get(CONF_ADDRESSES)
name = config.get(CONF_NAME)
addresses = config[CONF_ADDRESSES]
name = config[CONF_NAME]

for address in addresses:
if not validate_address(address):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bloomsky/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the available BloomSky weather binary sensors."""
# Default needed in case of discovery
sensors = config.get(CONF_MONITORED_CONDITIONS, SENSOR_TYPES)
sensors = config[CONF_MONITORED_CONDITIONS]
bloomsky = hass.data[DOMAIN]

for device in bloomsky.devices.values():
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bloomsky/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the available BloomSky weather sensors."""
# Default needed in case of discovery
sensors = config.get(CONF_MONITORED_CONDITIONS, SENSOR_TYPES)
sensors = config[CONF_MONITORED_CONDITIONS]
bloomsky = hass.data[DOMAIN]

for device in bloomsky.devices.values():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def async_setup_scanner(
hass: HomeAssistantType, config: dict, async_see, discovery_info=None
):
"""Set up the Bluetooth Scanner."""
device_id: int = config.get(CONF_DEVICE_ID)
device_id: int = config[CONF_DEVICE_ID]
interval = config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL)
request_rssi = config.get(CONF_REQUEST_RSSI, False)
update_bluetooth_lock = asyncio.Lock()
Expand Down
20 changes: 10 additions & 10 deletions homeassistant/components/bme280/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
"""Set up the BME280 sensor."""

SENSOR_TYPES[SENSOR_TEMP][1] = hass.config.units.temperature_unit
name = config.get(CONF_NAME)
i2c_address = config.get(CONF_I2C_ADDRESS)
name = config[CONF_NAME]
i2c_address = config[CONF_I2C_ADDRESS]

bus = smbus.SMBus(config.get(CONF_I2C_BUS))
bus = smbus.SMBus(config[CONF_I2C_BUS])
sensor = await hass.async_add_job(
partial(
BME280,
bus,
i2c_address,
osrs_t=config.get(CONF_OVERSAMPLING_TEMP),
osrs_p=config.get(CONF_OVERSAMPLING_PRES),
osrs_h=config.get(CONF_OVERSAMPLING_HUM),
mode=config.get(CONF_OPERATION_MODE),
t_sb=config.get(CONF_T_STANDBY),
filter_mode=config.get(CONF_FILTER_MODE),
delta_temp=config.get(CONF_DELTA_TEMP),
osrs_t=config[CONF_OVERSAMPLING_TEMP],
osrs_p=config[CONF_OVERSAMPLING_PRES],
osrs_h=config[CONF_OVERSAMPLING_HUM],
mode=config[CONF_OPERATION_MODE],
t_sb=config[CONF_T_STANDBY],
filter_mode=config[CONF_FILTER_MODE],
delta_temp=config[CONF_DELTA_TEMP],
logger=_LOGGER,
)
)
Expand Down
16 changes: 8 additions & 8 deletions homeassistant/components/bme680/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the BME680 sensor."""
SENSOR_TYPES[SENSOR_TEMP][1] = hass.config.units.temperature_unit
name = config.get(CONF_NAME)
name = config[CONF_NAME]

sensor_handler = await hass.async_add_job(_setup_bme680, config)
if sensor_handler is None:
Expand All @@ -132,8 +132,8 @@ def _setup_bme680(config):
sensor = None
try:
# pylint: disable=no-member
i2c_address = config.get(CONF_I2C_ADDRESS)
bus = SMBus(config.get(CONF_I2C_BUS))
i2c_address = config[CONF_I2C_ADDRESS]
bus = SMBus(config[CONF_I2C_BUS])
sensor = bme680.BME680(i2c_address, bus)

# Configure Oversampling
Expand All @@ -145,10 +145,10 @@ def _setup_bme680(config):
8: bme680.OS_8X,
16: bme680.OS_16X,
}
sensor.set_temperature_oversample(os_lookup[config.get(CONF_OVERSAMPLING_TEMP)])
sensor.set_temp_offset(config.get(CONF_TEMP_OFFSET))
sensor.set_humidity_oversample(os_lookup[config.get(CONF_OVERSAMPLING_HUM)])
sensor.set_pressure_oversample(os_lookup[config.get(CONF_OVERSAMPLING_PRES)])
sensor.set_temperature_oversample(os_lookup[config[CONF_OVERSAMPLING_TEMP]])
sensor.set_temp_offset(config[CONF_TEMP_OFFSET])
sensor.set_humidity_oversample(os_lookup[config[CONF_OVERSAMPLING_HUM]])
sensor.set_pressure_oversample(os_lookup[config[CONF_OVERSAMPLING_PRES]])

# Configure IIR Filter
filter_lookup = {
Expand All @@ -161,7 +161,7 @@ def _setup_bme680(config):
63: bme680.FILTER_SIZE_63,
127: bme680.FILTER_SIZE_127,
}
sensor.set_filter(filter_lookup[config.get(CONF_FILTER_SIZE)])
sensor.set_filter(filter_lookup[config[CONF_FILTER_SIZE]])

# Configure the Gas Heater
if (
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/braviatv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Sony Bravia TV platform."""
host = config.get(CONF_HOST)
host = config[CONF_HOST]

if host is None:
return
Expand All @@ -74,7 +74,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
if host_ip == host:
pin = host_config["pin"]
mac = host_config["mac"]
name = config.get(CONF_NAME)
name = config[CONF_NAME]
braviarc = BraviaRC(host, mac)
if not braviarc.connect(pin, CLIENTID_PREFIX, NICKNAME):
raise PlatformNotReady
Expand All @@ -91,8 +91,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):

def setup_bravia(config, pin, hass, add_entities):
"""Set up a Sony Bravia TV based on host parameter."""
host = config.get(CONF_HOST)
name = config.get(CONF_NAME)
host = config[CONF_HOST]
name = config[CONF_NAME]

if pin is None:
request_configuration(config, hass, add_entities)
Expand Down Expand Up @@ -128,8 +128,8 @@ def setup_bravia(config, pin, hass, add_entities):

def request_configuration(config, hass, add_entities):
"""Request configuration steps from the user."""
host = config.get(CONF_HOST)
name = config.get(CONF_NAME)
host = config[CONF_HOST]
name = config[CONF_NAME]

configurator = hass.components.configurator

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/brottsplatskartan/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
area = config.get(CONF_AREA)
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
name = config.get(CONF_NAME)
name = config[CONF_NAME]

# Every Home Assistant instance should have their own unique
# app parameter: https://brottsplatskartan.se/sida/api
Expand Down