Add Venstar runtimes and battery sensors (#60414)

* Venstar: Add runtimes and battery sensors

* Address review - replace classes with lambda functions

* Clean up patch usage, make temperature_unit it's own function

* Remove double define of entities
This commit is contained in:
Tim Rightnour 2021-12-05 09:23:22 -07:00 committed by GitHub
parent bf1cacf4b2
commit dd4ede09c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 124 additions and 45 deletions

View file

@ -60,3 +60,7 @@ class VenstarColorTouchMock:
def update_alerts(self):
"""Mock update_alerts."""
return True
def get_runtimes(self):
"""Mock get runtimes."""
return {}

View file

@ -0,0 +1 @@
{"runtimes":[{"ts":1637452800,"heat1":0,"heat2":0,"cool1":156,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637539200,"heat1":0,"heat2":0,"cool1":216,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637625600,"heat1":0,"heat2":0,"cool1":234,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637712000,"heat1":0,"heat2":0,"cool1":225,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637798400,"heat1":0,"heat2":0,"cool1":153,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637884800,"heat1":0,"heat2":0,"cool1":94,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637921499,"heat1":0,"heat2":0,"cool1":12,"cool2":0,"aux1":0,"aux2":0,"fc":0}]}

View file

@ -0,0 +1 @@
{"runtimes":[{"ts":1637452800,"heat1":0,"heat2":0,"cool1":156,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637539200,"heat1":0,"heat2":0,"cool1":216,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637625600,"heat1":0,"heat2":0,"cool1":234,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637712000,"heat1":0,"heat2":0,"cool1":225,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637798400,"heat1":0,"heat2":0,"cool1":153,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637884800,"heat1":0,"heat2":0,"cool1":94,"cool2":0,"aux1":0,"aux2":0,"fc":0},{"ts":1637921489,"heat1":0,"heat2":0,"cool1":12,"cool2":0,"aux1":0,"aux2":0,"fc":0}]}

View file

@ -20,7 +20,7 @@ EXPECTED_BASE_SUPPORTED_FEATURES = (
async def test_colortouch(hass):
"""Test interfacing with a venstar colortouch with attached humidifier."""
with patch("homeassistant.components.onewire.sensor.asyncio.sleep"):
with patch("homeassistant.components.venstar.VENSTAR_SLEEP", new=0):
await async_init_integration(hass)
state = hass.states.get("climate.colortouch")
@ -56,7 +56,7 @@ async def test_colortouch(hass):
async def test_t2000(hass):
"""Test interfacing with a venstar T2000 presently turned off."""
with patch("homeassistant.components.onewire.sensor.asyncio.sleep"):
with patch("homeassistant.components.venstar.VENSTAR_SLEEP", new=0):
await async_init_integration(hass)
state = hass.states.get("climate.t2000")

View file

@ -37,7 +37,11 @@ async def test_setup_entry(hass: HomeAssistant):
"homeassistant.components.venstar.VenstarColorTouch.update_alerts",
new=VenstarColorTouchMock.update_alerts,
), patch(
"homeassistant.components.onewire.sensor.asyncio.sleep"
"homeassistant.components.venstar.VenstarColorTouch.get_runtimes",
new=VenstarColorTouchMock.get_runtimes,
), patch(
"homeassistant.components.venstar.VENSTAR_SLEEP",
new=0,
):
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
@ -72,6 +76,9 @@ async def test_setup_entry_exception(hass: HomeAssistant):
), patch(
"homeassistant.components.venstar.VenstarColorTouch.update_alerts",
new=VenstarColorTouchMock.update_alerts,
), patch(
"homeassistant.components.venstar.VenstarColorTouch.get_runtimes",
new=VenstarColorTouchMock.get_runtimes,
):
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()