Skip to content

Commit ea0e6da

Browse files
author
speleolontra
committed
First Committ in Beta version
0 parents  commit ea0e6da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+12837
-0
lines changed

.gitignore

+9,673
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
2+
* * * * * * INSERIMENTO DI UN NUOVO SENSORE * * * * * *
3+
4+
5+
6+
7+
8+
1) const.py: Aggiungere una costante ATTR battezzandone il nuovo nome, es:
9+
10+
11+
ATTR_TANK_TEMPERATURE = "tankTemperature"
12+
13+
14+
2) const.py: Aggiungere il CMD_SET con il percorso MP,DP e Value:
15+
16+
17+
DAIKIN_CMD_SETS = {
18+
...
19+
ATTR_TANK_TEMPERATURE: [MP_DOMESTIC_HWT, DP_SENSORS, "/tankTemperature"],
20+
21+
22+
dove "/tankTemperature" deve corrispondere al JSON:
23+
24+
25+
"sensoryData": {
26+
"ref": "#sensoryData",
27+
"settable": false,
28+
"value": {
29+
"tankTemperature": {
30+
"maxValue": 127,
31+
"minValue": -127,
32+
"requiresReboot": false,
33+
"settable": false,
34+
"stepValue": 1,
35+
"value": 38
36+
37+
38+
3) const.py: nei SENSOR_TYPES aggiungere la definizione del nuovo sensore:
39+
40+
41+
SENSOR_TYPES = {
42+
...
43+
ATTR_TANK_TEMPERATURE: {
44+
CONF_NAME: "Tank Temperature",
45+
CONF_TYPE: SENSOR_TYPE_TEMPERATURE,
46+
CONF_DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE,
47+
CONF_UNIT_OF_MEASUREMENT: TEMP_CELSIUS,
48+
},
49+
50+
51+
4) daikin_base.py: aggiungere l'attributo all'import:
52+
53+
54+
from .const import(
55+
...,
56+
ATTR_TANK_TEMPERATURE,
57+
58+
59+
5) daikin_base.py: definire le nuove property "support_xxx" e "xxx":
60+
61+
62+
@property
63+
def support_tank_temperature(self):
64+
"""Return True if the device supports outsite temperature measurement."""
65+
return self.getData(ATTR_TANK_TEMPERATURE) is not None
66+
67+
@property
68+
def tank_temperature(self):
69+
"""Return current outside temperature."""
70+
return float(self.getValue(ATTR_TANK_TEMPERATURE))
71+
72+
73+
6) sensor.py: aggiungere l'attributo all'import:
74+
75+
76+
from .const import (
77+
...,
78+
ATTR_TANK_TEMPERATURE,
79+
80+
81+
7) sensor.py: Append Se il sensore è supportato
82+
83+
84+
if device.support_tank_temperature:
85+
sensor = DaikinSensor.factory(device, ATTR_TANK_TEMPERATURE)
86+
_LOGGER.debug("DAMIANO append sensor = %s", sensor)
87+
sensors.append(sensor)
88+
89+
90+
8) sensor.py: Aggiungere la proprietà di stato
91+
92+
93+
@property
94+
def state(self):
95+
"""Return the internal state of the sensor."""
96+
...
97+
if self._device_attribute == ATTR_TANK_TEMPERATURE:
98+
return self._device.tank_temperature
99+
return None
100+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
"""Platform for the Daikin AC."""
2+
import asyncio
3+
import datetime
4+
import logging
5+
import voluptuous as vol
6+
7+
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
8+
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, SERVICE_RELOAD
9+
from homeassistant.helpers.typing import HomeAssistantType
10+
11+
from .const import DOMAIN, DAIKIN_API, DAIKIN_DEVICES, CONF_TOKENSET
12+
13+
from .daikin_api import DaikinApi
14+
15+
_LOGGER = logging.getLogger(__name__)
16+
17+
ENTRY_IS_SETUP = "daikin_entry_is_setup"
18+
_LOGGER.debug("DAMIANO daikin_entry_is_setup")
19+
20+
PARALLEL_UPDATES = 0
21+
22+
SERVICE_FORCE_UPDATE = "force_update"
23+
SERVICE_PULL_DEVICES = "pull_devices"
24+
25+
SIGNAL_DELETE_ENTITY = "daikin_delete"
26+
SIGNAL_UPDATE_ENTITY = "daikin_update"
27+
28+
TOKENSET_FILE = "altherma_tokenset.json"
29+
30+
MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(seconds=2)
31+
32+
COMPONENT_TYPES = ["climate", "sensor", "switch"]
33+
34+
35+
CONFIG_SCHEMA = vol.Schema(
36+
vol.All(
37+
{
38+
DOMAIN: vol.Schema(
39+
{vol.Required(CONF_EMAIL): str, vol.Required(CONF_PASSWORD): str}
40+
)
41+
}
42+
),
43+
extra=vol.ALLOW_EXTRA,
44+
)
45+
46+
47+
async def async_setup(hass, config):
48+
"""Setup the Daikin Residential component."""
49+
50+
async def _handle_reload(service):
51+
"""Handle reload service call."""
52+
_LOGGER.info("Reloading integration: retrieving new TokenSet.")
53+
try:
54+
daikin_api = hass.data[DOMAIN][DAIKIN_API]
55+
data = daikin_api._config_entry.data.copy()
56+
await daikin_api.retrieveAccessToken(data[CONF_EMAIL], data[CONF_PASSWORD])
57+
data[CONF_TOKENSET] = daikin_api.tokenSet
58+
hass.config_entries.async_update_entry(
59+
entry=daikin_api._config_entry, data=data
60+
)
61+
except Exception as e:
62+
_LOGGER.error("Failed to reload integration: %s", e)
63+
64+
hass.helpers.service.async_register_admin_service(
65+
DOMAIN, SERVICE_RELOAD, _handle_reload
66+
)
67+
68+
if DOMAIN not in config:
69+
return True
70+
71+
conf = config.get(DOMAIN)
72+
if conf is not None:
73+
hass.async_create_task(
74+
hass.config_entries.flow.async_init(
75+
DOMAIN, context={"source": SOURCE_IMPORT}, data=conf
76+
)
77+
)
78+
79+
return True
80+
81+
82+
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
83+
"""Establish connection with Daikin."""
84+
85+
daikin_api = DaikinApi(hass, entry)
86+
await daikin_api.getCloudDeviceDetails()
87+
88+
devices = await daikin_api.getCloudDevices()
89+
hass.data[DOMAIN] = {DAIKIN_API: daikin_api, DAIKIN_DEVICES: devices}
90+
91+
for component in COMPONENT_TYPES:
92+
#print("DAMIANO component %S", component)
93+
hass.async_create_task(
94+
hass.config_entries.async_forward_entry_setup(entry, component)
95+
)
96+
return True
97+
98+
99+
async def async_unload_entry(hass, config_entry):
100+
"""Unload a config entry."""
101+
_LOGGER.debug("Unloading integration...")
102+
await asyncio.wait(
103+
[
104+
hass.config_entries.async_forward_entry_unload(config_entry, component)
105+
for component in COMPONENT_TYPES
106+
]
107+
)
108+
hass.data[DOMAIN].clear()
109+
if not hass.data[DOMAIN]:
110+
hass.data.pop(DOMAIN)
111+
return True
112+
113+
114+
async def daikin_api_setup(hass, host, key, uuid, password):
115+
"""Create a Daikin instance only once."""
116+
return

0 commit comments

Comments
 (0)