-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers.typing import HomeAssistantType | ||
|
||
DOMAIN = "iceicedata" | ||
|
||
async def async_setup(hass: HomeAssistantType, config: dict): | ||
return True | ||
|
||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): | ||
hass.async_add_job(hass.config_entries.async_forward_entry_setup(entry, "sensor")) | ||
return True | ||
|
||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): | ||
await hass.config_entries.async_forward_entry_unload(entry, "sensor") | ||
return True |
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,15 @@ | ||
from homeassistant import config_entries | ||
import voluptuous as vol | ||
|
||
from .const import DOMAIN | ||
|
||
class IceIceDataConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): | ||
async def async_step_user(self, user_input=None): | ||
if user_input is not None: | ||
return self.async_create_entry(title="IceIceData", data=user_input) | ||
|
||
return self.async_show_form( | ||
step_id="user", data_schema=vol.Schema({ | ||
vol.Required("name"): str, | ||
}) | ||
) |
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,14 @@ | ||
{ | ||
"domain": "iceicedata", | ||
"name": "IceIceData", | ||
"version": "1.0.0", | ||
"documentation": "https://github.com/douginoz/iceicedata", | ||
"requirements": [ | ||
"selenium", | ||
"paho-mqtt", | ||
"pytz", | ||
"pyyaml" | ||
], | ||
"dependencies": [], | ||
"codeowners": ["@douginoz"] | ||
} |
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,24 @@ | ||
import logging | ||
from homeassistant.components.sensor import SensorEntity | ||
from ...iceicedata.data_processing import get_weather_data | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
async def async_setup_entry(hass, config_entry, async_add_entities): | ||
async_add_entities([IceIceDataSensor(config_entry.data)]) | ||
|
||
class IceIceDataSensor(SensorEntity): | ||
def __init__(self, config): | ||
self._name = config.get("name", "IceIceData Sensor") | ||
self._state = None | ||
|
||
@property | ||
def name(self): | ||
return self._name | ||
|
||
@property | ||
def state(self): | ||
return self._state | ||
|
||
async def async_update(self): | ||
self._state = get_weather_data() |