10000 SPC: Fix recorder/history graph by mbrrg · Pull Request #17220 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

SPC: Fix recorder/history graph #17220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions homeassistant/components/alarm_control_panel/spc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import homeassistant.components.alarm_control_panel as alarm
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.core import callback
from homeassistant.components.spc import (
ATTR_DISCOVER_AREAS, DATA_API, SIGNAL_UPDATE_ALARM)
from homeassistant.components.spc import (DATA_API, SIGNAL_UPDATE_ALARM)
from homeassistant.const import (
STATE_ALARM_ARMED_AWAY, ST 8000 ATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT,
STATE_ALARM_DISARMED, STATE_ALARM_TRIGGERED)
Expand All @@ -37,12 +36,9 @@ def _get_alarm_state(area):
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the SPC alarm control panel platform."""
if (discovery_info is None or
discovery_info[ATTR_DISCOVER_AREAS] is None):
return

async_add_entities([SpcAlarm(area=area, api=hass.data[DATA_API])
for area in discovery_info[ATTR_DISCOVER_AREAS]])
api = hass.data[DATA_API]
async_add_entities([SpcAlarm(area=area, api=api)
for area in api.areas.values()])


class SpcAlarm(alarm.AlarmControlPanel):
Expand Down
14 changes: 5 additions & 9 deletions homeassistant/components/binary_sensor/spc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.core import callback
from homeassistant.components.spc import (
ATTR_DISCOVER_DEVICES, SIGNAL_UPDATE_SENSOR)
from homeassistant.components.spc import (DATA_API, SIGNAL_UPDATE_SENSOR)

_LOGGER = logging.getLogger(__name__)

Expand All @@ -27,13 +26,10 @@ def _get_device_class(zone_type):
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the SPC binary sensor."""
if (discovery_info is None or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should still guard from no discovery_info.

discovery_info[ATTR_DISCOVER_DEVICES] is None):
return

async_add_entities(SpcBinarySensor(zone)
for zone in discovery_info[ATTR_DISCOVER_DEVICES]
if _get_device_class(zone.type))
api = hass.data[DATA_API]
async_add_entities([SpcBinarySensor(zone)
for zone in api.zones.values()
if _get_device_class(zone.type)])


class SpcBinarySensor(BinarySensorDevice):
Expand Down
9 changes: 2 additions & 7 deletions homeassistant/components/spc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

_LOGGER = logging.getLogger(__name__)

ATTR_DISCOVER_DEVICES = 'devices'
ATTR_DISCOVER_AREAS = 'areas'

CONF_WS_URL = 'ws_url'
CONF_API_URL = 'api_url'

Expand Down Expand Up @@ -66,13 +63,11 @@ async def async_upate_callback(spc_object):

# add sensor devices for each zone (typically motion/fire/door sensors)
hass.async_create_task(discovery.async_load_platform(
hass, 'binary_sensor', DOMAIN,
{ATTR_DISCOVER_DEVICES: spc.zones.values()}, config))
hass, 'binary_sensor', DOMAIN))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send an empty dict as discovery_info.


# create a separate alarm panel for each area
hass.async_create_task(discovery.async_load_platform(
hass, 'alarm_control_panel', DOMAIN,
{ATTR_DISCOVER_AREAS: spc.areas.values()}, config))
hass, 'alarm_control_panel', DOMAIN))

# start listening for incoming events over websocket
spc.start()
Expand Down
58 changes: 0 additions & 58 deletions tests/components/alarm_control_panel/test_spc.py

This file was deleted.

55 changes: 0 additions & 55 deletions tests/components/binary_sensor/test_spc.py

This file was deleted.

3 changes: 2 additions & 1 deletion tests/components/test_spc.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ async def test_update_alarm_device(hass):
return_value=mock_coro(True)):
assert await async_setup_component(hass, 'spc', config) is True

await hass.async_block_till_done()
await hass.async_block_till_done()

entity_id = 'alarm_control_panel.house'

assert hass.states.get(entity_id).state == STATE_ALARM_ARMED_AWAY
Expand Down
0