Skip to content

Commit 3d5bbae

Browse files
authored
Merge pull request #113 from explosivo22/dev
Fix bad commit
2 parents 21a54d8 + 1df92de commit 3d5bbae

File tree

5 files changed

+1
-482
lines changed

5 files changed

+1
-482
lines changed
Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD:custom_components/rinnaicontrolr-ha/__init__.py
21
import logging
32
import asyncio
43

@@ -84,93 +83,3 @@ async def async_remove_config_entry_device(
8483
) -> bool:
8584
"""Remove a config entry from a device."""
8685
return True
87-
=======
88-
import logging
89-
import asyncio
90-
from datetime import timedelta
91-
92-
from aiorinnai import async_get_api
93-
from aiorinnai.errors import RequestError
94-
95-
from homeassistant.config_entries import ConfigEntry
96-
from homeassistant.const import (
97-
CONF_PASSWORD,
98-
CONF_EMAIL,
99-
MAJOR_VERSION,
100-
MINOR_VERSION,
101-
)
102-
from homeassistant.core import HomeAssistant
103-
from homeassistant.exceptions import ConfigEntryNotReady
104-
from homeassistant.helpers.aiohttp_client import async_get_clientsession
105-
from homeassistant.components.water_heater import DOMAIN as WATER_HEATER_DOMAIN
106-
107-
from .const import (
108-
CLIENT,
109-
DOMAIN,
110-
CONF_UNIT,
111-
DEFAULT_UNIT,
112-
CONF_MAINT_INTERVAL_ENABLED,
113-
DEFAULT_MAINT_INTERVAL_ENABLED,
114-
)
115-
from .device import RinnaiDeviceDataUpdateCoordinator
116-
117-
_LOGGER = logging.getLogger(__name__)
118-
119-
PLATFORMS = ["water_heater","binary_sensor", "sensor"]
120-
121-
def is_min_ha_version(min_ha_major_ver: int, min_ha_minor_ver: int) -> bool:
122-
"""Check if HA version at least a specific version."""
123-
return (
124-
MAJOR_VERSION > min_ha_major_ver or
125-
(MAJOR_VERSION == min_ha_major_ver and MINOR_VERSION >= min_ha_minor_ver)
126-
)
127-
128-
129-
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
130-
"""Set up Rinnai from config entry"""
131-
session = async_get_clientsession(hass)
132-
hass.data.setdefault(DOMAIN, {})
133-
hass.data[DOMAIN][entry.entry_id] = {}
134-
135-
try:
136-
hass.data[DOMAIN][entry.entry_id][CLIENT] = client = await async_get_api(
137-
entry.data[CONF_EMAIL], entry.data[CONF_PASSWORD], session=session
138-
)
139-
except RequestError as err:
140-
raise ConfigEntryNotReady from err
141-
142-
user_info = await client.user.get_info()
143-
144-
_LOGGER.debug("Rinnai user information: %s", user_info)
145-
146-
hass.data[DOMAIN][entry.entry_id]["devices"] = devices = [
147-
RinnaiDeviceDataUpdateCoordinator(hass, client, device["id"], entry.options)
148-
for device in user_info["devices"]["items"]
149-
]
150-
151-
if not entry.options:
152-
await _async_options_updated(hass, entry)
153-
154-
tasks = [device.async_refresh() for device in devices]
155-
await asyncio.gather(*tasks)
156-
157-
if is_min_ha_version(2022,8):
158-
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
159-
else:
160-
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
161-
162-
entry.async_on_unload(entry.add_update_listener(_async_options_updated))
163-
164-
return True
165-
166-
async def _async_options_updated(hass: HomeAssistant, entry: ConfigEntry):
167-
"""Update options."""
168-
await hass.config_entries.async_reload(entry.entry_id)
169-
170-
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
171-
"""Unload a config entry."""
172-
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
173-
if unload_ok:
174-
hass.data[DOMAIN].pop(entry.entry_id)
175-
return unload_ok
176-
>>>>>>> 6a60ac3ef2862a01b180479f5b5a2e441f6a6f88:custom_components/rinnai/__init__.py

custom_components/rinnaicontrolr-ha/config_flow.py

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD:custom_components/rinnaicontrolr-ha/config_flow.py
21
"""Config flow for Rinnai integration."""
32
from typing import Any
43
from collections.abc import Mapping
@@ -120,99 +119,4 @@ async def async_step_init(self, user_input=None):
120119
)
121120

122121
class CannotConnect(exceptions.HomeAssistantError):
123-
=======
124-
"""Config flow for Rinnai integration."""
125-
from aiorinnai import async_get_api
126-
from aiorinnai.errors import RequestError
127-
import voluptuous as vol
128-
129-
from homeassistant import config_entries, core, exceptions
130-
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
131-
from homeassistant.helpers.aiohttp_client import async_get_clientsession
132-
from homeassistant.core import callback
133-
134-
from .const import (
135-
DOMAIN,
136-
LOGGER,
137-
CONF_MAINT_INTERVAL_ENABLED,
138-
DEFAULT_MAINT_INTERVAL_ENABLED,
139-
)
140-
141-
DATA_SCHEMA = vol.Schema({vol.Required("email"): str, vol.Required("password"): str})
142-
143-
async def validate_input(hass: core.HomeAssistant, data):
144-
"""Validate the user input allows us to connect.
145-
Data has the keys from DATA_SCHEMA with values provided by the user.
146-
"""
147-
148-
session = async_get_clientsession(hass)
149-
try:
150-
api = await async_get_api(
151-
data[CONF_EMAIL], data[CONF_PASSWORD], session=session
152-
)
153-
except RequestError as request_error:
154-
LOGGER.error("Error connecting to the Rinnai API: %s", request_error)
155-
raise CannotConnect from request_error
156-
157-
user_info = await api.user.get_info()
158-
first_device_name = user_info["devices"]["items"][0]["id"]
159-
device_info = await api.device.get_info(first_device_name)
160-
return {"title": device_info["data"]["getDevice"]["device_name"]}
161-
162-
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
163-
"""Handle a config flow for Rinnai."""
164-
165-
VERSION = 1
166-
167-
async def async_step_user(self, user_input=None):
168-
"""Handle the initial step."""
169-
errors = {}
170-
if user_input is not None:
171-
await self.async_set_unique_id(user_input[CONF_EMAIL])
172-
self._abort_if_unique_id_configured()
173-
try:
174-
info = await validate_input(self.hass, user_input)
175-
return self.async_create_entry(
176-
title=info["title"],
177-
data=user_input,
178-
options={
179-
CONF_MAINT_INTERVAL_ENABLED: DEFAULT_MAINT_INTERVAL_ENABLED,
180-
},
181-
)
182-
except CannotConnect:
183-
errors["base"] = "cannot_connect"
184-
185-
return self.async_show_form(
186-
step_id="user", data_schema=DATA_SCHEMA, errors=errors
187-
)
188-
189-
@staticmethod
190-
@callback
191-
def async_get_options_flow(config_entry):
192-
"""Get the options flow for this handler."""
193-
return OptionsFlow(config_entry)
194-
195-
class OptionsFlow(config_entries.OptionsFlow):
196-
def __init__(self, config_entry: config_entries.ConfigEntry):
197-
"""Initialize options flow."""
198-
self.config_entry = config_entry
199-
200-
async def async_step_init(self, user_input=None):
201-
if user_input is not None:
202-
return self.async_create_entry(title="", data=user_input)
203-
204-
return self.async_show_form(
205-
step_id="init",
206-
data_schema=vol.Schema(
207-
{
208-
vol.Optional(
209-
CONF_MAINT_INTERVAL_ENABLED,
210-
default=self.config_entry.options.get(CONF_MAINT_INTERVAL_ENABLED, DEFAULT_MAINT_INTERVAL_ENABLED),
211-
) : bool,
212-
}
213-
),
214-
)
215-
216-
class CannotConnect(exceptions.HomeAssistantError):
217-
>>>>>>> 6a60ac3ef2862a01b180479f5b5a2e441f6a6f88:custom_components/rinnai/config_flow.py
218122
"""Error to indicate we cannot connect."""
Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD:custom_components/rinnaicontrolr-ha/const.py
21
"""Constants for Rinnai Water Heater Monitoring"""
32
import logging
43

@@ -31,34 +30,3 @@
3130

3231
CONF_REFRESH_TOKEN = 'conf_refresh_token'
3332
CONF_ACCESS_TOKEN = 'conf_access_token'
34-
=======
35-
"""Constants for Rinnai Water Heater Monitoring"""
36-
import logging
37-
38-
LOGGER = logging.getLogger(__package__)
39-
40-
DOMAIN = 'rinnai'
41-
CLIENT = "client"
42-
43-
ATTRIBUTION = "Data provided by Rinnai"
44-
45-
DEFAULT_UNIT = "fahrenheit"
46-
CONF_UNIT = "units"
47-
48-
CONF_MAINT_INTERVAL_ENABLED = "maint_interval_enabled"
49-
DEFAULT_MAINT_INTERVAL_ENABLED = True
50-
51-
CONF_UNITS = ["celsius", "fahrenheit"]
52-
53-
ATTR_CACHE = 'cache'
54-
ATTR_COORDINATOR = 'coordinator'
55-
56-
SIGNAL_UPDATE_RINNAI = 'rinnai_temp_update'
57-
58-
ICON_DOMESTIC_TEMP='mdi:thermometer'
59-
ICON_RECIRCULATION='mdi:sync'
60-
ICON_RECIRCULATION_DISABLED='mdi:octagon-outline'
61-
62-
CONF_UNIT_SYSTEM_IMPERIAL = "imperial"
63-
CONF_UNIT_SYSTEM_METRIC = "metric"
64-
>>>>>>> 6a60ac3ef2862a01b180479f5b5a2e441f6a6f88:custom_components/rinnai/const.py

custom_components/rinnaicontrolr-ha/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"documentation": "https://github.com/explosivo22/rinnaicontrolr-ha/",
66
"codeowners": [ "@explosivo22" ],
77
"requirements": [ "aiorinnai==0.4.0a2" ],
8-
"version": "1.5.3",
8+
"version": "1.5.4",
99
"iot_class": "cloud_polling"
1010
}

0 commit comments

Comments
 (0)