Bump hatasmota to 0.3.0 (#58592)
parent
ea028e38d5
commit
5851d5246e
|
@ -49,17 +49,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
websocket_api.async_register_command(hass, websocket_remove_device)
|
||||
hass.data[DATA_UNSUB] = []
|
||||
|
||||
def _publish(
|
||||
async def _publish(
|
||||
topic: str,
|
||||
payload: mqtt.PublishPayloadType,
|
||||
qos: int | None = None,
|
||||
retain: bool | None = None,
|
||||
qos: int | None,
|
||||
retain: bool | None,
|
||||
) -> None:
|
||||
if qos is None:
|
||||
qos = 0
|
||||
if retain is None:
|
||||
retain = False
|
||||
hass.async_create_task(mqtt.async_publish(hass, topic, payload, qos, retain))
|
||||
await mqtt.async_publish(hass, topic, payload, qos, retain)
|
||||
|
||||
async def _subscribe_topics(sub_state: dict | None, topics: dict) -> dict:
|
||||
# Optionally mark message handlers as callback
|
||||
|
@ -75,9 +71,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
|
||||
def async_discover_device(config: TasmotaDeviceConfig, mac: str) -> None:
|
||||
async def async_discover_device(config: TasmotaDeviceConfig, mac: str) -> None:
|
||||
"""Discover and add a Tasmota device."""
|
||||
async_setup_device(hass, mac, config, entry, tasmota_mqtt, device_registry)
|
||||
await async_setup_device(
|
||||
hass, mac, config, entry, tasmota_mqtt, device_registry
|
||||
)
|
||||
|
||||
async def async_device_removed(event: Event) -> None:
|
||||
"""Handle the removal of a device."""
|
||||
|
@ -92,7 +90,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
macs = [c[1] for c in device.connections if c[0] == CONNECTION_NETWORK_MAC]
|
||||
for mac in macs:
|
||||
clear_discovery_topic(mac, entry.data[CONF_DISCOVERY_PREFIX], tasmota_mqtt)
|
||||
await clear_discovery_topic(
|
||||
mac, entry.data[CONF_DISCOVERY_PREFIX], tasmota_mqtt
|
||||
)
|
||||
|
||||
hass.data[DATA_UNSUB].append(
|
||||
hass.bus.async_listen(EVENT_DEVICE_REGISTRY_UPDATED, async_device_removed)
|
||||
|
@ -143,7 +143,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
def _remove_device(
|
||||
async def _remove_device(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
mac: str,
|
||||
|
@ -158,7 +158,9 @@ def _remove_device(
|
|||
|
||||
_LOGGER.debug("Removing tasmota device %s", mac)
|
||||
device_registry.async_remove_device(device.id)
|
||||
clear_discovery_topic(mac, config_entry.data[CONF_DISCOVERY_PREFIX], tasmota_mqtt)
|
||||
await clear_discovery_topic(
|
||||
mac, config_entry.data[CONF_DISCOVERY_PREFIX], tasmota_mqtt
|
||||
)
|
||||
|
||||
|
||||
def _update_device(
|
||||
|
@ -180,7 +182,7 @@ def _update_device(
|
|||
)
|
||||
|
||||
|
||||
def async_setup_device(
|
||||
async def async_setup_device(
|
||||
hass: HomeAssistant,
|
||||
mac: str,
|
||||
config: TasmotaDeviceConfig,
|
||||
|
@ -190,7 +192,7 @@ def async_setup_device(
|
|||
) -> None:
|
||||
"""Set up the Tasmota device."""
|
||||
if not config:
|
||||
_remove_device(hass, config_entry, mac, tasmota_mqtt, device_registry)
|
||||
await _remove_device(hass, config_entry, mac, tasmota_mqtt, device_registry)
|
||||
else:
|
||||
_update_device(hass, config_entry, config, device_registry)
|
||||
|
||||
|
|
|
@ -111,17 +111,17 @@ class TasmotaCover(
|
|||
|
||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||
"""Open the cover."""
|
||||
self._tasmota_entity.open()
|
||||
await self._tasmota_entity.open()
|
||||
|
||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||
"""Close cover."""
|
||||
self._tasmota_entity.close()
|
||||
await self._tasmota_entity.close()
|
||||
|
||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||
"""Move the cover to a specific position."""
|
||||
position = kwargs[cover.ATTR_POSITION]
|
||||
self._tasmota_entity.set_position(position)
|
||||
await self._tasmota_entity.set_position(position)
|
||||
|
||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||
"""Stop the cover."""
|
||||
self._tasmota_entity.stop()
|
||||
await self._tasmota_entity.stop()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Callable
|
||||
from typing import Awaitable, Callable
|
||||
|
||||
from hatasmota.discovery import (
|
||||
TasmotaDiscovery,
|
||||
|
@ -34,7 +34,7 @@ TASMOTA_DISCOVERY_ENTITY_NEW = "tasmota_discovery_entity_new_{}"
|
|||
TASMOTA_DISCOVERY_ENTITY_UPDATED = "tasmota_discovery_entity_updated_{}_{}_{}_{}"
|
||||
TASMOTA_DISCOVERY_INSTANCE = "tasmota_discovery_instance"
|
||||
|
||||
SetupDeviceCallback = Callable[[TasmotaDeviceConfig, str], None]
|
||||
SetupDeviceCallback = Callable[[TasmotaDeviceConfig, str], Awaitable[None]]
|
||||
|
||||
|
||||
def clear_discovery_hash(
|
||||
|
@ -119,7 +119,7 @@ async def async_start(
|
|||
|
||||
_LOGGER.debug("Received discovery data for tasmota device: %s", mac)
|
||||
tasmota_device_config = tasmota_get_device_config(payload)
|
||||
setup_device(tasmota_device_config, mac)
|
||||
await setup_device(tasmota_device_config, mac)
|
||||
|
||||
if not payload:
|
||||
return
|
||||
|
|
|
@ -109,7 +109,7 @@ class TasmotaFan(
|
|||
tasmota_speed = percentage_to_ordered_list_item(
|
||||
ORDERED_NAMED_FAN_SPEEDS, percentage
|
||||
)
|
||||
self._tasmota_entity.set_speed(tasmota_speed)
|
||||
await self._tasmota_entity.set_speed(tasmota_speed)
|
||||
|
||||
async def async_turn_on(
|
||||
self,
|
||||
|
@ -129,4 +129,4 @@ class TasmotaFan(
|
|||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the fan off."""
|
||||
self._tasmota_entity.set_speed(tasmota_const.FAN_SPEED_OFF)
|
||||
await self._tasmota_entity.set_speed(tasmota_const.FAN_SPEED_OFF)
|
||||
|
|
|
@ -275,7 +275,7 @@ class TasmotaLight(
|
|||
if ATTR_EFFECT in kwargs:
|
||||
attributes["effect"] = kwargs[ATTR_EFFECT]
|
||||
|
||||
self._tasmota_entity.set_state(True, attributes)
|
||||
await self._tasmota_entity.set_state(True, attributes)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
|
@ -284,4 +284,4 @@ class TasmotaLight(
|
|||
if ATTR_TRANSITION in kwargs:
|
||||
attributes["transition"] = kwargs[ATTR_TRANSITION]
|
||||
|
||||
self._tasmota_entity.set_state(False, attributes)
|
||||
await self._tasmota_entity.set_state(False, attributes)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Tasmota",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/tasmota",
|
||||
"requirements": ["hatasmota==0.2.21"],
|
||||
"requirements": ["hatasmota==0.3.0"],
|
||||
"dependencies": ["mqtt"],
|
||||
"mqtt": ["tasmota/discovery/#"],
|
||||
"codeowners": ["@emontnemery"],
|
||||
|
|
|
@ -123,10 +123,9 @@ class TasmotaAvailability(TasmotaEntity):
|
|||
)
|
||||
await super().async_added_to_hass()
|
||||
|
||||
@callback
|
||||
def availability_updated(self, available: bool) -> None:
|
||||
async def availability_updated(self, available: bool) -> None:
|
||||
"""Handle updated availability."""
|
||||
self._tasmota_entity.poll_status()
|
||||
await self._tasmota_entity.poll_status()
|
||||
self._available = available
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ class TasmotaSwitch(
|
|||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
self._tasmota_entity.set_state(True)
|
||||
await self._tasmota_entity.set_state(True)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
self._tasmota_entity.set_state(False)
|
||||
await self._tasmota_entity.set_state(False)
|
||||
|
|
|
@ -786,7 +786,7 @@ hass-nabucasa==0.50.0
|
|||
hass_splunk==0.1.1
|
||||
|
||||
# homeassistant.components.tasmota
|
||||
hatasmota==0.2.21
|
||||
hatasmota==0.3.0
|
||||
|
||||
# homeassistant.components.jewish_calendar
|
||||
hdate==0.10.4
|
||||
|
|
|
@ -482,7 +482,7 @@ hangups==0.4.14
|
|||
hass-nabucasa==0.50.0
|
||||
|
||||
# homeassistant.components.tasmota
|
||||
hatasmota==0.2.21
|
||||
hatasmota==0.3.0
|
||||
|
||||
# homeassistant.components.jewish_calendar
|
||||
hdate==0.10.4
|
||||
|
|
|
@ -56,6 +56,7 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("binary_sensor.tasmota_binary_sensor_1")
|
||||
assert state.state == STATE_OFF
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -121,6 +122,7 @@ async def test_controlling_state_via_mqtt_switchname(hass, mqtt_mock, setup_tasm
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("binary_sensor.custom_name")
|
||||
assert state.state == STATE_OFF
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -179,6 +181,7 @@ async def test_pushon_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota)
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("binary_sensor.tasmota_binary_sensor_1")
|
||||
assert state.state == STATE_OFF
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
|
|
@ -130,7 +130,7 @@ async def help_test_availability_when_connection_lost(
|
|||
get_topic_tele_will(config),
|
||||
config_get_state_online(config),
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state != STATE_UNAVAILABLE
|
||||
|
||||
|
@ -158,6 +158,7 @@ async def help_test_availability_when_connection_lost(
|
|||
get_topic_tele_will(config),
|
||||
config_get_state_online(config),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state != STATE_UNAVAILABLE
|
||||
|
||||
|
@ -196,7 +197,7 @@ async def help_test_availability(
|
|||
get_topic_tele_will(config),
|
||||
config_get_state_online(config),
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state != STATE_UNAVAILABLE
|
||||
|
||||
|
@ -205,7 +206,7 @@ async def help_test_availability(
|
|||
get_topic_tele_will(config),
|
||||
config_get_state_offline(config),
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
@ -258,10 +259,12 @@ async def help_test_availability_discovery_update(
|
|||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
async_fire_mqtt_message(hass, availability_topic1, online1)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state != STATE_UNAVAILABLE
|
||||
|
||||
async_fire_mqtt_message(hass, availability_topic1, offline1)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
@ -273,11 +276,13 @@ async def help_test_availability_discovery_update(
|
|||
async_fire_mqtt_message(hass, availability_topic1, online1)
|
||||
async_fire_mqtt_message(hass, availability_topic1, online2)
|
||||
async_fire_mqtt_message(hass, availability_topic2, online1)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
# Verify we are subscribing to the new topic
|
||||
async_fire_mqtt_message(hass, availability_topic2, online2)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state != STATE_UNAVAILABLE
|
||||
|
||||
|
@ -575,10 +580,12 @@ async def help_test_entity_id_update_discovery_update(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, topic, config_get_state_online(config))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state != STATE_UNAVAILABLE
|
||||
|
||||
async_fire_mqtt_message(hass, topic, config_get_state_offline(config))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.{entity_id}")
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
@ -597,5 +604,6 @@ async def help_test_entity_id_update_discovery_update(
|
|||
|
||||
topic = get_topic_tele_will(config)
|
||||
async_fire_mqtt_message(hass, topic, config_get_state_online(config))
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(f"{domain}.milk")
|
||||
assert state.state != STATE_UNAVAILABLE
|
||||
|
|
|
@ -53,6 +53,7 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("cover.tasmota_cover_1")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert (
|
||||
|
@ -215,6 +216,7 @@ async def test_controlling_state_via_mqtt_inverted(hass, mqtt_mock, setup_tasmot
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("cover.tasmota_cover_1")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert (
|
||||
|
@ -383,6 +385,7 @@ async def test_sending_mqtt_commands(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("cover.test_cover_1")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
await hass.async_block_till_done()
|
||||
|
@ -446,6 +449,7 @@ async def test_sending_mqtt_commands_inverted(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("cover.test_cover_1")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -50,6 +50,7 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("fan.tasmota")
|
||||
assert state.state == STATE_OFF
|
||||
assert state.attributes["percentage"] is None
|
||||
|
@ -101,6 +102,7 @@ async def test_sending_mqtt_commands(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("fan.tasmota")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
@ -167,6 +169,7 @@ async def test_invalid_fan_speed_percentage(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("fan.tasmota")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -46,6 +46,7 @@ async def test_attributes_on_off(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
|
@ -72,6 +73,7 @@ async def test_attributes_dimmer_tuya(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
|
@ -97,6 +99,7 @@ async def test_attributes_dimmer(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
|
@ -122,6 +125,7 @@ async def test_attributes_ct(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
|
@ -148,6 +152,7 @@ async def test_attributes_ct_reduced(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
|
@ -173,6 +178,7 @@ async def test_attributes_rgb(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
|
@ -207,6 +213,7 @@ async def test_attributes_rgbw(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
|
@ -241,6 +248,7 @@ async def test_attributes_rgbww(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
|
@ -276,6 +284,7 @@ async def test_attributes_rgbww_reduced(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/STATE", '{"POWER":"ON"}')
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
|
@ -316,6 +325,7 @@ async def test_controlling_state_via_mqtt_on_off(hass, mqtt_mock, setup_tasmota)
|
|||
assert "color_mode" not in state.attributes
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -364,6 +374,7 @@ async def test_controlling_state_via_mqtt_ct(hass, mqtt_mock, setup_tasmota):
|
|||
assert "color_mode" not in state.attributes
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -426,6 +437,7 @@ async def test_controlling_state_via_mqtt_rgbw(hass, mqtt_mock, setup_tasmota):
|
|||
assert "color_mode" not in state.attributes
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -524,6 +536,7 @@ async def test_controlling_state_via_mqtt_rgbww(hass, mqtt_mock, setup_tasmota):
|
|||
assert "color_mode" not in state.attributes
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -625,6 +638,7 @@ async def test_controlling_state_via_mqtt_rgbww_tuya(hass, mqtt_mock, setup_tasm
|
|||
assert "color_mode" not in state.attributes
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -729,6 +743,7 @@ async def test_sending_mqtt_commands_on_off(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
@ -770,6 +785,7 @@ async def test_sending_mqtt_commands_rgbww_tuya(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
@ -817,6 +833,7 @@ async def test_sending_mqtt_commands_rgbw_legacy(hass, mqtt_mock, setup_tasmota)
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
@ -923,6 +940,7 @@ async def test_sending_mqtt_commands_rgbw(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
@ -1029,6 +1047,7 @@ async def test_sending_mqtt_commands_rgbww(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
@ -1114,6 +1133,7 @@ async def test_sending_mqtt_commands_power_unlinked(hass, mqtt_mock, setup_tasmo
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
@ -1164,6 +1184,7 @@ async def test_transition(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
@ -1345,6 +1366,7 @@ async def test_transition_fixed(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
|
|
@ -155,6 +155,7 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
|||
assert entry.entity_category is None
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_dht11_temperature")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -200,6 +201,7 @@ async def test_nested_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_tx23_speed_act")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -245,6 +247,7 @@ async def test_indexed_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_energy_totaltariff_1")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -293,6 +296,7 @@ async def test_indexed_sensor_state_via_mqtt2(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_energy_total")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -343,6 +347,7 @@ async def test_indexed_sensor_state_via_mqtt3(hass, mqtt_mock, setup_tasmota):
|
|||
)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_energy_total_1")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -396,6 +401,7 @@ async def test_bad_indexed_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota)
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_energy_apparentpower_0")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -507,6 +513,7 @@ async def test_status_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_status")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -566,6 +573,7 @@ async def test_single_shot_status_sensor_state_via_mqtt(hass, mqtt_mock, setup_t
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_status")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -650,6 +658,7 @@ async def test_restart_time_status_sensor_state_via_mqtt(
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_status")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -863,6 +872,7 @@ async def test_enable_status_sensor(hass, mqtt_mock, setup_tasmota):
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("sensor.tasmota_signal")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
|
|
@ -48,6 +48,7 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota):
|
|||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("switch.test")
|
||||
assert state.state == STATE_OFF
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
@ -87,6 +88,7 @@ async def test_sending_mqtt_commands(hass, mqtt_mock, setup_tasmota):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
async_fire_mqtt_message(hass, "tasmota_49A3BC/tele/LWT", "Online")
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("switch.test")
|
||||
assert state.state == STATE_OFF
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Reference in New Issue