Skip to content

Commit

Permalink
Add Home Assistant integration
Browse files Browse the repository at this point in the history
  • Loading branch information
douginoz committed Jun 25, 2024
1 parent dbf12af commit 90de8b5
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
16 changes: 16 additions & 0 deletions custom_components/iceicedata/__init__.py
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
15 changes: 15 additions & 0 deletions custom_components/iceicedata/config_flow.py
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,
})
)
14 changes: 14 additions & 0 deletions custom_components/iceicedata/manifest.json
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"]
}
24 changes: 24 additions & 0 deletions custom_components/iceicedata/sensor.py
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()

0 comments on commit 90de8b5

Please sign in to comment.