Skip to content

Commit 2c44562

Browse files
authored
Merge pull request #319 from jwillemsen/jwi-modelid
Add a test json with minimal data from the onecta app, extended some …
2 parents 68659f0 + 7bb72f9 commit 2c44562

File tree

7 files changed

+2643
-38
lines changed

7 files changed

+2643
-38
lines changed

.github/workflows/precommit.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ jobs:
1414
steps:
1515
- name: Check out the repository
1616
uses: actions/checkout@v4
17-
17+
- name: Setup Python
18+
uses: "actions/setup-python@v5"
19+
with:
20+
python-version: "3.12"
1821
- name: Upgrade pip
1922
run: |
2023
pip install --constraint=.github/workflows/constraints.txt pip
2124
pip --version
22-
2325
- name: Install Python modules
2426
run: |
2527
pip install --constraint=.github/workflows/constraints.txt pre-commit black flake8 reorder-python-imports
26-
2728
- name: Run pre-commit on all files
2829
run: |
2930
pre-commit run --all-files --show-diff-on-failure --color=always

custom_components/daikin_onecta/climate.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,10 @@ def get_hvac_mode(self):
345345
mode = HVACMode.OFF
346346
operationmode = self.operation_mode()
347347
cc = self.climate_control()
348-
if cc["onOffMode"]["value"] != "off":
349-
mode = operationmode["value"]
348+
onoff = cc.get("onOffMode")
349+
if onoff is not None:
350+
if onoff["value"] != "off":
351+
mode = operationmode["value"]
350352
return DAIKIN_HVAC_TO_HA.get(mode, HVACMode.HEAT_COOL)
351353

352354
def get_hvac_modes(self):

custom_components/daikin_onecta/sensor.py

+30-28
Original file line numberDiff line numberDiff line change
@@ -108,39 +108,41 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
108108
if cd is not None:
109109
# Retrieve the available operationModes, we can only provide consumption data for
110110
# supported operation modes
111-
operation_modes = management_point["operationMode"]["values"]
112-
cdv = cd.get("value")
113-
if cdv is not None:
114-
cdve = cdv.get("electrical")
115-
if cdve is not None:
116-
_LOGGER.info("Device '%s' provides electrical", device.name)
117-
for mode in cdve:
118-
# Only handle consumptionData for an operation mode supported by this device
119-
if mode in operation_modes:
120-
_LOGGER.info(
121-
"Device '%s' provides mode %s %s",
122-
device.name,
123-
management_point_type,
124-
mode,
125-
)
126-
for period in cdve[mode]:
111+
opmode = management_point.get("operationMode")
112+
if opmode is not None:
113+
operation_modes = opmode["values"]
114+
cdv = cd.get("value")
115+
if cdv is not None:
116+
cdve = cdv.get("electrical")
117+
if cdve is not None:
118+
_LOGGER.info("Device '%s' provides electrical", device.name)
119+
for mode in cdve:
120+
# Only handle consumptionData for an operation mode supported by this device
121+
if mode in operation_modes:
127122
_LOGGER.info(
128-
"Device '%s:%s' provides mode %s %s supports period %s",
123+
"Device '%s' provides mode %s %s",
129124
device.name,
130-
embedded_id,
131125
management_point_type,
132126
mode,
133-
period,
134127
)
135-
periodName = SENSOR_PERIODS[period]
136-
sensor = f"{device.name} {management_point_type} {mode} {periodName}"
137-
_LOGGER.info("Proposing sensor '%s'", sensor)
138-
sensors.append(DaikinEnergySensor(device, coordinator, embedded_id, management_point_type, mode, period))
139-
else:
140-
_LOGGER.info(
141-
"Ignoring consumption data '%s', not a supported operation_mode",
142-
mode,
143-
)
128+
for period in cdve[mode]:
129+
_LOGGER.info(
130+
"Device '%s:%s' provides mode %s %s supports period %s",
131+
device.name,
132+
embedded_id,
133+
management_point_type,
134+
mode,
135+
period,
136+
)
137+
periodName = SENSOR_PERIODS[period]
138+
sensor = f"{device.name} {management_point_type} {mode} {periodName}"
139+
_LOGGER.info("Proposing sensor '%s'", sensor)
140+
sensors.append(DaikinEnergySensor(device, coordinator, embedded_id, management_point_type, mode, period))
141+
else:
142+
_LOGGER.info(
143+
"Ignoring consumption data '%s', not a supported operation_mode",
144+
mode,
145+
)
144146

145147
async_add_entities(sensors)
146148

custom_components/daikin_onecta/water_heater.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ def hotwatertank_data(self):
8989
def domestic_hotwater_temperature(self):
9090
# Find the json dictionary for controlling the hot water temperature
9191
dht = None
92-
temp_control = self.hotwatertank_data["temperatureControl"]["value"]
93-
if temp_control:
94-
heating_mode = temp_control["operationModes"]["heating"]
95-
if heating_mode is not None:
96-
dht = heating_mode["setpoints"]["domesticHotWaterTemperature"]
92+
tc = self.hotwatertank_data.get("temperatureControl")
93+
if tc is not None:
94+
temp_control = tc["value"]
95+
if temp_control:
96+
heating_mode = temp_control["operationModes"]["heating"]
97+
if heating_mode is not None:
98+
dht = heating_mode["setpoints"]["domesticHotWaterTemperature"]
9799
return dht
98100

99101
def get_supported_features(self):

0 commit comments

Comments
 (0)