Skip to content

Commit 66ec13c

Browse files
committed
tests pass and updates to docs after first pdf export read
1 parent 17a06d6 commit 66ec13c

3 files changed

Lines changed: 35 additions & 8 deletions

File tree

‎open_fdd/platform/drivers/bacnet.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ async def scrape_bacnet_from_csv(
353353
}
354354

355355
logger.info("BACnet scrape via RPC: %s (site=%s)", server_url, site_id)
356-
return await _scrape_via_rpc(csv_path, site_id, config_rows, by_device, server_url=server_url)
356+
return await _scrape_via_rpc(
357+
csv_path, site_id, config_rows, by_device, server_url=server_url
358+
)
357359

358360

359361
def run_bacnet_scrape(

‎open_fdd/tests/engine/test_weather_rules.py‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
"""Tests for weather fault rules."""
22

3+
from pathlib import Path
4+
35
import pandas as pd
46
import pytest
57

68
from open_fdd.engine import RuleRunner
7-
from pathlib import Path
9+
10+
# Weather rules use Brick class names; test DataFrame uses Open-Meteo column names.
11+
# Pass this column_map so the runner resolves Brick -> actual df columns.
12+
WEATHER_COLUMN_MAP = {
13+
"Humidity_Sensor": "rh_pct",
14+
"Wind_Gust_Speed_Sensor": "gust_mph",
15+
"Wind_Speed_Sensor": "wind_mph",
16+
"Outside_Air_Temperature_Sensor": "temp_f",
17+
}
818

919

1020
@pytest.fixture
@@ -43,6 +53,7 @@ def test_weather_rules_load(weather_df):
4353
"tolerance": 0.2,
4454
"window": 6,
4555
},
56+
column_map=WEATHER_COLUMN_MAP,
4657
skip_missing_columns=True,
4758
)
4859
assert "fault_rh_out_of_range" in result.columns
@@ -59,11 +70,19 @@ def test_weather_rh_out_of_range(weather_df):
5970
r for r in runner._rules if r.get("name") == "weather_rh_out_of_range"
6071
]
6172

62-
result = runner.run(weather_df, params={"rh_min": 0, "rh_max": 100})
73+
result = runner.run(
74+
weather_df,
75+
params={"rh_min": 0, "rh_max": 100},
76+
column_map=WEATHER_COLUMN_MAP,
77+
)
6378
# All rh in 50-86, within [0,100]
6479
assert result["fault_rh_out_of_range"].sum() == 0
6580

66-
result2 = runner.run(weather_df, params={"rh_min": 70, "rh_max": 85})
81+
result2 = runner.run(
82+
weather_df,
83+
params={"rh_min": 70, "rh_max": 85},
84+
column_map=WEATHER_COLUMN_MAP,
85+
)
6786
# Some rh < 70 or > 85
6887
assert result2["fault_rh_out_of_range"].sum() > 0
6988

@@ -81,5 +100,5 @@ def test_weather_gust_lt_wind(weather_df):
81100
r for r in runner._rules if r.get("name") == "weather_gust_lt_wind"
82101
]
83102

84-
result = runner.run(df)
103+
result = runner.run(df, column_map=WEATHER_COLUMN_MAP)
85104
assert result["fault_gust_lt_wind"].sum() >= 2

‎tools/run_bacnet_scrape.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ def main() -> int:
108108
log.warning("Gateway CSV not found: %s", csv_path)
109109
continue
110110
try:
111-
result = run_bacnet_scrape(csv_path, site_id, "bacnet", server_url=url)
111+
result = run_bacnet_scrape(
112+
csv_path, site_id, "bacnet", server_url=url
113+
)
112114
except Exception as e:
113115
log.exception("Gateway %s failed: %s", site_id, e)
114116
continue
@@ -162,7 +164,9 @@ def main() -> int:
162164
)
163165
while True:
164166
try:
165-
result = run_bacnet_scrape(csv_path, site_id, server_url=settings.bacnet_server_url)
167+
result = run_bacnet_scrape(
168+
csv_path, site_id, server_url=settings.bacnet_server_url
169+
)
166170
log.info(
167171
"Scrape cycle: %d rows, %d points, %d errors",
168172
result["rows_inserted"],
@@ -173,7 +177,9 @@ def main() -> int:
173177
log.exception("Scrape failed: %s", e)
174178
time.sleep(interval_sec)
175179
else:
176-
result = run_bacnet_scrape(csv_path, site_id, server_url=settings.bacnet_server_url)
180+
result = run_bacnet_scrape(
181+
csv_path, site_id, server_url=settings.bacnet_server_url
182+
)
177183
if result["errors"] and result["rows_inserted"] == 0:
178184
for e in result["errors"]:
179185
log.error("%s", e)

0 commit comments

Comments
 (0)