mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-12 01:24:29 +05:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ba627a9f9 | ||
|
|
0138f5e323 | ||
|
|
0ab4f6623c | ||
|
|
5664e1e929 | ||
|
|
bcf108fc9c | ||
|
|
ca3f90374b | ||
|
|
d15cce8061 | ||
|
|
4e83d81004 | ||
|
|
9ceb544c1a | ||
|
|
c8b3cb60de | ||
|
|
bd550442d4 | ||
|
|
8903628b36 | ||
|
|
e1a6637f28 | ||
|
|
a346cb3fd7 | ||
|
|
d6ef137e75 |
@@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 1.1.4
|
||||
current_version = 1.1.7b0
|
||||
parse = (?P<major>\d+)(\.(?P<minor>\d+))(\.(?P<patch>\d+))(?P<release>[bf]*)(?P<build>\d*)
|
||||
commit = True
|
||||
tag = True
|
||||
|
||||
@@ -136,10 +136,10 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
CUSTOMIZE_PORT,
|
||||
CUSTOMIZE_DS2413,
|
||||
),
|
||||
vol.Optional(CONF_FILTER_VALUES): [cv.positive_float],
|
||||
vol.Optional(CONF_FILTER_SCALE): cv.positive_float,
|
||||
vol.Optional(CONF_FILTER_LOW): cv.positive_float,
|
||||
vol.Optional(CONF_FILTER_HIGH): cv.positive_float,
|
||||
vol.Optional(CONF_FILTER_VALUES): [vol.Coerce(float)],
|
||||
vol.Optional(CONF_FILTER_SCALE): vol.Coerce(float),
|
||||
vol.Optional(CONF_FILTER_LOW): vol.Coerce(float),
|
||||
vol.Optional(CONF_FILTER_HIGH): vol.Coerce(float),
|
||||
},
|
||||
vol.Optional(CONF_1WBUS): [OWBUS]
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ from functools import partial
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.core import State
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
from . import hub as h
|
||||
@@ -142,7 +143,7 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
||||
return self._customize
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
if isinstance(self.port, list):
|
||||
pt_idx = self.id_suffix
|
||||
else:
|
||||
@@ -151,19 +152,16 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
||||
pt_idx, _ = _pt.split('e')
|
||||
else:
|
||||
pt_idx = _pt
|
||||
return {
|
||||
"identifiers": {
|
||||
return DeviceInfo(
|
||||
identifiers={
|
||||
# Serial numbers are unique identifiers within a specific domain
|
||||
(DOMAIN, f'{self._mega_id}', pt_idx),
|
||||
(DOMAIN, f'{self._mega_id}', pt_idx)
|
||||
},
|
||||
"config_entries": [
|
||||
self.config_entry,
|
||||
],
|
||||
"name": f'{self._mega_id} port {pt_idx}' if not isinstance(self.port, list) else f'{self._mega_id} {pt_idx}',
|
||||
"manufacturer": 'ab-log.ru',
|
||||
"sw_version": self.mega.fw,
|
||||
"via_device": (DOMAIN, self._mega_id),
|
||||
}
|
||||
name=self.name,
|
||||
manufacturer='ab-log.ru',
|
||||
sw_version=self.mega.fw,
|
||||
via_device=(DOMAIN, self._mega_id),
|
||||
)
|
||||
|
||||
@property
|
||||
def lg(self) -> logging.Logger:
|
||||
|
||||
@@ -9,10 +9,10 @@ import re
|
||||
import json
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_ILLUMINANCE, TEMP_CELSIUS, PERCENTAGE, LIGHT_LUX
|
||||
from homeassistant.const import ( TEMP_CELSIUS, PERCENTAGE, LIGHT_LUX
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
@@ -45,10 +45,10 @@ UNITS = {
|
||||
LUX: LIGHT_LUX
|
||||
}
|
||||
CLASSES = {
|
||||
TEMP: DEVICE_CLASS_TEMPERATURE,
|
||||
HUM: DEVICE_CLASS_HUMIDITY,
|
||||
PRESS: DEVICE_CLASS_PRESSURE,
|
||||
LUX: DEVICE_CLASS_ILLUMINANCE
|
||||
TEMP: SensorDeviceClass.TEMPERATURE,
|
||||
HUM: SensorDeviceClass.HUMIDITY,
|
||||
PRESS: SensorDeviceClass.PRESSURE,
|
||||
LUX: SensorDeviceClass.ILLUMINANCE
|
||||
}
|
||||
I2C_DEVICE_TYPES = {
|
||||
"2": LUX, # BH1750
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import typing
|
||||
from dataclasses import dataclass, field, astuple
|
||||
from dataclasses import dataclass, astuple
|
||||
from urllib.parse import parse_qsl, urlparse
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_CO2,
|
||||
PERCENTAGE,
|
||||
LIGHT_LUX,
|
||||
TEMP_CELSIUS,
|
||||
@@ -16,11 +13,11 @@ from homeassistant.const import (
|
||||
)
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
# DeviceType = namedtuple('DeviceType', 'device_class,unit_of_measurement,suffix')
|
||||
|
||||
@dataclass
|
||||
class DeviceType:
|
||||
|
||||
device_class: typing.Optional[str] = None
|
||||
unit_of_measurement: typing.Optional[str] = None
|
||||
suffix: typing.Optional[str] = None
|
||||
@@ -89,55 +86,55 @@ class Request:
|
||||
|
||||
i2c_classes = {
|
||||
'htu21d': [
|
||||
DeviceType(DEVICE_CLASS_HUMIDITY, PERCENTAGE, None),
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
DeviceType(SensorDeviceClass.HUMIDITY, PERCENTAGE, None),
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, None),
|
||||
],
|
||||
'sht31': [
|
||||
DeviceType(DEVICE_CLASS_HUMIDITY, PERCENTAGE, None, delay=1.5),
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
DeviceType(SensorDeviceClass.HUMIDITY, PERCENTAGE, None, delay=1.5),
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, None),
|
||||
],
|
||||
'max44009': [
|
||||
DeviceType(DEVICE_CLASS_ILLUMINANCE, LIGHT_LUX, None)
|
||||
DeviceType(SensorDeviceClass.ILLUMINANCE, LIGHT_LUX, None)
|
||||
],
|
||||
'bh1750': [
|
||||
DeviceType(DEVICE_CLASS_ILLUMINANCE, LIGHT_LUX, None)
|
||||
DeviceType(SensorDeviceClass.ILLUMINANCE, LIGHT_LUX, None)
|
||||
],
|
||||
'tsl2591': [
|
||||
DeviceType(DEVICE_CLASS_ILLUMINANCE, LIGHT_LUX, None)
|
||||
DeviceType(SensorDeviceClass.ILLUMINANCE, LIGHT_LUX, None)
|
||||
],
|
||||
'bmp180': [
|
||||
DeviceType(DEVICE_CLASS_PRESSURE, PRESSURE_BAR, None),
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
DeviceType(SensorDeviceClass.PRESSURE, PRESSURE_BAR, None),
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, None),
|
||||
],
|
||||
'bmx280': [
|
||||
DeviceType(DEVICE_CLASS_PRESSURE, PRESSURE_BAR, None),
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
DeviceType(DEVICE_CLASS_HUMIDITY, PERCENTAGE, None)
|
||||
DeviceType(SensorDeviceClass.PRESSURE, PRESSURE_BAR, None),
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, None),
|
||||
DeviceType(SensorDeviceClass.HUMIDITY, PERCENTAGE, None)
|
||||
],
|
||||
'dps368': [
|
||||
DeviceType(DEVICE_CLASS_PRESSURE, PRESSURE_BAR, None),
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
DeviceType(SensorDeviceClass.PRESSURE, PRESSURE_BAR, None),
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, None),
|
||||
],
|
||||
'mlx90614': [
|
||||
Skip,
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, 'temp'),
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, 'object'),
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, 'temp'),
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, 'object'),
|
||||
],
|
||||
'ptsensor': [
|
||||
Skip,
|
||||
Request(delay=3), # запрос на измерение
|
||||
DeviceType(DEVICE_CLASS_PRESSURE, PRESSURE_BAR, None),
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
DeviceType(SensorDeviceClass.PRESSURE, PRESSURE_BAR, None),
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, None),
|
||||
],
|
||||
'mcp9600': [
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None), # термопара
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None), # сенсор встроенный в микросхему
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, None), # термопара
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, None), # сенсор встроенный в микросхему
|
||||
],
|
||||
't67xx': [
|
||||
DeviceType(DEVICE_CLASS_CO2, CONCENTRATION_PARTS_PER_MILLION, None)
|
||||
DeviceType(SensorDeviceClass.CO2, CONCENTRATION_PARTS_PER_MILLION, None)
|
||||
],
|
||||
'tmp117': [
|
||||
DeviceType(DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, None),
|
||||
DeviceType(SensorDeviceClass.TEMPERATURE, TEMP_CELSIUS, None),
|
||||
],
|
||||
'ads1115': [
|
||||
DeviceType(None, None, 'ch0'),
|
||||
|
||||
@@ -131,7 +131,7 @@ class MegaRGBW(LightEntity, BaseMegaEntity):
|
||||
def max_values(self) -> list:
|
||||
if self._max_values is None:
|
||||
if self.is_ws:
|
||||
self._max_values = [255] * 3
|
||||
self._max_values = [255] * 4
|
||||
else:
|
||||
self._max_values = [
|
||||
255 if isinstance(x, int) else 4095 for x in self.port
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
"@andvikt"
|
||||
],
|
||||
"issue_tracker": "https://github.com/andvikt/mega_hacs/issues",
|
||||
"version": "v1.1.4"
|
||||
"version": "v1.1.7b0"
|
||||
}
|
||||
@@ -4,9 +4,7 @@ import voluptuous as vol
|
||||
import struct
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
PLATFORM_SCHEMA as SENSOR_SCHEMA,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_HUMIDITY, SensorEntity
|
||||
PLATFORM_SCHEMA as SENSOR_SCHEMA, SensorEntity, SensorDeviceClass
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@@ -40,8 +38,8 @@ UNITS = {
|
||||
HUM: '%'
|
||||
}
|
||||
CLASSES = {
|
||||
TEMP: DEVICE_CLASS_TEMPERATURE,
|
||||
HUM: DEVICE_CLASS_HUMIDITY
|
||||
TEMP: SensorDeviceClass.TEMPERATURE,
|
||||
HUM: SensorDeviceClass.HUMIDITY
|
||||
}
|
||||
# Validation of the user's configuration
|
||||
_ITEM = {
|
||||
@@ -118,15 +116,15 @@ class FilterBadValues(MegaPushEntity, SensorEntity):
|
||||
try:
|
||||
if value \
|
||||
in self.filter_values \
|
||||
or (self.filter_low is not None and value < self.filter_low) \
|
||||
or (self.filter_high is not None and value > self.filter_high) \
|
||||
or (
|
||||
or (self.filter_low is not None and value < self.filter_low) \
|
||||
or (self.filter_high is not None and value > self.filter_high) \
|
||||
or (
|
||||
self._prev_value is not None
|
||||
and self.filter_scale is not None
|
||||
and (
|
||||
abs(value - self._prev_value) / self._prev_value > self.filter_scale
|
||||
abs(value - self._prev_value) / self._prev_value > self.filter_scale
|
||||
)
|
||||
):
|
||||
):
|
||||
if self.fill_na == 'last':
|
||||
value = self._prev_value
|
||||
else:
|
||||
@@ -231,8 +229,8 @@ class Mega1WSensor(FilterBadValues):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
unit_of_measurement,
|
||||
device_class,
|
||||
unit_of_measurement=None,
|
||||
device_class=None,
|
||||
key=None,
|
||||
*args,
|
||||
**kwargs
|
||||
|
||||
Reference in New Issue
Block a user