Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New method fetch_metric_data() -> MetricData #61

Merged
merged 6 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ from vallox_websocket_api import Vallox, PROFILE
client = Vallox('192.168.1.10') # Vallox unit IP

async def run():
await client.get_profile() # RETURNS a PROFILE.* value
data = await client.fetch_metric_data()
profile = data.profile # RETURNS a PROFILE.* value
await client.set_profile(PROFILE.HOME) # Permanently HOME profile
await client.set_profile(PROFILE.AWAY) # Permanently AWAY profile
await client.set_profile(PROFILE.FIREPLACE) # FIREPLACE mode for configured timeout
Expand All @@ -103,15 +104,14 @@ Reading metrics and setting values
## Reading Metrics
```python
import asyncio
from vallox_websocket_api import Client
from vallox_websocket_api import Vallox
from pprint import pprint

client = Client('192.168.1.2')
client = Vallox('192.168.1.2')

async def run():
metrics = await client.fetch_metrics()

from pprint import pprint
pprint(metrics)
data = await client.fetch_metric_data()
pprint(data)

asyncio.run(run())
```
Expand All @@ -120,9 +120,9 @@ Or if you want just a subset of metrics:

```python
import asyncio
from vallox_websocket_api import Client
from vallox_websocket_api import Vallox

client = Client('192.168.1.2')
client = Vallox('192.168.1.2')
async def run():
metrics = await client.fetch_metrics([
'A_CYC_TEMP_EXHAUST_AIR',
Expand All @@ -143,9 +143,9 @@ Device stores some historical data in its memory. Code to retrieve it:

```python
import asyncio
from vallox_websocket_api import Client
from vallox_websocket_api import Vallox

client = Client('192.168.1.2')
client = Vallox('192.168.1.2')
async def run():
data = await client.fetch_raw_logs()

Expand All @@ -159,9 +159,9 @@ asyncio.run(run())
Textual values will be converted to integers before sending to the unit.
```python
import asyncio
from vallox_websocket_api import Client
from vallox_websocket_api import Vallox

client = Client('192.168.9.106')
client = Vallox('192.168.9.106')

async def run():
# Setting Home profile fan speed
Expand Down
12 changes: 4 additions & 8 deletions tests/test_vallox_alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

import pytest

from vallox_websocket_api.vallox import Alarm, Vallox


@pytest.fixture
def vallox():
return Vallox("127.0.0.1")
from vallox_websocket_api.vallox import Alarm, MetricData


@pytest.fixture
Expand Down Expand Up @@ -215,8 +210,9 @@ def metrics():
}


async def test_get_info(vallox: Vallox, metrics: dict):
alarms = vallox.get_alarms_from_metrics(metrics, skip_solved=False)
async def test_get_info(metrics: dict):
data = MetricData(metrics)
alarms = data.get_alarms(skip_solved=False)

assert len(alarms) == 1

Expand Down
2 changes: 1 addition & 1 deletion tests/test_vallox_fan_speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ async def test_get_fan_speed_for_profile_home(vallox: Vallox):
vallox.fetch_metrics.return_value = {"A_CYC_HOME_SPEED_SETTING": 19}

assert await vallox.get_fan_speed(PROFILE.HOME) == 19
vallox.fetch_metrics.assert_called_once_with(["A_CYC_HOME_SPEED_SETTING"])
vallox.fetch_metrics.assert_called_once()
9 changes: 1 addition & 8 deletions tests/test_vallox_next_filter_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,4 @@ async def test_nextFilterChangeYesterday(vallox: Vallox):


def assert_filter_metrics_called(vallox):
vallox.fetch_metrics.assert_called_once_with(
[
"A_CYC_FILTER_CHANGED_YEAR",
"A_CYC_FILTER_CHANGED_MONTH",
"A_CYC_FILTER_CHANGED_DAY",
"A_CYC_FILTER_CHANGE_INTERVAL",
]
)
vallox.fetch_metrics.assert_called_once()
9 changes: 1 addition & 8 deletions tests/test_vallox_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,4 @@ async def test_get_profile_extra(vallox: Vallox):


def _assert_profile_metrics_fetched(vallox):
vallox.fetch_metrics.assert_called_once_with(
[
"A_CYC_STATE",
"A_CYC_BOOST_TIMER",
"A_CYC_FIREPLACE_TIMER",
"A_CYC_EXTRA_TIMER",
]
)
vallox.fetch_metrics.assert_called_once()
4 changes: 1 addition & 3 deletions tests/test_vallox_temperatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ async def test_vallox_get_temperature(vallox):
)

assert await vallox.get_temperature(PROFILE.HOME) == 19
vallox.fetch_metrics.assert_called_once_with(
list({"A_CYC_HOME_AIR_TEMP_TARGET": 19}.keys())
)
vallox.fetch_metrics.assert_called_once()


async def test_vallox_fetch_metric(vallox, ws):
Expand Down
Loading
Loading