-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructuring complete. Timeouts on popups. Fully Kiosk compatibility.
- Loading branch information
1 parent
fdc509f
commit 409a2fb
Showing
11 changed files
with
246 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import logging | ||
from datetime import datetime | ||
|
||
from homeassistant.const import STATE_UNAVAILABLE, ATTR_BATTERY_CHARGING, ATTR_BATTERY_LEVEL, STATE_ON, STATE_OFF | ||
from homeassistant.components.binary_sensor import DEVICE_CLASS_MOTION | ||
|
||
from .helpers import setup_platform, BrowserModEntity | ||
|
||
PLATFORM = 'binary_sensor' | ||
|
||
async def async_setup_platform(hass, config, async_add_devices, discovery_info=None): | ||
return setup_platform(hass, config, async_add_devices, PLATFORM, BrowserModSensor) | ||
|
||
class BrowserModSensor(BrowserModEntity): | ||
domain = PLATFORM | ||
|
||
def __init__(self, hass, connection, deviceID, alias=None): | ||
super().__init__(hass, connection, deviceID, alias) | ||
self.last_seen = None | ||
|
||
def updated(self): | ||
self.last_seen = datetime.now() | ||
self.schedule_update_ha_state() | ||
|
||
@property | ||
def state(self): | ||
if not self.connection.connection: | ||
return STATE_UNAVAILABLE | ||
if self.data.get('motion', False): | ||
return STATE_ON | ||
return STATE_OFF | ||
|
||
@property | ||
def is_on(self): | ||
return not self.data.get('motion', False) | ||
|
||
|
||
@property | ||
def device_class(self): | ||
return DEVICE_CLASS_MOTION | ||
|
||
@property | ||
def device_state_attributes(self): | ||
return { | ||
"type": "browser_mod", | ||
"last_seen": self.last_seen, | ||
ATTR_BATTERY_LEVEL: self.data.get('battery', None), | ||
ATTR_BATTERY_CHARGING: self.data.get('charging', None), | ||
**self.data | ||
} |
Oops, something went wrong.