hass-core/tests/components/rainforest_raven/const.py
Scott K Logan f249563608
Add Rainforest RAVEn integration (#80061)
* Add Rainforest RAVEn integration

* Add Rainforest Automation brand

* Add diagnostics to Rainforest RAVEn integration

* Drop a test assertion for an undefined behavior

* Add DEVICE_NAME test constant

* Catch up with reality

* Use Platform.SENSOR

Co-authored-by: Robert Resch <robert@resch.dev>

* Make rainforest_raven translatable

* Stop setting device_class on unsupported scenarios

* Rename rainforest_raven.data -> rainforest_raven.coordinator

* Make _generate_unique_id more reusable

* Move device synchronization into third party library

* Switch from asyncio_timeout to asyncio.timeout

* Ignore non-electric meters

Co-authored-by: Robert Resch <robert@resch.dev>

* Drop direct dependency on iso4217, bump aioraven

* Use RAVEn-specific exceptions

* Add timeouts to data updates

* Move DeviceInfo generation from Sensor to Coordinator

* Store meter macs as strings

* Convert to using SelectSelector

* Drop test_flow_user_invalid_mac

This test isn't necessary now that SelectSelector is used.

* Implement PR feedback

- Split some long format lines
- Simplify meter mac_id extraction in diagnostics
- Expose unique_id using an attribute instead of a property
- Add a comment about the meters dictionary shallow copy

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Simplify mac address redaction

Co-authored-by: Joakim Sørensen <ludeeus@ludeeus.dev>

* Freeze RAVEnSensorEntityDescription dataclass

Co-authored-by: Erik Montnemery <erik@montnemery.com>

---------

Co-authored-by: Robert Resch <robert@resch.dev>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Joakim Sørensen <ludeeus@ludeeus.dev>
2024-01-05 14:00:54 +01:00

132 lines
3 KiB
Python

"""Constants for the Rainforest RAVEn tests."""
from aioraven.data import (
CurrentSummationDelivered,
DeviceInfo,
InstantaneousDemand,
MeterInfo,
MeterList,
MeterType,
NetworkInfo,
PriceCluster,
)
from iso4217 import Currency
from homeassistant.components import usb
DISCOVERY_INFO = usb.UsbServiceInfo(
device="/dev/ttyACM0",
pid="0x0003",
vid="0x04B4",
serial_number="1234",
description="RFA-Z105-2 HW2.7.3 EMU-2",
manufacturer="Rainforest Automation, Inc.",
)
DEVICE_NAME = usb.human_readable_device_name(
DISCOVERY_INFO.device,
DISCOVERY_INFO.serial_number,
DISCOVERY_INFO.manufacturer,
DISCOVERY_INFO.description,
int(DISCOVERY_INFO.vid, 0),
int(DISCOVERY_INFO.pid, 0),
)
DEVICE_INFO = DeviceInfo(
device_mac_id=bytes.fromhex("abcdef0123456789"),
install_code=None,
link_key=None,
fw_version="2.0.0 (7400)",
hw_version="2.7.3",
image_type=None,
manufacturer=DISCOVERY_INFO.manufacturer,
model_id="Z105-2-EMU2-LEDD_JM",
date_code=None,
)
METER_LIST = MeterList(
device_mac_id=DEVICE_INFO.device_mac_id,
meter_mac_ids=[
bytes.fromhex("1234567890abcdef"),
bytes.fromhex("9876543210abcdef"),
],
)
METER_INFO = {
None: MeterInfo(
device_mac_id=DEVICE_INFO.device_mac_id,
meter_mac_id=METER_LIST.meter_mac_ids[0],
meter_type=MeterType.ELECTRIC,
nick_name=None,
account=None,
auth=None,
host=None,
enabled=True,
),
METER_LIST.meter_mac_ids[0]: MeterInfo(
device_mac_id=DEVICE_INFO.device_mac_id,
meter_mac_id=METER_LIST.meter_mac_ids[0],
meter_type=MeterType.ELECTRIC,
nick_name=None,
account=None,
auth=None,
host=None,
enabled=True,
),
METER_LIST.meter_mac_ids[1]: MeterInfo(
device_mac_id=DEVICE_INFO.device_mac_id,
meter_mac_id=METER_LIST.meter_mac_ids[1],
meter_type=MeterType.GAS,
nick_name=None,
account=None,
auth=None,
host=None,
enabled=True,
),
}
NETWORK_INFO = NetworkInfo(
device_mac_id=DEVICE_INFO.device_mac_id,
coord_mac_id=None,
status=None,
description=None,
status_code=None,
ext_pan_id=None,
channel=13,
short_addr=None,
link_strength=100,
)
PRICE_CLUSTER = PriceCluster(
device_mac_id=DEVICE_INFO.device_mac_id,
meter_mac_id=METER_INFO[None].meter_mac_id,
time_stamp=None,
price="0.10",
currency=Currency.usd,
tier=3,
tier_label="Set by user",
rate_label="Set by user",
)
SUMMATION = CurrentSummationDelivered(
device_mac_id=DEVICE_INFO.device_mac_id,
meter_mac_id=METER_INFO[None].meter_mac_id,
time_stamp=None,
summation_delivered="23456.7890",
summation_received="00000.0000",
)
DEMAND = InstantaneousDemand(
device_mac_id=DEVICE_INFO.device_mac_id,
meter_mac_id=METER_INFO[None].meter_mac_id,
time_stamp=None,
demand="1.2345",
)