Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…andy into main
  • Loading branch information
terminet85 committed Oct 13, 2021
2 parents f6c5f8b + 1791cbe commit e973c10
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Run tests

on: [push]
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
test:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/validate_hacs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Validate HACS

on:
pull_request:
branches:
- main

jobs:
validate:
Expand Down
3 changes: 2 additions & 1 deletion custom_components/candy/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def extra_state_attributes(self) -> Mapping[str, Any]:
"program": status.program,
"temperature": status.temp,
"spin_speed": status.spin_speed,
"remaining_minutes": status.remaining_minutes,
"remaining_minutes": status.remaining_minutes if status.machine_state in [MachineState.RUNNING,
MachineState.PAUSED] else 0,
"remote_control": status.remote_control,
}

Expand Down
18 changes: 16 additions & 2 deletions tests/test_sensor_washing_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def test_main_sensor_idle(hass: HomeAssistant, aioclient_mock: AiohttpClie
'program': 1,
'temperature': 40,
'spin_speed': 800,
'remaining_minutes': 39,
'remaining_minutes': 0,
'remote_control': True,
'fill_percent': 0,
'friendly_name': 'Washing machine',
Expand Down Expand Up @@ -53,6 +53,20 @@ async def test_remaining_time_sensor_wash(hass: HomeAssistant, aioclient_mock: A
}


async def test_remaining_time_sensor_idle(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker):
await init_integration(hass, aioclient_mock, load_fixture("washing_machine/idle.json"))

state = hass.states.get("sensor.wash_cycle_remaining_time")

assert state
assert state.state == "0"
assert state.attributes == {
"friendly_name": "Wash cycle remaining time",
"icon": "mdi:progress-clock",
"unit_of_measurement": "min",
}


async def test_main_sensor_no_fillr(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker):
await init_integration(hass, aioclient_mock, load_fixture("washing_machine/no_fillr.json"))

Expand All @@ -64,7 +78,7 @@ async def test_main_sensor_no_fillr(hass: HomeAssistant, aioclient_mock: Aiohttp
'program': 4,
'temperature': 40,
'spin_speed': 1000,
'remaining_minutes': 1,
'remaining_minutes': 0,
'remote_control': False,
'friendly_name': 'Washing machine',
'icon': 'mdi:washing-machine'
Expand Down

0 comments on commit e973c10

Please sign in to comment.