Skip to content
Merged

2021.9.4 #55870

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
6 changes: 3 additions & 3 deletions homeassistant/components/incomfort/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ def current_temperature(self) -> float:

@property
def min_temp(self) -> float:
"""Return max valid temperature that can be set."""
return 80.0
"""Return min valid temperature that can be set."""
return 30.0

@property
def max_temp(self) -> float:
"""Return max valid temperature that can be set."""
return 30.0
return 80.0

@property
def temperature_unit(self) -> str:
Expand Down
22 changes: 8 additions & 14 deletions homeassistant/components/integration/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,10 @@ def __init__(
self._method = integration_method

self._name = name if name is not None else f"{source_entity} integral"

if unit_of_measurement is None:
self._unit_template = (
f"{'' if unit_prefix is None else unit_prefix}{{}}{unit_time}"
)
# we postpone the definition of unit_of_measurement to later
self._unit_of_measurement = None
else:
self._unit_of_measurement = unit_of_measurement

self._unit_template = (
f"{'' if unit_prefix is None else unit_prefix}{{}}{unit_time}"
)
self._unit_of_measurement = unit_of_measurement
self._unit_prefix = UNIT_PREFIXES[unit_prefix]
self._unit_time = UNIT_TIME[unit_time]
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
Expand All @@ -135,10 +129,10 @@ async def async_added_to_hass(self):
_LOGGER.warning("Could not restore last state: %s", err)
else:
self._attr_device_class = state.attributes.get(ATTR_DEVICE_CLASS)

self._unit_of_measurement = state.attributes.get(
ATTR_UNIT_OF_MEASUREMENT
)
if self._unit_of_measurement is None:
self._unit_of_measurement = state.attributes.get(
ATTR_UNIT_OF_MEASUREMENT
)

@callback
def calc_integration(event):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/logbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from homeassistant.loader import bind_hass
import homeassistant.util.dt as dt_util

ENTITY_ID_JSON_TEMPLATE = '"entity_id": ?"{}"'
ENTITY_ID_JSON_TEMPLATE = '"entity_id":"{}"'
ENTITY_ID_JSON_EXTRACT = re.compile('"entity_id": ?"([^"]+)"')
DOMAIN_JSON_EXTRACT = re.compile('"domain": ?"([^"]+)"')
ICON_JSON_EXTRACT = re.compile('"icon": ?"([^"]+)"')
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mazda/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Mazda Connected Services",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/mazda",
"requirements": ["pymazda==0.2.0"],
"requirements": ["pymazda==0.2.1"],
"codeowners": ["@bdr99"],
"quality_scale": "platinum",
"iot_class": "cloud_polling"
Expand Down
11 changes: 10 additions & 1 deletion homeassistant/components/modbus/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@

from .const import (
CONF_DATA_TYPE,
CONF_INPUT_TYPE,
CONF_SWAP,
CONF_SWAP_BYTE,
CONF_SWAP_NONE,
CONF_WRITE_TYPE,
DATA_TYPE_CUSTOM,
DATA_TYPE_FLOAT,
DATA_TYPE_FLOAT16,
Expand Down Expand Up @@ -212,6 +214,10 @@ def duplicate_entity_validator(config: dict) -> dict:
for index, entry in enumerate(hub[conf_key]):
name = entry[CONF_NAME]
addr = str(entry[CONF_ADDRESS])
if CONF_INPUT_TYPE in entry:
addr += "_" + str(entry[CONF_INPUT_TYPE])
elif CONF_WRITE_TYPE in entry:
addr += "_" + str(entry[CONF_WRITE_TYPE])
if CONF_COMMAND_ON in entry:
addr += "_" + str(entry[CONF_COMMAND_ON])
if CONF_COMMAND_OFF in entry:
Expand Down Expand Up @@ -242,7 +248,10 @@ def duplicate_modbus_validator(config: list) -> list:
errors = []
for index, hub in enumerate(config):
name = hub.get(CONF_NAME, DEFAULT_HUB)
host = hub[CONF_PORT] if hub[CONF_TYPE] == SERIAL else hub[CONF_HOST]
if hub[CONF_TYPE] == SERIAL:
host = hub[CONF_PORT]
else:
host = f"{hub[CONF_HOST]}_{hub[CONF_PORT]}"
if host in hosts:
err = f"Modbus {name}  contains duplicate host/port {host}, not loaded!"
_LOGGER.warning(err)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/rfxtrx/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class RfxtrxSensorEntityDescription(SensorEntityDescription):

SENSOR_TYPES = (
RfxtrxSensorEntityDescription(
key="Barameter",
key="Barometer",
device_class=DEVICE_CLASS_PRESSURE,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=PRESSURE_HPA,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/surepetcare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async def async_update(self, _: Any = None) -> None:
"""Get the latest data from Sure Petcare."""

try:
self.states = await self.surepy.get_entities()
self.states = await self.surepy.get_entities(refresh=True)
except SurePetcareError as error:
_LOGGER.error("Unable to fetch data: %s", error)
return
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/thinkingcleaner/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, tc_object, update_devices, description: SwitchEntityDescripti
self.last_lock_time = None
self.graceful_state = False

self._attr_name = f"{tc_object} {description.name}"
self._attr_name = f"{tc_object.name} {description.name}"

def lock_update(self):
"""Lock the update since TC clean takes some time to update."""
Expand Down
7 changes: 7 additions & 0 deletions homeassistant/components/xiaomi_miio/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
MODEL_AIRQUALITYMONITOR_S1 = "cgllc.airmonitor.s1"
MODEL_AIRQUALITYMONITOR_CGDN1 = "cgllc.airm.cgdn1"

MODELS_AIR_QUALITY_MONITOR = [
MODEL_AIRQUALITYMONITOR_V1,
MODEL_AIRQUALITYMONITOR_B1,
MODEL_AIRQUALITYMONITOR_S1,
MODEL_AIRQUALITYMONITOR_CGDN1,
]

# Light Models
MODELS_LIGHT_EYECARE = ["philips.light.sread1"]
MODELS_LIGHT_CEILING = ["philips.light.ceiling", "philips.light.zyceiling"]
Expand Down
27 changes: 13 additions & 14 deletions homeassistant/components/xiaomi_miio/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,36 +405,42 @@ def __init__(self, name, device, entry, unique_id, coordinator):
self._preset_modes = PRESET_MODES_AIRPURIFIER_PRO
self._supported_features = SUPPORT_PRESET_MODE
self._speed_count = 1
self._operation_mode_class = AirpurifierOperationMode
elif self._model == MODEL_AIRPURIFIER_PRO_V7:
self._device_features = FEATURE_FLAGS_AIRPURIFIER_PRO_V7
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_PRO_V7
self._preset_modes = PRESET_MODES_AIRPURIFIER_PRO_V7
self._supported_features = SUPPORT_PRESET_MODE
self._speed_count = 1
self._operation_mode_class = AirpurifierOperationMode
elif self._model in [MODEL_AIRPURIFIER_2S, MODEL_AIRPURIFIER_2H]:
self._device_features = FEATURE_FLAGS_AIRPURIFIER_2S
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_COMMON
self._preset_modes = PRESET_MODES_AIRPURIFIER_2S
self._supported_features = SUPPORT_PRESET_MODE
self._speed_count = 1
self._operation_mode_class = AirpurifierOperationMode
elif self._model in MODELS_PURIFIER_MIOT:
self._device_features = FEATURE_FLAGS_AIRPURIFIER_MIOT
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_MIOT
self._preset_modes = PRESET_MODES_AIRPURIFIER_MIOT
self._supported_features = SUPPORT_SET_SPEED | SUPPORT_PRESET_MODE
self._speed_count = 3
self._operation_mode_class = AirpurifierMiotOperationMode
elif self._model == MODEL_AIRPURIFIER_V3:
self._device_features = FEATURE_FLAGS_AIRPURIFIER_V3
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER_V3
self._preset_modes = PRESET_MODES_AIRPURIFIER_V3
self._supported_features = SUPPORT_PRESET_MODE
self._speed_count = 1
self._operation_mode_class = AirpurifierOperationMode
else:
self._device_features = FEATURE_FLAGS_AIRPURIFIER_MIIO
self._available_attributes = AVAILABLE_ATTRIBUTES_AIRPURIFIER
self._preset_modes = PRESET_MODES_AIRPURIFIER
self._supported_features = SUPPORT_PRESET_MODE
self._speed_count = 1
self._operation_mode_class = AirpurifierOperationMode

self._state_attrs.update(
{attribute: None for attribute in self._available_attributes}
Expand All @@ -446,7 +452,7 @@ def __init__(self, name, device, entry, unique_id, coordinator):
def preset_mode(self):
"""Get the active preset mode."""
if self._state:
preset_mode = AirpurifierOperationMode(self._state_attrs[ATTR_MODE]).name
preset_mode = self._operation_mode_class(self._mode).name
return preset_mode if preset_mode in self._preset_modes else None

return None
Expand All @@ -455,7 +461,7 @@ def preset_mode(self):
def percentage(self):
"""Return the current percentage based speed."""
if self._state:
mode = AirpurifierOperationMode(self._state_attrs[ATTR_MODE])
mode = self._operation_mode_class(self._state_attrs[ATTR_MODE])
if mode in self.REVERSE_SPEED_MODE_MAPPING:
return ranged_value_to_percentage(
(1, self._speed_count), self.REVERSE_SPEED_MODE_MAPPING[mode]
Expand All @@ -479,7 +485,7 @@ async def async_set_percentage(self, percentage: int) -> None:
await self._try_command(
"Setting operation mode of the miio device failed.",
self._device.set_mode,
AirpurifierOperationMode(self.SPEED_MODE_MAPPING[speed_mode]),
self._operation_mode_class(self.SPEED_MODE_MAPPING[speed_mode]),
)

async def async_set_preset_mode(self, preset_mode: str) -> None:
Expand All @@ -490,11 +496,13 @@ async def async_set_preset_mode(self, preset_mode: str) -> None:
if preset_mode not in self.preset_modes:
_LOGGER.warning("'%s'is not a valid preset mode", preset_mode)
return
await self._try_command(
if await self._try_command(
"Setting operation mode of the miio device failed.",
self._device.set_mode,
self.PRESET_MODE_MAPPING[preset_mode],
)
):
self._mode = self._operation_mode_class[preset_mode].value
self.async_write_ha_state()

async def async_set_extra_features(self, features: int = 1):
"""Set the extra features."""
Expand Down Expand Up @@ -538,15 +546,6 @@ def percentage(self):

return None

@property
def preset_mode(self):
"""Get the active preset mode."""
if self._state:
preset_mode = AirpurifierMiotOperationMode(self._mode).name
return preset_mode if preset_mode in self._preset_modes else None

return None

async def async_set_percentage(self, percentage: int) -> None:
"""Set the percentage of the fan.

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/xiaomi_miio/humidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def __init__(self, name, device, entry, unique_id, coordinator):
self._available_modes = AVAILABLE_MODES_MJJSQ
self._min_humidity = 30
self._max_humidity = 80
self._humidity_steps = 10
self._humidity_steps = 100
else:
self._available_modes = AVAILABLE_MODES_OTHER
self._min_humidity = 30
Expand Down
59 changes: 32 additions & 27 deletions homeassistant/components/xiaomi_miio/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
MODEL_FAN_ZA1,
MODEL_FAN_ZA3,
MODEL_FAN_ZA4,
MODELS_AIR_QUALITY_MONITOR,
MODELS_HUMIDIFIER_MIIO,
MODELS_HUMIDIFIER_MIOT,
MODELS_HUMIDIFIER_MJJSQ,
Expand Down Expand Up @@ -371,23 +372,11 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
host = config_entry.data[CONF_HOST]
token = config_entry.data[CONF_TOKEN]
model = config_entry.data[CONF_MODEL]
device = hass.data[DOMAIN][config_entry.entry_id].get(KEY_DEVICE)
sensors = []

if model in (MODEL_FAN_ZA1, MODEL_FAN_ZA3, MODEL_FAN_ZA4, MODEL_FAN_P5):
return
if model in MODEL_TO_SENSORS_MAP:
sensors = MODEL_TO_SENSORS_MAP[model]
elif model in MODELS_HUMIDIFIER_MIOT:
sensors = HUMIDIFIER_MIOT_SENSORS
elif model in MODELS_HUMIDIFIER_MJJSQ:
sensors = HUMIDIFIER_MJJSQ_SENSORS
elif model in MODELS_HUMIDIFIER_MIIO:
sensors = HUMIDIFIER_MIIO_SENSORS
elif model in MODELS_PURIFIER_MIIO:
sensors = PURIFIER_MIIO_SENSORS
elif model in MODELS_PURIFIER_MIOT:
sensors = PURIFIER_MIOT_SENSORS
else:

if model in MODELS_AIR_QUALITY_MONITOR:
unique_id = config_entry.unique_id
name = config_entry.title
_LOGGER.debug("Initializing with host %s (token %s...)", host, token[:5])
Expand All @@ -399,19 +388,35 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
name, device, config_entry, unique_id, description
)
)
for sensor, description in SENSOR_TYPES.items():
if sensor not in sensors:
continue
entities.append(
XiaomiGenericSensor(
f"{config_entry.title} {description.name}",
device,
config_entry,
f"{sensor}_{config_entry.unique_id}",
hass.data[DOMAIN][config_entry.entry_id][KEY_COORDINATOR],
description,
else:
device = hass.data[DOMAIN][config_entry.entry_id][KEY_DEVICE]
sensors = []
if model in MODEL_TO_SENSORS_MAP:
sensors = MODEL_TO_SENSORS_MAP[model]
elif model in MODELS_HUMIDIFIER_MIOT:
sensors = HUMIDIFIER_MIOT_SENSORS
elif model in MODELS_HUMIDIFIER_MJJSQ:
sensors = HUMIDIFIER_MJJSQ_SENSORS
elif model in MODELS_HUMIDIFIER_MIIO:
sensors = HUMIDIFIER_MIIO_SENSORS
elif model in MODELS_PURIFIER_MIIO:
sensors = PURIFIER_MIIO_SENSORS
elif model in MODELS_PURIFIER_MIOT:
sensors = PURIFIER_MIOT_SENSORS

for sensor, description in SENSOR_TYPES.items():
if sensor not in sensors:
continue
entities.append(
XiaomiGenericSensor(
f"{config_entry.title} {description.name}",
device,
config_entry,
f"{sensor}_{config_entry.unique_id}",
hass.data[DOMAIN][config_entry.entry_id][KEY_COORDINATOR],
description,
)
)
)

async_add_entities(entities)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/zha/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def async_step_usb(self, discovery_info: DiscoveryInfoType):
self._abort_if_unique_id_configured(
updates={
CONF_DEVICE: {
**current_entry.data[CONF_DEVICE],
**current_entry.data.get(CONF_DEVICE, {}),
CONF_DEVICE_PATH: dev_path,
},
}
Expand Down Expand Up @@ -172,7 +172,7 @@ async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType):
self._abort_if_unique_id_configured(
updates={
CONF_DEVICE: {
**current_entry.data[CONF_DEVICE],
**current_entry.data.get(CONF_DEVICE, {}),
CONF_DEVICE_PATH: device_path,
},
}
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zwave_js/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Any

from zwave_js_server.client import Client as ZwaveClient
from zwave_js_server.const.command_class.barrior_operator import BarrierState
from zwave_js_server.const.command_class.barrier_operator import BarrierState
from zwave_js_server.model.value import Value as ZwaveValue

from homeassistant.components.cover import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
)
from zwave_js_server.model.node import Node as ZwaveNode
from zwave_js_server.model.value import Value as ZwaveValue, get_value_id
from zwave_js_server.util.command_class import (
get_meter_scale_type,
from zwave_js_server.util.command_class.meter import get_meter_scale_type
from zwave_js_server.util.command_class.multilevel_sensor import (
get_multilevel_sensor_type,
)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zwave_js/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Z-Wave JS",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/zwave_js",
"requirements": ["zwave-js-server-python==0.29.1"],
"requirements": ["zwave-js-server-python==0.30.0"],
"codeowners": ["@home-assistant/z-wave"],
"dependencies": ["usb", "http", "websocket_api"],
"iot_class": "local_push",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zwave_js/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from zwave_js_server.model.node import Node as ZwaveNode
from zwave_js_server.model.value import ConfigurationValue
from zwave_js_server.util.command_class import get_meter_type
from zwave_js_server.util.command_class.meter import get_meter_type

from homeassistant.components.sensor import (
DEVICE_CLASS_ENERGY,
Expand Down
Loading