Skip to content

Commit

Permalink
Merge pull request #40 from home-assistant/master
Browse files Browse the repository at this point in the history
2021.5.5
  • Loading branch information
rafale77 authored May 19, 2021
2 parents b810c9e + ae56154 commit c85d599
Show file tree
Hide file tree
Showing 14 changed files with 283 additions and 221 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/free_mobile/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "free_mobile",
"name": "Free Mobile",
"documentation": "https://www.home-assistant.io/integrations/free_mobile",
"requirements": ["freesms==0.1.2"],
"requirements": ["freesms==0.2.0"],
"codeowners": [],
"iot_class": "cloud_push"
}
4 changes: 1 addition & 3 deletions homeassistant/components/netatmo/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,7 @@ def _service_set_schedule(self, **kwargs):
schedule_id = sid

if not schedule_id:
_LOGGER.error(
"%s is not a invalid schedule", kwargs.get(ATTR_SCHEDULE_NAME)
)
_LOGGER.error("%s is not a valid schedule", kwargs.get(ATTR_SCHEDULE_NAME))
return

self._data.switch_home_schedule(home_id=self._home_id, schedule_id=schedule_id)
Expand Down
26 changes: 20 additions & 6 deletions homeassistant/components/netatmo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@
"domain": "netatmo",
"name": "Netatmo",
"documentation": "https://www.home-assistant.io/integrations/netatmo",
"requirements": ["pyatmo==4.2.2"],
"after_dependencies": ["cloud", "media_source"],
"dependencies": ["webhook"],
"codeowners": ["@cgtobi"],
"requirements": [
"pyatmo==4.2.3"
],
"after_dependencies": [
"cloud",
"media_source"
],
"dependencies": [
"webhook"
],
"codeowners": [
"@cgtobi"
],
"config_flow": true,
"homekit": {
"models": ["Healty Home Coach", "Netatmo Relay", "Presence", "Welcome"]
"models": [
"Healty Home Coach",
"Netatmo Relay",
"Presence",
"Welcome"
]
},
"iot_class": "cloud_polling"
}
}
2 changes: 1 addition & 1 deletion homeassistant/components/sonos/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Sonos",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/sonos",
"requirements": ["pysonos==0.0.45"],
"requirements": ["pysonos==0.0.47"],
"after_dependencies": ["plex"],
"ssdp": [
{
Expand Down
13 changes: 11 additions & 2 deletions homeassistant/components/sonos/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ async def _subscribe(
self, target: SubscriptionBase, sub_callback: Callable
) -> None:
"""Create a Sonos subscription."""
subscription = await target.subscribe(auto_renew=True)
subscription = await target.subscribe(auto_renew=True, requested_timeout=1200)
subscription.callback = sub_callback
subscription.auto_renew_fail = self.async_renew_failed
self._subscriptions.append(subscription)

@callback
Expand Down Expand Up @@ -241,11 +242,19 @@ async def async_seen(self, soco: SoCo | None = None) -> None:

self.async_write_entity_states()

@callback
def async_renew_failed(self, exception: Exception) -> None:
"""Handle a failed subscription renewal."""
if self.available:
self.hass.async_add_job(self.async_unseen)

async def async_unseen(self, now: datetime.datetime | None = None) -> None:
"""Make this player unavailable when it was not seen recently."""
self.async_write_entity_states()

self._seen_timer = None
if self._seen_timer:
self._seen_timer()
self._seen_timer = None

if self._poll_timer:
self._poll_timer()
Expand Down
62 changes: 34 additions & 28 deletions homeassistant/components/tasmota/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def async_discover(tasmota_entity, discovery_hash):
)


def clamp(value):
"""Clamp value to the range 0..255."""
return min(max(value, 0), 255)


class TasmotaLight(
TasmotaAvailability,
TasmotaDiscoveryUpdate,
Expand Down Expand Up @@ -136,22 +141,7 @@ def state_updated(self, state, **kwargs):
percent_bright = brightness / TASMOTA_BRIGHTNESS_MAX
self._brightness = percent_bright * 255
if "color" in attributes:

def clamp(value):
"""Clamp value to the range 0..255."""
return min(max(value, 0), 255)

rgb = attributes["color"]
# Tasmota's RGB color is adjusted for brightness, compensate
if self._brightness > 0:
red_compensated = clamp(round(rgb[0] / self._brightness * 255))
green_compensated = clamp(round(rgb[1] / self._brightness * 255))
blue_compensated = clamp(round(rgb[2] / self._brightness * 255))
else:
red_compensated = 0
green_compensated = 0
blue_compensated = 0
self._rgb = [red_compensated, green_compensated, blue_compensated]
self._rgb = attributes["color"][0:3]
if "color_temp" in attributes:
self._color_temp = attributes["color_temp"]
if "effect" in attributes:
Expand Down Expand Up @@ -207,14 +197,38 @@ def effect_list(self):
@property
def rgb_color(self):
"""Return the rgb color value."""
return self._rgb
if self._rgb is None:
return None
rgb = self._rgb
# Tasmota's RGB color is adjusted for brightness, compensate
if self._brightness > 0:
red_compensated = clamp(round(rgb[0] / self._brightness * 255))
green_compensated = clamp(round(rgb[1] / self._brightness * 255))
blue_compensated = clamp(round(rgb[2] / self._brightness * 255))
else:
red_compensated = 0
green_compensated = 0
blue_compensated = 0
return [red_compensated, green_compensated, blue_compensated]

@property
def rgbw_color(self):
"""Return the rgbw color value."""
if self._rgb is None or self._white_value is None:
return None
return [*self._rgb, self._white_value]
rgb = self._rgb
# Tasmota's color is adjusted for brightness, compensate
if self._brightness > 0:
red_compensated = clamp(round(rgb[0] / self._brightness * 255))
green_compensated = clamp(round(rgb[1] / self._brightness * 255))
blue_compensated = clamp(round(rgb[2] / self._brightness * 255))
white_compensated = clamp(round(self._white_value / self._brightness * 255))
else:
red_compensated = 0
green_compensated = 0
blue_compensated = 0
white_compensated = 0
return [red_compensated, green_compensated, blue_compensated, white_compensated]

@property
def force_update(self):
Expand Down Expand Up @@ -250,18 +264,10 @@ async def async_turn_on(self, **kwargs):

if ATTR_RGBW_COLOR in kwargs and COLOR_MODE_RGBW in supported_color_modes:
rgbw = kwargs[ATTR_RGBW_COLOR]
attributes["color"] = [rgbw[0], rgbw[1], rgbw[2], rgbw[3]]
# Tasmota does not support direct RGBW control, the light must be set to
# either white mode or color mode. Set the mode to white if white channel
# is on, and to color otheruse
if rgbw[3] == 0:
attributes["color"] = [rgbw[0], rgbw[1], rgbw[2]]
else:
white_value_normalized = rgbw[3] / DEFAULT_BRIGHTNESS_MAX
device_white_value = min(
round(white_value_normalized * TASMOTA_BRIGHTNESS_MAX),
TASMOTA_BRIGHTNESS_MAX,
)
attributes["white_value"] = device_white_value
# is on, and to color otherwise

if ATTR_TRANSITION in kwargs:
attributes["transition"] = kwargs[ATTR_TRANSITION]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tasmota/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Tasmota",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/tasmota",
"requirements": ["hatasmota==0.2.12"],
"requirements": ["hatasmota==0.2.13"],
"dependencies": ["mqtt"],
"mqtt": ["tasmota/discovery/#"],
"codeowners": ["@emontnemery"],
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 = 5
PATCH_VERSION = "4"
PATCH_VERSION = "5"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER = (3, 8, 0)
Expand Down
8 changes: 4 additions & 4 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ fortiosapi==0.10.8
freebox-api==0.0.10

# homeassistant.components.free_mobile
freesms==0.1.2
freesms==0.2.0

# homeassistant.components.fritz
# homeassistant.components.fritzbox_callmonitor
Expand Down Expand Up @@ -737,7 +737,7 @@ hass-nabucasa==0.43.0
hass_splunk==0.1.1

# homeassistant.components.tasmota
hatasmota==0.2.12
hatasmota==0.2.13

# homeassistant.components.jewish_calendar
hdate==0.10.2
Expand Down Expand Up @@ -1291,7 +1291,7 @@ pyarlo==0.2.4
pyatag==0.3.5.3

# homeassistant.components.netatmo
pyatmo==4.2.2
pyatmo==4.2.3

# homeassistant.components.atome
pyatome==0.1.1
Expand Down Expand Up @@ -1746,7 +1746,7 @@ pysnmp==4.4.12
pysoma==0.0.10

# homeassistant.components.sonos
pysonos==0.0.45
pysonos==0.0.47

# homeassistant.components.spc
pyspcwebgw==0.4.0
Expand Down
6 changes: 3 additions & 3 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ hangups==0.4.11
hass-nabucasa==0.43.0

# homeassistant.components.tasmota
hatasmota==0.2.12
hatasmota==0.2.13

# homeassistant.components.jewish_calendar
hdate==0.10.2
Expand Down Expand Up @@ -708,7 +708,7 @@ pyarlo==0.2.4
pyatag==0.3.5.3

# homeassistant.components.netatmo
pyatmo==4.2.2
pyatmo==4.2.3

# homeassistant.components.apple_tv
pyatv==0.7.7
Expand Down Expand Up @@ -965,7 +965,7 @@ pysmartthings==0.7.6
pysoma==0.0.10

# homeassistant.components.sonos
pysonos==0.0.45
pysonos==0.0.47

# homeassistant.components.spc
pyspcwebgw==0.4.0
Expand Down
2 changes: 1 addition & 1 deletion tests/components/netatmo/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ async def test_service_schedule_thermostats(hass, climate_entry, caplog):
await hass.async_block_till_done()
mock_switch_home_schedule.assert_not_called()

assert "summer is not a invalid schedule" in caplog.text
assert "summer is not a valid schedule" in caplog.text


async def test_service_preset_mode_already_boost_valves(hass, climate_entry):
Expand Down
2 changes: 1 addition & 1 deletion tests/components/tasmota/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"ofln": "Offline",
"onln": "Online",
"state": ["OFF", "ON", "TOGGLE", "HOLD"],
"sw": "8.4.0.2",
"sw": "9.4.0.4",
"swn": [None, None, None, None, None],
"t": "tasmota_49A3BC",
"ft": "%topic%/%prefix%/",
Expand Down
Loading

0 comments on commit c85d599

Please sign in to comment.