Add config entry and device support to Demo (#28702)

* Add config entry and device support to Demo

* Some more devices

* Fix tests using demo

* Review comments

* Update config_flow.py

* Revert

* Disable pylint
This commit is contained in:
Bram Kragten authored and GitHub committed 2019-11-13 16:37:31 +01:00
1 parent 15ce738357
commit 15e6278a2e
21 files changed
+305 -54

No files matched your search

@@ -498,6 +498,7 @@ async def test_unavailable_state_doesnt_sync(hass):
async def test_device_class_switch(hass, device_class, google_type):
"""Test that a cover entity syncs to the correct device type."""
sensor = DemoSwitch(
None,
"Demo Sensor",
state=False,
icon="mdi:switch",
@@ -545,7 +546,9 @@ async def test_device_class_switch(hass, device_class, google_type):
)
async def test_device_class_binary_sensor(hass, device_class, google_type):
"""Test that a binary entity syncs to the correct device type."""
sensor = DemoBinarySensor("Demo Sensor", state=False, device_class=device_class)
sensor = DemoBinarySensor(
None, "Demo Sensor", state=False, device_class=device_class
)
sensor.hass = hass
sensor.entity_id = "binary_sensor.demo_sensor"
await sensor.async_update_ha_state()
@@ -585,7 +588,7 @@ async def test_device_class_binary_sensor(hass, device_class, google_type):
)
async def test_device_class_cover(hass, device_class, google_type):
"""Test that a binary entity syncs to the correct device type."""
sensor = DemoCover(hass, "Demo Sensor", device_class=device_class)
sensor = DemoCover(None, hass, "Demo Sensor", device_class=device_class)
sensor.hass = hass
sensor.entity_id = "cover.demo_sensor"
await sensor.async_update_ha_state()
+6 -4
View File
@@ -24,24 +24,26 @@ async def prometheus_client(loop, hass, hass_client):
hass, climate.DOMAIN, {"climate": [{"platform": "demo"}]}
)
sensor1 = DemoSensor("Television Energy", 74, None, ENERGY_KILO_WATT_HOUR, None)
sensor1 = DemoSensor(
None, "Television Energy", 74, None, ENERGY_KILO_WATT_HOUR, None
)
sensor1.hass = hass
sensor1.entity_id = "sensor.television_energy"
await sensor1.async_update_ha_state()
sensor2 = DemoSensor(
"Radio Energy", 14, DEVICE_CLASS_POWER, ENERGY_KILO_WATT_HOUR, None
None, "Radio Energy", 14, DEVICE_CLASS_POWER, ENERGY_KILO_WATT_HOUR, None
)
sensor2.hass = hass
sensor2.entity_id = "sensor.radio_energy"
await sensor2.async_update_ha_state()
sensor3 = DemoSensor("Electricity price", 0.123, None, "SEK/kWh", None)
sensor3 = DemoSensor(None, "Electricity price", 0.123, None, "SEK/kWh", None)
sensor3.hass = hass
sensor3.entity_id = "sensor.electricity_price"
await sensor3.async_update_ha_state()
sensor4 = DemoSensor("Wind Direction", 25, None, "°", None)
sensor4 = DemoSensor(None, "Wind Direction", 25, None, "°", None)
sensor4.hass = hass
sensor4.entity_id = "sensor.wind_direction"
await sensor4.async_update_ha_state()