hass-core/tests/components/motionmount/__init__.py
RJPoelstra 2c2e6171e2
Add integration for Vogel's MotionMount (#103498)
* Skeleton for Vogel's MotionMount support.

* Generated updates.

* Add validation of the discovered information.

* Add manual configuration

* Use a mac address as a unique id

* Add tests for config_flow

* Add a 'turn' sensor entity.

* Add all needed sensors.

* Add number and select entity for control of MotionMount

* Update based on development checklist

* Preset selector now updates when a preset is chosen

* Fix adding presets selector to device

* Remove irrelevant TODO

* Bump python-MotionMount requirement

* Invert direction of turn slider

* Prepare for PR

* Make sure entities have correct values when created

* Use device's mac address as unique id for entities.

* Fix missing files in .coveragerc

* Remove typing ignore from device library.

Improved typing also gave rise to the need to improve the callback mechanism

* Improve typing

* Convert property to shorthand form

* Remove unneeded CONF_NAME in ConfigEntry

* Add small comment

* Refresh coordinator on notification from MotionMount

* Use translation for entity

* Bump python-MotionMount

* Raise `ConfigEntryNotReady` when connect fails

* Use local variable

* Improve exception handling

* Reduce duplicate code

* Make better use of constants

* Remove unneeded callback

* Remove other occurrence of unneeded callback

* Improve removal of suffix

* Catch 'getaddrinfo' exception

* Add config flow tests for invalid hostname

* Abort if device with same hostname is already configured

* Make sure we connect to a device with the same unique id as configured

* Convert function names to snake_case

* Remove unneeded commented-out code

* Use tuple

* Make us of config_entry id when mac is missing

* Prevent update of entities when nothing changed

* Don't store data in `hass.data` until we know we will proceed

* Remove coordinator

* Handle situation where mac is EMPTY_MAC

* Disable polling

* Fix failing hassfest

* Avoid calling unique-id-less discovery handler for situations where we've an unique id
2023-12-22 12:04:58 +01:00

42 lines
1.2 KiB
Python

"""Tests for the Vogel's MotionMount integration."""
from ipaddress import ip_address
from homeassistant.components import zeroconf
from homeassistant.const import CONF_HOST, CONF_PORT
HOST = "192.168.1.31"
PORT = 23
TVM_ZEROCONF_SERVICE_TYPE = "_tvm._tcp.local."
ZEROCONF_NAME = "My MotionMount"
ZEROCONF_HOST = HOST
ZEROCONF_HOSTNAME = "MMF8A55F.local."
ZEROCONF_PORT = PORT
ZEROCONF_MAC = "c4:dd:57:f8:a5:5f"
MOCK_USER_INPUT = {
CONF_HOST: HOST,
CONF_PORT: PORT,
}
MOCK_ZEROCONF_TVM_SERVICE_INFO_V1 = zeroconf.ZeroconfServiceInfo(
type=TVM_ZEROCONF_SERVICE_TYPE,
name=f"{ZEROCONF_NAME}.{TVM_ZEROCONF_SERVICE_TYPE}",
ip_address=ip_address(ZEROCONF_HOST),
ip_addresses=[ip_address(ZEROCONF_HOST)],
hostname=ZEROCONF_HOSTNAME,
port=ZEROCONF_PORT,
properties={"txtvers": "1", "model": "TVM 7675"},
)
MOCK_ZEROCONF_TVM_SERVICE_INFO_V2 = zeroconf.ZeroconfServiceInfo(
type=TVM_ZEROCONF_SERVICE_TYPE,
name=f"{ZEROCONF_NAME}.{TVM_ZEROCONF_SERVICE_TYPE}",
ip_address=ip_address(ZEROCONF_HOST),
ip_addresses=[ip_address(ZEROCONF_HOST)],
hostname=ZEROCONF_HOSTNAME,
port=ZEROCONF_PORT,
properties={"mac": ZEROCONF_MAC, "txtvers": "2", "model": "TVM 7675"},
)