2020-02-25 23:37:41 +00:00
|
|
|
"""Constants for monitoring a Sense energy sensor."""
|
2020-03-23 04:41:59 +00:00
|
|
|
|
|
|
|
import asyncio
|
2021-10-28 19:27:19 +00:00
|
|
|
import socket
|
2020-03-23 04:41:59 +00:00
|
|
|
|
2022-03-22 22:14:01 +00:00
|
|
|
from sense_energy import (
|
|
|
|
SenseAPIException,
|
|
|
|
SenseAPITimeoutException,
|
|
|
|
SenseWebsocketException,
|
|
|
|
)
|
2020-03-23 04:41:59 +00:00
|
|
|
|
2020-02-25 23:37:41 +00:00
|
|
|
DOMAIN = "sense"
|
2023-05-02 14:50:34 +00:00
|
|
|
DEFAULT_TIMEOUT = 30
|
2020-02-25 23:37:41 +00:00
|
|
|
ACTIVE_UPDATE_RATE = 60
|
|
|
|
DEFAULT_NAME = "Sense"
|
|
|
|
SENSE_DATA = "sense_data"
|
|
|
|
SENSE_DEVICE_UPDATE = "sense_devices_update"
|
2020-02-28 05:23:47 +00:00
|
|
|
SENSE_DEVICES_DATA = "sense_devices_data"
|
|
|
|
SENSE_DISCOVERED_DEVICES_DATA = "sense_discovered_devices"
|
2020-04-14 05:56:02 +00:00
|
|
|
SENSE_TRENDS_COORDINATOR = "sense_trends_coordinator"
|
2020-02-28 05:23:47 +00:00
|
|
|
|
|
|
|
ACTIVE_NAME = "Energy"
|
|
|
|
ACTIVE_TYPE = "active"
|
|
|
|
|
2020-04-04 20:51:00 +00:00
|
|
|
ATTRIBUTION = "Data provided by Sense.com"
|
|
|
|
|
2020-02-28 05:23:47 +00:00
|
|
|
CONSUMPTION_NAME = "Usage"
|
|
|
|
CONSUMPTION_ID = "usage"
|
|
|
|
PRODUCTION_NAME = "Production"
|
|
|
|
PRODUCTION_ID = "production"
|
2021-08-30 15:01:26 +00:00
|
|
|
PRODUCTION_PCT_NAME = "Net Production Percentage"
|
|
|
|
PRODUCTION_PCT_ID = "production_pct"
|
|
|
|
NET_PRODUCTION_NAME = "Net Production"
|
|
|
|
NET_PRODUCTION_ID = "net_production"
|
|
|
|
TO_GRID_NAME = "To Grid"
|
|
|
|
TO_GRID_ID = "to_grid"
|
|
|
|
FROM_GRID_NAME = "From Grid"
|
|
|
|
FROM_GRID_ID = "from_grid"
|
|
|
|
SOLAR_POWERED_NAME = "Solar Powered Percentage"
|
|
|
|
SOLAR_POWERED_ID = "solar_powered"
|
2020-02-28 05:23:47 +00:00
|
|
|
|
2020-03-23 04:41:59 +00:00
|
|
|
SENSE_TIMEOUT_EXCEPTIONS = (asyncio.TimeoutError, SenseAPITimeoutException)
|
Fix handling of dns resolution failure during sense setup (#88279)
```
2023-02-16 20:44:54.516 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry alexander for sense
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1152, in _create_direct_connection
hosts = await asyncio.shield(host_resolved)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1152, in _create_direct_connection
hosts = await asyncio.shield(host_resolved)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 861, in _resolve_host
await event.wait()
File "/usr/local/lib/python3.10/site-packages/aiohttp/locks.py", line 34, in wait
raise self._exc
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 874, in _resolve_host
addrs = await self._resolver.resolve(host, port, family=self._family)
File "/usr/local/lib/python3.10/site-packages/aiohttp/resolver.py", line 33, in resolve
infos = await self._loop.getaddrinfo(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 860, in getaddrinfo
return await self.run_in_executor(
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 381, in async_setup
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/sense/__init__.py", line 83, in async_setup_entry
await gateway.get_monitor_data()
File "/usr/local/lib/python3.10/site-packages/sense_energy/asyncsenseable.py", line 214, in get_monitor_data
json = await self._api_call("app/monitors/%s/overview" % self.sense_monitor_id)
File "/usr/local/lib/python3.10/site-packages/sense_energy/asyncsenseable.py", line 174, in _api_call
async with self._client_session.get(
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1166, in _create_direct_connection
raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.sense.com:443 ssl:default [Try again] ```
2023-02-17 04:18:16 +00:00
|
|
|
SENSE_WEBSOCKET_EXCEPTIONS = (socket.gaierror, SenseWebsocketException)
|
2022-03-22 22:14:01 +00:00
|
|
|
SENSE_CONNECT_EXCEPTIONS = (
|
Fix handling of dns resolution failure during sense setup (#88279)
```
2023-02-16 20:44:54.516 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry alexander for sense
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1152, in _create_direct_connection
hosts = await asyncio.shield(host_resolved)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1152, in _create_direct_connection
hosts = await asyncio.shield(host_resolved)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 861, in _resolve_host
await event.wait()
File "/usr/local/lib/python3.10/site-packages/aiohttp/locks.py", line 34, in wait
raise self._exc
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 874, in _resolve_host
addrs = await self._resolver.resolve(host, port, family=self._family)
File "/usr/local/lib/python3.10/site-packages/aiohttp/resolver.py", line 33, in resolve
infos = await self._loop.getaddrinfo(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 860, in getaddrinfo
return await self.run_in_executor(
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 381, in async_setup
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/sense/__init__.py", line 83, in async_setup_entry
await gateway.get_monitor_data()
File "/usr/local/lib/python3.10/site-packages/sense_energy/asyncsenseable.py", line 214, in get_monitor_data
json = await self._api_call("app/monitors/%s/overview" % self.sense_monitor_id)
File "/usr/local/lib/python3.10/site-packages/sense_energy/asyncsenseable.py", line 174, in _api_call
async with self._client_session.get(
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1166, in _create_direct_connection
raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.sense.com:443 ssl:default [Try again] ```
2023-02-17 04:18:16 +00:00
|
|
|
socket.gaierror,
|
2022-03-22 22:14:01 +00:00
|
|
|
asyncio.TimeoutError,
|
|
|
|
SenseAPITimeoutException,
|
|
|
|
SenseAPIException,
|
|
|
|
)
|
2020-03-23 04:41:59 +00:00
|
|
|
|
2020-02-28 05:23:47 +00:00
|
|
|
MDI_ICONS = {
|
|
|
|
"ac": "air-conditioner",
|
|
|
|
"aquarium": "fish",
|
|
|
|
"car": "car-electric",
|
|
|
|
"computer": "desktop-classic",
|
|
|
|
"cup": "coffee",
|
|
|
|
"dehumidifier": "water-off",
|
|
|
|
"dishes": "dishwasher",
|
|
|
|
"drill": "toolbox",
|
|
|
|
"fan": "fan",
|
|
|
|
"freezer": "fridge-top",
|
|
|
|
"fridge": "fridge-bottom",
|
|
|
|
"game": "gamepad-variant",
|
|
|
|
"garage": "garage",
|
|
|
|
"grill": "stove",
|
|
|
|
"heat": "fire",
|
|
|
|
"heater": "radiatior",
|
|
|
|
"humidifier": "water",
|
|
|
|
"kettle": "kettle",
|
|
|
|
"leafblower": "leaf",
|
|
|
|
"lightbulb": "lightbulb",
|
|
|
|
"media_console": "set-top-box",
|
|
|
|
"modem": "router-wireless",
|
|
|
|
"outlet": "power-socket-us",
|
|
|
|
"papershredder": "shredder",
|
|
|
|
"printer": "printer",
|
|
|
|
"pump": "water-pump",
|
2020-08-25 02:35:48 +00:00
|
|
|
"settings": "cog",
|
2020-02-28 05:23:47 +00:00
|
|
|
"skillet": "pot",
|
|
|
|
"smartcamera": "webcam",
|
|
|
|
"socket": "power-plug",
|
|
|
|
"solar_alt": "solar-power",
|
|
|
|
"sound": "speaker",
|
|
|
|
"stove": "stove",
|
|
|
|
"trash": "trash-can",
|
|
|
|
"tv": "television",
|
|
|
|
"vacuum": "robot-vacuum",
|
|
|
|
"washer": "washing-machine",
|
|
|
|
}
|