Skip to content

Commit

Permalink
Merge pull request #42 from D34DC3N73R/D34DC3N73R-async_patch
Browse files Browse the repository at this point in the history
Fix async, fix team_colors_"RGB"
  • Loading branch information
zacs authored May 9, 2023
2 parents b51cc3b + 0025d13 commit 5e8805d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
Expand All @@ -23,10 +23,10 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements_test.txt
pip install --upgrade -r requirements_test.txt
- name: Generate coverage report
run: |
python -m pytest
python -m pytest --asyncio-mode=auto
pip install pytest-cov
pytest ./tests/ --cov=custom_components/nfl/ --cov-report=xml
- name: Upload coverage to Codecov
Expand Down
4 changes: 2 additions & 2 deletions blueprints/nfl-game-score-lights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ action:
sequence:
- service: light.turn_on
data:
rgb_color: "{{ state_attr(trigger.entity_id, 'team_colors_rbg')[0] if (trigger.id != 'oppo_score') else state_attr(trigger.entity_id, 'opponent_colors_rgb')[0] }}"
rgb_color: "{{ state_attr(trigger.entity_id, 'team_colors_rgb')[0] if (trigger.id != 'oppo_score') else state_attr(trigger.entity_id, 'opponent_colors_rgb')[0] }}"
target:
entity_id: !input light_targets
- delay:
Expand All @@ -79,7 +79,7 @@ action:
milliseconds: 0
- service: light.turn_on
data:
rgb_color: "{{ state_attr(trigger.entity_id, 'team_colors_rbg')[1] if (trigger.id != 'oppo_score') else state_attr(trigger.entity_id, 'opponent_colors_rgb')[1] }}"
rgb_color: "{{ state_attr(trigger.entity_id, 'team_colors_rgb')[1] if (trigger.id != 'oppo_score') else state_attr(trigger.entity_id, 'opponent_colors_rgb')[1] }}"
target:
entity_id: !input light_targets
- delay:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/nfl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
COORDINATOR: coordinator,
}

hass.config_entries.async_setup_platforms(entry, PLATFORMS)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True


Expand Down
2 changes: 1 addition & 1 deletion custom_components/nfl/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def extra_state_attributes(self):
attrs["team_homeaway"] = self.coordinator.data["team_homeaway"]
attrs["team_logo"] = self.coordinator.data["team_logo"]
attrs["team_colors"] = self.coordinator.data["team_colors"]
attrs["team_colors_rbg"] = self.team_colors(self.coordinator.data["team_colors"])
attrs["team_colors_rgb"] = self.team_colors(self.coordinator.data["team_colors"])
attrs["team_score"] = self.coordinator.data["team_score"]
attrs["team_win_probability"] = self.coordinator.data["team_win_probability"]
attrs["team_timeouts"] = self.coordinator.data["team_timeouts"]
Expand Down
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
black
isort
pytest
pytest-asyncio
pytest-cov
pytest-homeassistant-custom-component
arrow
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Fixtures for tests"""
import pytest
import asyncio

pytest_plugins = "pytest_homeassistant_custom_component"
pytest_plugins = ("pytest_homeassistant_custom_component", "pytest_asyncio")


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit 5e8805d

Please sign in to comment.