2021-04-01 13:06:47 +00:00
|
|
|
"""Constants for 1-Wire integration."""
|
2024-03-08 13:55:15 +00:00
|
|
|
|
2024-04-27 07:26:26 +00:00
|
|
|
from pyownet.protocol import ProtocolError
|
2020-10-14 08:19:12 +00:00
|
|
|
|
2023-04-29 09:18:16 +00:00
|
|
|
from homeassistant.components.onewire.const import Platform
|
2020-10-14 08:19:12 +00:00
|
|
|
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_DEVICE_FILE = "device_file"
|
|
|
|
ATTR_INJECT_READS = "inject_reads"
|
2021-10-20 09:43:59 +00:00
|
|
|
|
2021-07-30 11:35:49 +00:00
|
|
|
|
2021-04-01 13:06:47 +00:00
|
|
|
MOCK_OWPROXY_DEVICES = {
|
2020-10-25 17:05:02 +00:00
|
|
|
"00.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-25 17:05:02 +00:00
|
|
|
b"", # read device type
|
|
|
|
],
|
|
|
|
},
|
2021-05-20 15:02:25 +00:00
|
|
|
"05.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2021-05-20 15:02:25 +00:00
|
|
|
b"DS2405", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SWITCH: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
2021-05-20 15:02:25 +00:00
|
|
|
],
|
|
|
|
},
|
2020-10-14 08:19:12 +00:00
|
|
|
"10.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-25 17:05:02 +00:00
|
|
|
b"DS18S20", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 25.123"},
|
2020-10-25 17:05:02 +00:00
|
|
|
],
|
2020-10-14 08:19:12 +00:00
|
|
|
},
|
2020-10-24 18:56:41 +00:00
|
|
|
"12.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-25 17:05:02 +00:00
|
|
|
b"DS2406", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.BINARY_SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
2020-11-08 02:42:20 +00:00
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 25.123"},
|
|
|
|
{ATTR_INJECT_READS: b" 1025.123"},
|
2020-10-25 17:05:02 +00:00
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SWITCH: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
2020-11-08 18:06:41 +00:00
|
|
|
],
|
2020-10-24 18:56:41 +00:00
|
|
|
},
|
2020-10-14 08:19:12 +00:00
|
|
|
"1D.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-25 17:05:02 +00:00
|
|
|
b"DS2423", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 251123"},
|
|
|
|
{ATTR_INJECT_READS: b" 248125"},
|
2020-10-25 17:05:02 +00:00
|
|
|
],
|
2020-10-14 08:19:12 +00:00
|
|
|
},
|
2024-04-27 07:26:26 +00:00
|
|
|
"16.111111111111": {
|
|
|
|
# Test case for issue #115984, where the device type cannot be read
|
|
|
|
ATTR_INJECT_READS: [
|
|
|
|
ProtocolError(), # read device type
|
|
|
|
],
|
|
|
|
},
|
2020-12-07 01:09:32 +00:00
|
|
|
"1F.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-12-07 01:09:32 +00:00
|
|
|
b"DS2409", # read device type
|
|
|
|
],
|
2021-04-01 13:06:47 +00:00
|
|
|
"branches": {
|
|
|
|
"aux": {},
|
|
|
|
"main": {
|
|
|
|
"1D.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2021-04-01 13:06:47 +00:00
|
|
|
b"DS2423", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2021-04-01 13:06:47 +00:00
|
|
|
{
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_DEVICE_FILE: "/1F.111111111111/main/1D.111111111111/counter.A",
|
|
|
|
ATTR_INJECT_READS: b" 251123",
|
2021-04-01 13:06:47 +00:00
|
|
|
},
|
|
|
|
{
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_DEVICE_FILE: "/1F.111111111111/main/1D.111111111111/counter.B",
|
|
|
|
ATTR_INJECT_READS: b" 248125",
|
2021-04-01 13:06:47 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-12-07 01:09:32 +00:00
|
|
|
},
|
2020-10-14 08:19:12 +00:00
|
|
|
"22.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-25 17:05:02 +00:00
|
|
|
b"DS1822", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2020-10-14 08:19:12 +00:00
|
|
|
{
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: ProtocolError,
|
2020-10-14 08:19:12 +00:00
|
|
|
},
|
2020-10-25 17:05:02 +00:00
|
|
|
],
|
2020-10-14 08:19:12 +00:00
|
|
|
},
|
2020-10-24 18:56:41 +00:00
|
|
|
"26.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-25 17:05:02 +00:00
|
|
|
b"DS2438", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 25.123"},
|
|
|
|
{ATTR_INJECT_READS: b" 72.7563"},
|
|
|
|
{ATTR_INJECT_READS: b" 73.7563"},
|
|
|
|
{ATTR_INJECT_READS: b" 74.7563"},
|
|
|
|
{ATTR_INJECT_READS: b" 75.7563"},
|
2020-10-24 18:56:41 +00:00
|
|
|
{
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: ProtocolError,
|
2021-11-14 16:30:03 +00:00
|
|
|
},
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 969.265"},
|
|
|
|
{ATTR_INJECT_READS: b" 65.8839"},
|
|
|
|
{ATTR_INJECT_READS: b" 2.97"},
|
|
|
|
{ATTR_INJECT_READS: b" 4.74"},
|
|
|
|
{ATTR_INJECT_READS: b" 0.12"},
|
2021-11-14 16:30:03 +00:00
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SWITCH: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
2020-10-25 17:05:02 +00:00
|
|
|
],
|
2020-10-24 18:56:41 +00:00
|
|
|
},
|
2020-10-14 08:19:12 +00:00
|
|
|
"28.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-25 17:05:02 +00:00
|
|
|
b"DS18B20", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 26.984"},
|
2020-10-25 17:05:02 +00:00
|
|
|
],
|
2020-10-14 08:19:12 +00:00
|
|
|
},
|
2022-03-03 19:41:59 +00:00
|
|
|
"28.222222222222": {
|
|
|
|
# This device has precision options in the config entry
|
|
|
|
ATTR_INJECT_READS: [
|
|
|
|
b"DS18B20", # read device type
|
|
|
|
],
|
|
|
|
Platform.SENSOR: [
|
|
|
|
{
|
|
|
|
ATTR_DEVICE_FILE: "/28.222222222222/temperature9",
|
|
|
|
ATTR_INJECT_READS: b" 26.984",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
"28.222222222223": {
|
|
|
|
# This device has an illegal precision option in the config entry
|
|
|
|
ATTR_INJECT_READS: [
|
|
|
|
b"DS18B20", # read device type
|
|
|
|
],
|
|
|
|
Platform.SENSOR: [
|
|
|
|
{
|
|
|
|
ATTR_DEVICE_FILE: "/28.222222222223/temperature",
|
|
|
|
ATTR_INJECT_READS: b" 26.984",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2020-11-08 02:42:20 +00:00
|
|
|
"29.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-11-08 02:42:20 +00:00
|
|
|
b"DS2408", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.BINARY_SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
2024-03-18 09:12:46 +00:00
|
|
|
{
|
|
|
|
ATTR_INJECT_READS: ProtocolError,
|
|
|
|
},
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
2020-11-08 02:42:20 +00:00
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SWITCH: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
2024-03-18 09:12:46 +00:00
|
|
|
{
|
|
|
|
ATTR_INJECT_READS: ProtocolError,
|
|
|
|
},
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
2020-11-08 18:06:41 +00:00
|
|
|
],
|
2020-11-08 02:42:20 +00:00
|
|
|
},
|
2022-01-25 12:53:37 +00:00
|
|
|
"30.111111111111": {
|
|
|
|
ATTR_INJECT_READS: [
|
|
|
|
b"DS2760", # read device type
|
|
|
|
],
|
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 26.984"},
|
2022-01-25 12:53:37 +00:00
|
|
|
{
|
|
|
|
ATTR_DEVICE_FILE: "/30.111111111111/typeK/temperature",
|
|
|
|
ATTR_INJECT_READS: b" 173.7563",
|
|
|
|
},
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 2.97"},
|
|
|
|
{ATTR_INJECT_READS: b" 0.12"},
|
2022-01-25 12:53:37 +00:00
|
|
|
],
|
|
|
|
},
|
2021-10-15 06:23:26 +00:00
|
|
|
"3A.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2021-10-15 06:23:26 +00:00
|
|
|
b"DS2413", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.BINARY_SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
2021-10-15 06:23:26 +00:00
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SWITCH: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
{ATTR_INJECT_READS: b" 0"},
|
2021-10-15 06:23:26 +00:00
|
|
|
],
|
|
|
|
},
|
2020-10-14 08:19:12 +00:00
|
|
|
"3B.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-25 17:05:02 +00:00
|
|
|
b"DS1825", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 28.243"},
|
2020-10-25 17:05:02 +00:00
|
|
|
],
|
2020-10-14 08:19:12 +00:00
|
|
|
},
|
|
|
|
"42.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-25 17:05:02 +00:00
|
|
|
b"DS28EA00", # read device type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 29.123"},
|
2020-10-25 17:05:02 +00:00
|
|
|
],
|
2020-10-14 08:19:12 +00:00
|
|
|
},
|
2024-03-12 07:06:02 +00:00
|
|
|
"A6.111111111111": {
|
|
|
|
ATTR_INJECT_READS: [
|
|
|
|
b"DS2438", # read device type
|
|
|
|
],
|
|
|
|
Platform.SENSOR: [
|
|
|
|
{ATTR_INJECT_READS: b" 25.123"},
|
|
|
|
{ATTR_INJECT_READS: b" 72.7563"},
|
|
|
|
{ATTR_INJECT_READS: b" 73.7563"},
|
|
|
|
{ATTR_INJECT_READS: b" 74.7563"},
|
|
|
|
{ATTR_INJECT_READS: b" 75.7563"},
|
|
|
|
{
|
|
|
|
ATTR_INJECT_READS: ProtocolError,
|
|
|
|
},
|
|
|
|
{ATTR_INJECT_READS: b" 969.265"},
|
|
|
|
{ATTR_INJECT_READS: b" 65.8839"},
|
|
|
|
{ATTR_INJECT_READS: b" 2.97"},
|
|
|
|
{ATTR_INJECT_READS: b" 4.74"},
|
|
|
|
{ATTR_INJECT_READS: b" 0.12"},
|
|
|
|
],
|
|
|
|
Platform.SWITCH: [
|
|
|
|
{ATTR_INJECT_READS: b" 1"},
|
|
|
|
],
|
|
|
|
},
|
2020-10-14 08:19:12 +00:00
|
|
|
"EF.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-14 08:19:12 +00:00
|
|
|
b"HobbyBoards_EF", # read type
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 67.745"},
|
|
|
|
{ATTR_INJECT_READS: b" 65.541"},
|
|
|
|
{ATTR_INJECT_READS: b" 25.123"},
|
2020-10-14 08:19:12 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
"EF.111111111112": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2020-10-14 08:19:12 +00:00
|
|
|
b"HB_MOISTURE_METER", # read type
|
|
|
|
b" 1", # read is_leaf_0
|
|
|
|
b" 1", # read is_leaf_1
|
|
|
|
b" 0", # read is_leaf_2
|
|
|
|
b" 0", # read is_leaf_3
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 41.745"},
|
|
|
|
{ATTR_INJECT_READS: b" 42.541"},
|
|
|
|
{ATTR_INJECT_READS: b" 43.123"},
|
|
|
|
{ATTR_INJECT_READS: b" 44.123"},
|
2020-10-14 08:19:12 +00:00
|
|
|
],
|
2021-12-07 12:59:43 +00:00
|
|
|
Platform.SWITCH: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b"1"},
|
|
|
|
{ATTR_INJECT_READS: b"1"},
|
|
|
|
{ATTR_INJECT_READS: b"0"},
|
|
|
|
{ATTR_INJECT_READS: b"0"},
|
|
|
|
{ATTR_INJECT_READS: b"1"},
|
|
|
|
{ATTR_INJECT_READS: b"1"},
|
|
|
|
{ATTR_INJECT_READS: b"0"},
|
|
|
|
{ATTR_INJECT_READS: b"0"},
|
2021-12-07 12:59:43 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
"EF.111111111113": {
|
|
|
|
ATTR_INJECT_READS: [
|
|
|
|
b"HB_HUB", # read type
|
|
|
|
],
|
|
|
|
Platform.BINARY_SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b"1"},
|
|
|
|
{ATTR_INJECT_READS: b"0"},
|
|
|
|
{ATTR_INJECT_READS: b"1"},
|
|
|
|
{ATTR_INJECT_READS: b"0"},
|
2021-12-07 12:59:43 +00:00
|
|
|
],
|
|
|
|
Platform.SWITCH: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b"1"},
|
|
|
|
{ATTR_INJECT_READS: b"0"},
|
|
|
|
{ATTR_INJECT_READS: b"1"},
|
|
|
|
{ATTR_INJECT_READS: b"0"},
|
2021-12-07 12:59:43 +00:00
|
|
|
],
|
2020-10-14 08:19:12 +00:00
|
|
|
},
|
2021-01-26 22:07:04 +00:00
|
|
|
"7E.111111111111": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2021-01-26 22:07:04 +00:00
|
|
|
b"EDS", # read type
|
|
|
|
b"EDS0068", # read device_type - note EDS specific
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 13.9375"},
|
|
|
|
{ATTR_INJECT_READS: b" 1012.21"},
|
|
|
|
{ATTR_INJECT_READS: b" 65.8839"},
|
|
|
|
{ATTR_INJECT_READS: b" 41.375"},
|
2021-01-26 22:07:04 +00:00
|
|
|
],
|
|
|
|
},
|
2021-05-20 13:39:34 +00:00
|
|
|
"7E.222222222222": {
|
2021-10-19 19:41:01 +00:00
|
|
|
ATTR_INJECT_READS: [
|
2021-05-20 13:39:34 +00:00
|
|
|
b"EDS", # read type
|
|
|
|
b"EDS0066", # read device_type - note EDS specific
|
|
|
|
],
|
2021-12-03 17:25:22 +00:00
|
|
|
Platform.SENSOR: [
|
2023-04-29 09:18:16 +00:00
|
|
|
{ATTR_INJECT_READS: b" 13.9375"},
|
|
|
|
{ATTR_INJECT_READS: b" 1012.21"},
|
2021-05-20 13:39:34 +00:00
|
|
|
],
|
|
|
|
},
|
2020-10-14 08:19:12 +00:00
|
|
|
}
|