diff --git a/custom_components/iceicedata/__init__.py b/custom_components/iceicedata/__init__.py new file mode 100644 index 000000000..e066756eb --- /dev/null +++ b/custom_components/iceicedata/__init__.py @@ -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 diff --git a/custom_components/iceicedata/config_flow.py b/custom_components/iceicedata/config_flow.py new file mode 100644 index 000000000..591eaee14 --- /dev/null +++ b/custom_components/iceicedata/config_flow.py @@ -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, + }) + ) diff --git a/custom_components/iceicedata/manifest.json b/custom_components/iceicedata/manifest.json new file mode 100644 index 000000000..4bc4357ed --- /dev/null +++ b/custom_components/iceicedata/manifest.json @@ -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"] +} diff --git a/custom_components/iceicedata/sensor.py b/custom_components/iceicedata/sensor.py new file mode 100644 index 000000000..96e8d35a8 --- /dev/null +++ b/custom_components/iceicedata/sensor.py @@ -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()