-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c3424c
commit f015eb2
Showing
30 changed files
with
883 additions
and
701 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__all__ = ["sqlite_filepath"] | ||
__all__ = [] | ||
|
||
|
||
from freyr import get_data_root | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
__all__ = ["Summary"] | ||
|
||
from datetime import datetime | ||
from decimal import Decimal | ||
from typing import Self | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class Summary(BaseModel): | ||
class Reading(BaseModel): | ||
timestamp: datetime | ||
temperature: Decimal | ||
humidity: Decimal | ||
|
||
def __lt__(self: Self, other) -> int: # noqa: ANN001 | ||
if not isinstance(other, Summary.Reading): | ||
raise NotImplementedError | ||
return self.timestamp < other.timestamp | ||
|
||
def __eq__(self: Self, other) -> bool: # noqa: ANN001 | ||
if not isinstance(other, Summary.Reading): | ||
raise NotImplementedError | ||
return self.timestamp == other.timestamp | ||
|
||
def __hash__(self: Self) -> int: | ||
return hash((type(self), self.timestamp)) | ||
|
||
highs: list[Reading] = Field(default_factory=list) | ||
averages: list[Reading] = Field(default_factory=list) | ||
lows: list[Reading] = Field(default_factory=list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
__all__ = ["Device", "DeviceEntry", "DeviceInput"] | ||
|
||
from datetime import datetime | ||
from decimal import Decimal | ||
from typing import Self | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class BaseDevice(BaseModel): | ||
name: str | ||
|
||
def __lt__(self: Self, other) -> int: # noqa: ANN001 | ||
if not isinstance(other, BaseDevice): | ||
raise NotImplementedError | ||
return self.name.casefold() < other.name.casefold() | ||
|
||
def __eq__(self: Self, other) -> bool: # noqa: ANN001 | ||
if not isinstance(other, BaseDevice): | ||
raise NotImplementedError | ||
return self.name.casefold() == other.name.casefold() | ||
|
||
def __hash__(self: Self) -> int: | ||
return hash((type(self), self.name.casefold())) | ||
|
||
|
||
class Device(BaseDevice): | ||
class Reading(BaseModel): | ||
id: int # noqa: A003 | ||
timestamp: datetime | ||
temperature: Decimal | ||
humidity: Decimal | ||
|
||
def __lt__(self: Self, other) -> int: # noqa: ANN001 | ||
if not isinstance(other, Device.Reading): | ||
raise NotImplementedError | ||
return self.timestamp < other.timestamp | ||
|
||
def __eq__(self: Self, other) -> bool: # noqa: ANN001 | ||
if not isinstance(other, Device.Reading): | ||
raise NotImplementedError | ||
return self.timestamp == other.timestamp | ||
|
||
def __hash__(self: Self) -> int: | ||
return hash((type(self), self.timestamp)) | ||
|
||
id: int # noqa: A003 | ||
readings: list[Reading] = Field(default_factory=list) | ||
|
||
|
||
class DeviceEntry(BaseDevice): | ||
id: int # noqa: A003 | ||
|
||
|
||
class DeviceInput(BaseDevice): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
__all__ = ["Reading", "ReadingEntry", "ReadingInput"] | ||
|
||
from datetime import datetime | ||
from decimal import Decimal | ||
from typing import Self | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class BaseReading(BaseModel): | ||
temperature: Decimal | ||
humidity: Decimal | ||
|
||
|
||
class Reading(BaseReading): | ||
id: int # noqa: A003 | ||
timestamp: datetime | ||
|
||
def __lt__(self: Self, other) -> int: # noqa: ANN001 | ||
if not isinstance(other, Reading): | ||
raise NotImplementedError | ||
return self.timestamp < other.timestamp | ||
|
||
def __eq__(self: Self, other) -> bool: # noqa: ANN001 | ||
if not isinstance(other, Reading): | ||
raise NotImplementedError | ||
return self.timestamp == other.timestamp | ||
|
||
def __hash__(self: Self) -> int: | ||
return hash((type(self), self.timestamp)) | ||
|
||
|
||
class ReadingEntry(BaseReading): | ||
id: int # noqa: A003 | ||
timestamp: datetime | ||
|
||
def __lt__(self: Self, other) -> int: # noqa: ANN001 | ||
if not isinstance(other, ReadingEntry): | ||
raise NotImplementedError | ||
return self.timestamp < other.timestamp | ||
|
||
def __eq__(self: Self, other) -> bool: # noqa: ANN001 | ||
if not isinstance(other, ReadingEntry): | ||
raise NotImplementedError | ||
return self.timestamp == other.timestamp | ||
|
||
def __hash__(self: Self) -> int: | ||
return hash((type(self), self.timestamp)) | ||
|
||
|
||
class ReadingInput(BaseReading): | ||
pass |
Oops, something went wrong.