Skip to content

Commit

Permalink
Update to HA 2024.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbkarlsson authored Jun 6, 2024
1 parent cd24158 commit 5c28a11
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 6 deletions.
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
homeassistant==2024.4.3
homeassistant==2024.6.0
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pytest-homeassistant-custom-component==0.13.114
pytest-homeassistant-custom-component==0.13.132
2 changes: 1 addition & 1 deletion requirements_test312.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pytest-homeassistant-custom-component==0.13.114
pytest-homeassistant-custom-component==0.13.132
11 changes: 10 additions & 1 deletion scripts/pytest_all_ha_versions_python312
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,14 @@ pip3 install -qq homeassistant==2024.3.3 pytest-homeassistant-custom-component==
run_next_test "auto"

# As of HA 2024.4, Python 3.11 is not supported.
pip3 install -qq homeassistant==2024.4.3 pytest-homeassistant-custom-component==0.13.114

#pip3 install -qq homeassistant==2024.4.4 pytest-homeassistant-custom-component==0.13.115
#run_next_test "auto"
# Depends on non-existng version of mypy-dev

#pip3 install -qq homeassistant==2024.5.5 pytest-homeassistant-custom-component==0.13.125
#run_next_test "auto"
# Depends on non-existng version of mypy-dev

pip3 install -qq homeassistant==2024.6.0 pytest-homeassistant-custom-component==0.13.132
run_next_test "auto"
2 changes: 2 additions & 0 deletions scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

sudo chown -R vscode:vscode /workspaces

cd "$(dirname "$0")/.."

python3 -m pip install --requirement requirements_dev.txt
Expand Down
103 changes: 101 additions & 2 deletions tests/coordinator/test_coordinator_keep_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,56 @@ async def test_coordinator_keep_on4(
assert coordinator.auto_charging_state == STATE_ON
assert coordinator.sensor.state == STATE_ON

# Move back time to recreate the schedule
# Unsubscribe to listeners
coordinator.unsubscribe_listeners()


async def test_coordinator_keep_on4b(
hass: HomeAssistant, skip_service_calls, set_cet_timezone, freezer
):
"""Test Coordinator."""

freezer.move_to("2022-09-30T14:00:00+02:00")

entity_registry: EntityRegistry = async_entity_registry_get(hass)
MockSOCEntity.create(hass, entity_registry, "40")
MockTargetSOCEntity.create(hass, entity_registry, "80")
MockPriceEntity.create(hass, entity_registry, 123)
MockChargerEntity.create(hass, entity_registry, STATE_OFF)

# Test with max price 0.0 and 6.0 PCT/h.
# This should give 7h charging, 02-09, or 23-00 + 03-09
# Test "if self.ev_soc >= self.ev_target_soc:"

config_entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_CONFIG_KEEP_ON1, entry_id="test"
)
config_entry.add_to_hass(hass)
coordinator = EVSmartChargingCoordinator(hass, config_entry)
assert coordinator is not None

sensor: EVSmartChargingSensorCharging = EVSmartChargingSensorCharging(config_entry)
assert sensor is not None
await coordinator.add_sensor([sensor])

# Provide price
MockPriceEntity.set_state(hass, PRICE_20220930, PRICE_20221001)
await coordinator.update_sensors()
await hass.async_block_till_done()
assert coordinator.tomorrow_valid

# Turn on switches
await coordinator.switch_active_update(True)
await coordinator.switch_apply_limit_update(False)
await coordinator.switch_continuous_update(True)
await coordinator.switch_ev_connected_update(True)
await coordinator.switch_keep_on_update(False)
await hass.async_block_till_done()

assert coordinator.auto_charging_state == STATE_OFF
assert coordinator.sensor.state == STATE_OFF

# Move time and turn on keep on
freezer.move_to("2022-09-30T20:00:00+02:00")
MockPriceEntity.set_state(hass, PRICE_20220930, PRICE_20221001)
MockSOCEntity.set_state(hass, "40")
Expand Down Expand Up @@ -722,7 +771,57 @@ async def test_coordinator_keep_on6(
assert coordinator.auto_charging_state == STATE_ON
assert coordinator.sensor.state == STATE_ON

# Move back time to recreate the schedule
# Unsubscribe to listeners
coordinator.unsubscribe_listeners()


async def test_coordinator_keep_on6b(
hass: HomeAssistant, skip_service_calls, set_cet_timezone, freezer
):
"""Test Coordinator."""

freezer.move_to("2022-09-30T14:00:00+02:00")

entity_registry: EntityRegistry = async_entity_registry_get(hass)
MockSOCEntity.create(hass, entity_registry, "40")
MockTargetSOCEntity.create(hass, entity_registry, "80")
MockPriceEntity.create(hass, entity_registry, 123)
MockChargerEntity.create(hass, entity_registry, STATE_OFF)

# Test with max price 0.0 and 6.0 PCT/h.
# For the case with non-continuous charging
# This should give 7h charging, 02-09, or 23-00 + 03-09
# Test "if self.ev_soc >= self.ev_target_soc:"

config_entry = MockConfigEntry(
domain=DOMAIN, data=MOCK_CONFIG_KEEP_ON1, entry_id="test"
)
config_entry.add_to_hass(hass)
coordinator = EVSmartChargingCoordinator(hass, config_entry)
assert coordinator is not None

sensor: EVSmartChargingSensorCharging = EVSmartChargingSensorCharging(config_entry)
assert sensor is not None
await coordinator.add_sensor([sensor])

# Provide price
MockPriceEntity.set_state(hass, PRICE_20220930, PRICE_20221001)
await coordinator.update_sensors()
await hass.async_block_till_done()
assert coordinator.tomorrow_valid

# Turn on switches
await coordinator.switch_active_update(True)
await coordinator.switch_apply_limit_update(False)
await coordinator.switch_continuous_update(False)
await coordinator.switch_ev_connected_update(True)
await coordinator.switch_keep_on_update(True)
await hass.async_block_till_done()

assert coordinator.auto_charging_state == STATE_OFF
assert coordinator.sensor.state == STATE_OFF

# Move time
freezer.move_to("2022-09-30T20:00:00+02:00")
MockPriceEntity.set_state(hass, PRICE_20220930, PRICE_20221001)
MockSOCEntity.set_state(hass, "40")
Expand Down

0 comments on commit 5c28a11

Please sign in to comment.