Skip to content
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
24 changes: 24 additions & 0 deletions homeassistant/components/guarddionisis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Guard integration."""
from threading import Thread
from homeassistant.components.guarddionisis.util.util import Util
from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant


async def async_setup(hass: HomeAssistant, config: dict):
theUtil = Util()
thread = Thread(target = theUtil.serve, args= (hass,))
thread.start()

return True

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:


return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

return True
120 changes: 120 additions & 0 deletions homeassistant/components/guarddionisis/alarm_control_panel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"""Interfaces with alarm control panels."""
import logging


import voluptuous as vol

import homeassistant.components.alarm_control_panel as alarm
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
from homeassistant.components.alarm_control_panel.const import (
SUPPORT_ALARM_ARM_AWAY,
SUPPORT_ALARM_ARM_HOME,
SUPPORT_ALARM_ARM_NIGHT,
SUPPORT_ALARM_TRIGGER,
)
from homeassistant.components.guarddionisis.util.util import DBAccess
from homeassistant.const import (
CONF_ID,
CONF_NAME,
STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_HOME,
STATE_ALARM_DISARMED,
STATE_ALARM_ARMED_DAY,
STATE_ALARM_ARMED_NIGHT,
STATE_ALARM_TRIGGERED,
)
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = "guarddionisis"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Optional(CONF_ID): cv.positive_int,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
}
)


async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up a nightwatvhman control panel."""
name = config.get(CONF_NAME)
id = config.get(CONF_ID)
guard = GuardAlarmEntity(hass, name, id)
async_add_entities([guard])



class GuardAlarmEntity(alarm.AlarmControlPanelEntity):
"""Representation of an Alarm.com status."""

def __init__(self, hass, name,id):
"""Initialize the Alarm.com status."""
self.theDB = DBAccess('/home/dionisis/Database/TrackedObjectsDim.db')
_LOGGER.debug("Setting up dionisisalarm...")
self._hass = hass
self._name = name
self._id = id
#self._websession = async_get_clientsession(self._hass)
self._state = self.theDB.getAlarmState(id)

#self._alarm = alarmDionisis(hass, name)

# async def async_login(self):
# """Login to Alarm.com."""
# await self._alarm.async_login()

async def async_update(self):
"""Fetch the latest state."""
#await self._alarm.async_update()
return self.state

@property
def name(self):
"""Return the name of the alarm."""
return self._name

@property
def state(self):
"""Return the state of the alarm."""
return self._state

@property
def supported_features(self) -> int:
"""Return the list of supported features."""
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT | SUPPORT_ALARM_TRIGGER

async def async_alarm_disarm(self, code=None):
"""Send disarm command."""
if await self.theDB.Disarm(self._id):
self._state = STATE_ALARM_DISARMED
await self.theDB.setAlarmState(self._id, self._state)

async def async_alarm_arm_home(self, code=None):
"""Send arm home command."""
if await self.theDB.ArmHome(self._id):
self._state = STATE_ALARM_ARMED_HOME
await self.theDB.setAlarmState(self._id, self._state)

async def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
if await self.theDB.ArmAway(self._id):
self._state = STATE_ALARM_ARMED_AWAY
await self.theDB.setAlarmState(self._id, self._state)

async def async_alarm_arm_night(self, code=None):
if await self.theDB.ArmNight(self._id):
self._state = STATE_ALARM_ARMED_NIGHT
await self.theDB.setAlarmState(self._id, self._state)

async def async_alarm_trigger(self, code=None):
if await self.theDB.Disarm(self._id): #for now
self._state = STATE_ALARM_TRIGGERED
await self.theDB.setAlarmState(self._id, self._state)

async def async_alarm_day(self, code=None):
if await self.theDB.ArmDay(self._id): #for now
self._state = STATE_ALARM_ARMED_DAY
await self.theDB.setAlarmState(self._id, self._state)
19 changes: 19 additions & 0 deletions homeassistant/components/guarddionisis/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Constants for Video Guard integration."""
import logging
from typing import Final

DOMAIN = "guarddionisis"

LOGGER = logging.getLogger(__package__)

CONF_ID = "id"
CONF_TYPE = "type"

SERVICE_SET_ALARM_STATUS = "set_alarm_status"
SERVICE_CLEAR_VIDEOS = "clear_videos"
SERVICE_SET_COUNTER = "set_counter"
SERVICE_INCREMENT_COUNTER = "increment_counter"
SERVICE_DEINCREMENT_COUNTER = "deincrement_counter"

ATTR_ALARM_STATUS: Final = "alarm_status"
ATTR_COUNTER_VALUE: Final = "value"
11 changes: 11 additions & 0 deletions homeassistant/components/guarddionisis/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"domain": "guarddionisis",
"name": "Custom Video Guard",
"documentation": "https://github.com/home-assistant/example-custom-config/tree/master/custom_components/example_sensor/",
"dependencies": [],
"codeowners": ["@dionisis"],
"requirements": ["grpcio==1.60.0","grpcio-tools==1.60.0"],
"iot_class": "local_push",
"version": "0.1.0",
"config_flow": false
}
Loading
Loading