Skip to content

Commit

Permalink
Merge pull request #47835 from home-assistant/rc
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Mar 12, 2021
2 parents a8844ff + a024343 commit 6ed0146
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 16 deletions.
2 changes: 2 additions & 0 deletions homeassistant/components/homekit/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ reload:
reset_accessory:
description: Reset a HomeKit accessory
target:
entity: {}

2 changes: 1 addition & 1 deletion homeassistant/components/insteon/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .insteon_entity import InsteonEntity
from .utils import async_add_insteon_entities

SPEED_RANGE = (0x00, 0xFF) # off is not included
SPEED_RANGE = (1, 255) # off is not included


async def async_setup_entry(hass, config_entry, async_add_entities):
Expand Down
15 changes: 13 additions & 2 deletions homeassistant/components/mqtt/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,26 @@ def tilt_message_received(msg):
payload
)

if payload.isnumeric() and (
if not payload.isnumeric():
_LOGGER.warning("Payload '%s' is not numeric", payload)
elif (
self._config[CONF_TILT_MIN]
<= int(payload)
<= self._config[CONF_TILT_MAX]
or self._config[CONF_TILT_MAX]
<= int(payload)
<= self._config[CONF_TILT_MIN]
):

level = self.find_percentage_in_range(float(payload))
self._tilt_value = level
self.async_write_ha_state()
else:
_LOGGER.warning(
"Payload '%s' is out of range, must be between '%s' and '%s' inclusive",
payload,
self._config[CONF_TILT_MIN],
self._config[CONF_TILT_MAX],
)

@callback
@log_messages(self.hass, self.entity_id)
Expand Down
18 changes: 10 additions & 8 deletions homeassistant/components/netatmo/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,18 @@ async def async_send_event(hass, event_type, data):
{"type": event_type, "data": data},
)

if event_type not in EVENT_ID_MAP:
return
event_data = {
"type": event_type,
"data": data,
}

data_device_id = data[EVENT_ID_MAP[event_type]]
if event_type in EVENT_ID_MAP:
data_device_id = data[EVENT_ID_MAP[event_type]]
event_data[ATTR_DEVICE_ID] = hass.data[DOMAIN][DATA_DEVICE_IDS].get(
data_device_id
)

hass.bus.async_fire(
event_type=NETATMO_EVENT,
event_data={
"type": event_type,
"data": data,
ATTR_DEVICE_ID: hass.data[DOMAIN][DATA_DEVICE_IDS].get(data_device_id),
},
event_data=event_data,
)
2 changes: 1 addition & 1 deletion homeassistant/components/plex/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/plex",
"requirements": [
"plexapi==4.4.0",
"plexapi==4.4.1",
"plexauth==0.0.6",
"plexwebsocket==0.0.12"
],
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/simplisafe/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ async def async_alarm_disarm(self, code=None):
return

self._state = STATE_ALARM_DISARMED
self.async_write_ha_state()

async def async_alarm_arm_home(self, code=None):
"""Send arm home command."""
Expand All @@ -178,6 +179,7 @@ async def async_alarm_arm_home(self, code=None):
return

self._state = STATE_ALARM_ARMED_HOME
self.async_write_ha_state()

async def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
Expand All @@ -193,6 +195,7 @@ async def async_alarm_arm_away(self, code=None):
return

self._state = STATE_ALARM_ARMING
self.async_write_ha_state()

@callback
def async_update_from_rest_api(self):
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/simplisafe/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ async def async_lock(self, **kwargs):
LOGGER.error('Error while locking "%s": %s', self._lock.name, err)
return

self._is_locked = True
self.async_write_ha_state()

async def async_unlock(self, **kwargs):
"""Unlock the lock."""
try:
Expand All @@ -63,6 +66,9 @@ async def async_unlock(self, **kwargs):
LOGGER.error('Error while unlocking "%s": %s', self._lock.name, err)
return

self._is_locked = False
self.async_write_ha_state()

@callback
def async_update_from_rest_api(self):
"""Update the entity with the provided REST API data."""
Expand Down
7 changes: 6 additions & 1 deletion homeassistant/components/zwave_js/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,12 @@ def target_temperature_high(self) -> Optional[float]:
@property
def target_temperature_low(self) -> Optional[float]:
"""Return the lowbound target temperature we try to reach."""
return self.target_temperature
if self._current_mode and self._current_mode.value is None:
# guard missing value
return None
if len(self._current_mode_setpoint_enums) > 1:
return self.target_temperature
return None

@property
def preset_mode(self) -> Optional[str]:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Constants used by Home Assistant components."""
MAJOR_VERSION = 2021
MINOR_VERSION = 3
PATCH_VERSION = "3"
PATCH_VERSION = "4"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER = (3, 8, 0)
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ pillow==8.1.1
pizzapi==0.0.3

# homeassistant.components.plex
plexapi==4.4.0
plexapi==4.4.1

# homeassistant.components.plex
plexauth==0.0.6
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ pilight==0.1.1
pillow==8.1.1

# homeassistant.components.plex
plexapi==4.4.0
plexapi==4.4.1

# homeassistant.components.plex
plexauth==0.0.6
Expand Down
106 changes: 106 additions & 0 deletions tests/components/mqtt/test_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,112 @@ async def test_tilt_via_topic_altered_range(hass, mqtt_mock):
assert current_cover_tilt_position == 50


async def test_tilt_status_out_of_range_warning(hass, caplog, mqtt_mock):
"""Test tilt status via MQTT tilt out of range warning message."""
assert await async_setup_component(
hass,
cover.DOMAIN,
{
cover.DOMAIN: {
"platform": "mqtt",
"name": "test",
"state_topic": "state-topic",
"command_topic": "command-topic",
"qos": 0,
"payload_open": "OPEN",
"payload_close": "CLOSE",
"payload_stop": "STOP",
"tilt_command_topic": "tilt-command-topic",
"tilt_status_topic": "tilt-status-topic",
"tilt_min": 0,
"tilt_max": 50,
}
},
)
await hass.async_block_till_done()

async_fire_mqtt_message(hass, "tilt-status-topic", "60")

assert (
"Payload '60' is out of range, must be between '0' and '50' inclusive"
) in caplog.text


async def test_tilt_status_not_numeric_warning(hass, caplog, mqtt_mock):
"""Test tilt status via MQTT tilt not numeric warning message."""
assert await async_setup_component(
hass,
cover.DOMAIN,
{
cover.DOMAIN: {
"platform": "mqtt",
"name": "test",
"state_topic": "state-topic",
"command_topic": "command-topic",
"qos": 0,
"payload_open": "OPEN",
"payload_close": "CLOSE",
"payload_stop": "STOP",
"tilt_command_topic": "tilt-command-topic",
"tilt_status_topic": "tilt-status-topic",
"tilt_min": 0,
"tilt_max": 50,
}
},
)
await hass.async_block_till_done()

async_fire_mqtt_message(hass, "tilt-status-topic", "abc")

assert ("Payload 'abc' is not numeric") in caplog.text


async def test_tilt_via_topic_altered_range_inverted(hass, mqtt_mock):
"""Test tilt status via MQTT with altered tilt range and inverted tilt position."""
assert await async_setup_component(
hass,
cover.DOMAIN,
{
cover.DOMAIN: {
"platform": "mqtt",
"name": "test",
"state_topic": "state-topic",
"command_topic": "command-topic",
"qos": 0,
"payload_open": "OPEN",
"payload_close": "CLOSE",
"payload_stop": "STOP",
"tilt_command_topic": "tilt-command-topic",
"tilt_status_topic": "tilt-status-topic",
"tilt_min": 50,
"tilt_max": 0,
}
},
)
await hass.async_block_till_done()

async_fire_mqtt_message(hass, "tilt-status-topic", "0")

current_cover_tilt_position = hass.states.get("cover.test").attributes[
ATTR_CURRENT_TILT_POSITION
]
assert current_cover_tilt_position == 100

async_fire_mqtt_message(hass, "tilt-status-topic", "50")

current_cover_tilt_position = hass.states.get("cover.test").attributes[
ATTR_CURRENT_TILT_POSITION
]
assert current_cover_tilt_position == 0

async_fire_mqtt_message(hass, "tilt-status-topic", "25")

current_cover_tilt_position = hass.states.get("cover.test").attributes[
ATTR_CURRENT_TILT_POSITION
]
assert current_cover_tilt_position == 50


async def test_tilt_via_topic_template_altered_range(hass, mqtt_mock):
"""Test tilt status via MQTT and template with altered tilt range."""
assert await async_setup_component(
Expand Down

0 comments on commit 6ed0146

Please sign in to comment.