commit
015cdd155c
7 changed files with 47 additions and 33 deletions
|
@ -58,7 +58,8 @@ CONFIG_SCHEMA = vol.Schema({
|
|||
vol.Required(ATTR_PHONE): cv.string,
|
||||
vol.Required(ATTR_ADDRESS): cv.string,
|
||||
vol.Optional(ATTR_SHOW_MENU): cv.boolean,
|
||||
vol.Optional(ATTR_ORDERS): vol.All(cv.ensure_list, [_ORDERS_SCHEMA]),
|
||||
vol.Optional(ATTR_ORDERS, default=[]): vol.All(
|
||||
cv.ensure_list, [_ORDERS_SCHEMA]),
|
||||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
@ -81,7 +82,8 @@ def setup(hass, config):
|
|||
order = DominosOrder(order_info, dominos)
|
||||
entities.append(order)
|
||||
|
||||
component.add_entities(entities)
|
||||
if entities:
|
||||
component.add_entities(entities)
|
||||
|
||||
# Return boolean to indicate that initialization was successfully.
|
||||
return True
|
||||
|
@ -93,7 +95,8 @@ class Dominos():
|
|||
def __init__(self, hass, config):
|
||||
"""Set up main service."""
|
||||
conf = config[DOMAIN]
|
||||
from pizzapi import Address, Customer, Store
|
||||
from pizzapi import Address, Customer
|
||||
from pizzapi.address import StoreException
|
||||
self.hass = hass
|
||||
self.customer = Customer(
|
||||
conf.get(ATTR_FIRST_NAME),
|
||||
|
@ -105,7 +108,10 @@ class Dominos():
|
|||
*self.customer.address.split(','),
|
||||
country=conf.get(ATTR_COUNTRY))
|
||||
self.country = conf.get(ATTR_COUNTRY)
|
||||
self.closest_store = Store()
|
||||
try:
|
||||
self.closest_store = self.address.closest_store()
|
||||
except StoreException:
|
||||
self.closest_store = None
|
||||
|
||||
def handle_order(self, call):
|
||||
"""Handle ordering pizza."""
|
||||
|
@ -123,29 +129,31 @@ class Dominos():
|
|||
from pizzapi.address import StoreException
|
||||
try:
|
||||
self.closest_store = self.address.closest_store()
|
||||
return True
|
||||
except StoreException:
|
||||
self.closest_store = False
|
||||
self.closest_store = None
|
||||
return False
|
||||
|
||||
def get_menu(self):
|
||||
"""Return the products from the closest stores menu."""
|
||||
if self.closest_store is False:
|
||||
if self.closest_store is None:
|
||||
_LOGGER.warning('Cannot get menu. Store may be closed')
|
||||
return
|
||||
return []
|
||||
else:
|
||||
menu = self.closest_store.get_menu()
|
||||
product_entries = []
|
||||
|
||||
menu = self.closest_store.get_menu()
|
||||
product_entries = []
|
||||
for product in menu.products:
|
||||
item = {}
|
||||
if isinstance(product.menu_data['Variants'], list):
|
||||
variants = ', '.join(product.menu_data['Variants'])
|
||||
else:
|
||||
variants = product.menu_data['Variants']
|
||||
item['name'] = product.name
|
||||
item['variants'] = variants
|
||||
product_entries.append(item)
|
||||
|
||||
for product in menu.products:
|
||||
item = {}
|
||||
if isinstance(product.menu_data['Variants'], list):
|
||||
variants = ', '.join(product.menu_data['Variants'])
|
||||
else:
|
||||
variants = product.menu_data['Variants']
|
||||
item['name'] = product.name
|
||||
item['variants'] = variants
|
||||
product_entries.append(item)
|
||||
|
||||
return product_entries
|
||||
return product_entries
|
||||
|
||||
|
||||
class DominosProductListView(http.HomeAssistantView):
|
||||
|
@ -192,7 +200,7 @@ class DominosOrder(Entity):
|
|||
@property
|
||||
def state(self):
|
||||
"""Return the state either closed, orderable or unorderable."""
|
||||
if self.dominos.closest_store is False:
|
||||
if self.dominos.closest_store is None:
|
||||
return 'closed'
|
||||
else:
|
||||
return 'orderable' if self._orderable else 'unorderable'
|
||||
|
@ -217,6 +225,11 @@ class DominosOrder(Entity):
|
|||
def order(self):
|
||||
"""Create the order object."""
|
||||
from pizzapi import Order
|
||||
from pizzapi.address import StoreException
|
||||
|
||||
if self.dominos.closest_store is None:
|
||||
raise StoreException
|
||||
|
||||
order = Order(
|
||||
self.dominos.closest_store,
|
||||
self.dominos.customer,
|
||||
|
|
|
@ -23,7 +23,7 @@ from homeassistant.const import CONF_NAME, EVENT_THEMES_UPDATED
|
|||
from homeassistant.core import callback
|
||||
from homeassistant.loader import bind_hass
|
||||
|
||||
REQUIREMENTS = ['home-assistant-frontend==20171130.0', 'user-agents==1.1.0']
|
||||
REQUIREMENTS = ['home-assistant-frontend==20171204.0', 'user-agents==1.1.0']
|
||||
|
||||
DOMAIN = 'frontend'
|
||||
DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log']
|
||||
|
|
|
@ -264,7 +264,7 @@ class iOSIdentifyDeviceView(HomeAssistantView):
|
|||
# return self.json_message(humanize_error(request.json, ex),
|
||||
# HTTP_BAD_REQUEST)
|
||||
|
||||
data[ATTR_LAST_SEEN_AT] = datetime.datetime.now()
|
||||
data[ATTR_LAST_SEEN_AT] = datetime.datetime.now().isoformat()
|
||||
|
||||
name = data.get(ATTR_DEVICE_ID)
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@ Notifications for Android TV notification service.
|
|||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/notify.nfandroidtv/
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
import io
|
||||
import base64
|
||||
|
||||
import requests
|
||||
import voluptuous as vol
|
||||
|
@ -31,6 +32,9 @@ DEFAULT_TRANSPARENCY = 'default'
|
|||
DEFAULT_COLOR = 'grey'
|
||||
DEFAULT_INTERRUPT = False
|
||||
DEFAULT_TIMEOUT = 5
|
||||
DEFAULT_ICON = (
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApo'
|
||||
'cMXEAAAAASUVORK5CYII=')
|
||||
|
||||
ATTR_DURATION = 'duration'
|
||||
ATTR_POSITION = 'position'
|
||||
|
@ -110,16 +114,13 @@ class NFAndroidTVNotificationService(BaseNotificationService):
|
|||
self._default_color = color
|
||||
self._default_interrupt = interrupt
|
||||
self._timeout = timeout
|
||||
self._icon_file = os.path.join(
|
||||
os.path.dirname(__file__), '..', 'frontend', 'www_static', 'icons',
|
||||
'favicon-192x192.png')
|
||||
self._icon_file = io.BytesIO(base64.b64decode(DEFAULT_ICON))
|
||||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a message to a Android TV device."""
|
||||
_LOGGER.debug("Sending notification to: %s", self._target)
|
||||
|
||||
payload = dict(filename=('icon.png',
|
||||
open(self._icon_file, 'rb'),
|
||||
payload = dict(filename=('icon.png', self._icon_file,
|
||||
'application/octet-stream',
|
||||
{'Expires': '0'}), type='0',
|
||||
title=kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT),
|
||||
|
@ -129,7 +130,7 @@ class NFAndroidTVNotificationService(BaseNotificationService):
|
|||
transparency='%i' % TRANSPARENCIES.get(
|
||||
self._default_transparency),
|
||||
offset='0', app=ATTR_TITLE_DEFAULT, force='true',
|
||||
interrupt='%i' % self._default_interrupt)
|
||||
interrupt='%i' % self._default_interrupt,)
|
||||
|
||||
data = kwargs.get(ATTR_DATA)
|
||||
if data:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"""Constants used by Home Assistant components."""
|
||||
MAJOR_VERSION = 0
|
||||
MINOR_VERSION = 59
|
||||
PATCH_VERSION = '0'
|
||||
PATCH_VERSION = '1'
|
||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||
REQUIRED_PYTHON_VER = (3, 4, 2)
|
||||
|
|
|
@ -331,7 +331,7 @@ hipnotify==1.0.8
|
|||
holidays==0.8.1
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20171130.0
|
||||
home-assistant-frontend==20171204.0
|
||||
|
||||
# homeassistant.components.camera.onvif
|
||||
http://github.com/tgaugry/suds-passworddigest-py3/archive/86fc50e39b4d2b8997481967d6a7fe1c57118999.zip#suds-passworddigest-py3==0.1.2a
|
||||
|
|
|
@ -74,7 +74,7 @@ hbmqtt==0.9.1
|
|||
holidays==0.8.1
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20171130.0
|
||||
home-assistant-frontend==20171204.0
|
||||
|
||||
# homeassistant.components.influxdb
|
||||
# homeassistant.components.sensor.influxdb
|
||||
|
|
Loading…
Add table
Reference in a new issue