Skip to content

Commit

Permalink
Merge pull request #319 from jwillemsen/jwi-modelid
Browse files Browse the repository at this point in the history
Add a test json with minimal data from the onecta app, extended some …
  • Loading branch information
jwillemsen authored Oct 14, 2024
2 parents 68659f0 + 7bb72f9 commit 2c44562
Show file tree
Hide file tree
Showing 7 changed files with 2,643 additions and 38 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/precommit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ jobs:
steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Setup Python
uses: "actions/setup-python@v5"
with:
python-version: "3.12"
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Python modules
run: |
pip install --constraint=.github/workflows/constraints.txt pre-commit black flake8 reorder-python-imports
- name: Run pre-commit on all files
run: |
pre-commit run --all-files --show-diff-on-failure --color=always
6 changes: 4 additions & 2 deletions custom_components/daikin_onecta/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ def get_hvac_mode(self):
mode = HVACMode.OFF
operationmode = self.operation_mode()
cc = self.climate_control()
if cc["onOffMode"]["value"] != "off":
mode = operationmode["value"]
onoff = cc.get("onOffMode")
if onoff is not None:
if onoff["value"] != "off":
mode = operationmode["value"]
return DAIKIN_HVAC_TO_HA.get(mode, HVACMode.HEAT_COOL)

def get_hvac_modes(self):
Expand Down
58 changes: 30 additions & 28 deletions custom_components/daikin_onecta/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,41 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
if cd is not None:
# Retrieve the available operationModes, we can only provide consumption data for
# supported operation modes
operation_modes = management_point["operationMode"]["values"]
cdv = cd.get("value")
if cdv is not None:
cdve = cdv.get("electrical")
if cdve is not None:
_LOGGER.info("Device '%s' provides electrical", device.name)
for mode in cdve:
# Only handle consumptionData for an operation mode supported by this device
if mode in operation_modes:
_LOGGER.info(
"Device '%s' provides mode %s %s",
device.name,
management_point_type,
mode,
)
for period in cdve[mode]:
opmode = management_point.get("operationMode")
if opmode is not None:
operation_modes = opmode["values"]
cdv = cd.get("value")
if cdv is not None:
cdve = cdv.get("electrical")
if cdve is not None:
_LOGGER.info("Device '%s' provides electrical", device.name)
for mode in cdve:
# Only handle consumptionData for an operation mode supported by this device
if mode in operation_modes:
_LOGGER.info(
"Device '%s:%s' provides mode %s %s supports period %s",
"Device '%s' provides mode %s %s",
device.name,
embedded_id,
management_point_type,
mode,
period,
)
periodName = SENSOR_PERIODS[period]
sensor = f"{device.name} {management_point_type} {mode} {periodName}"
_LOGGER.info("Proposing sensor '%s'", sensor)
sensors.append(DaikinEnergySensor(device, coordinator, embedded_id, management_point_type, mode, period))
else:
_LOGGER.info(
"Ignoring consumption data '%s', not a supported operation_mode",
mode,
)
for period in cdve[mode]:
_LOGGER.info(
"Device '%s:%s' provides mode %s %s supports period %s",
device.name,
embedded_id,
management_point_type,
mode,
period,
)
periodName = SENSOR_PERIODS[period]
sensor = f"{device.name} {management_point_type} {mode} {periodName}"
_LOGGER.info("Proposing sensor '%s'", sensor)
sensors.append(DaikinEnergySensor(device, coordinator, embedded_id, management_point_type, mode, period))
else:
_LOGGER.info(
"Ignoring consumption data '%s', not a supported operation_mode",
mode,
)

async_add_entities(sensors)

Expand Down
12 changes: 7 additions & 5 deletions custom_components/daikin_onecta/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ def hotwatertank_data(self):
def domestic_hotwater_temperature(self):
# Find the json dictionary for controlling the hot water temperature
dht = None
temp_control = self.hotwatertank_data["temperatureControl"]["value"]
if temp_control:
heating_mode = temp_control["operationModes"]["heating"]
if heating_mode is not None:
dht = heating_mode["setpoints"]["domesticHotWaterTemperature"]
tc = self.hotwatertank_data.get("temperatureControl")
if tc is not None:
temp_control = tc["value"]
if temp_control:
heating_mode = temp_control["operationModes"]["heating"]
if heating_mode is not None:
dht = heating_mode["setpoints"]["domesticHotWaterTemperature"]
return dht

def get_supported_features(self):
Expand Down
Loading

0 comments on commit 2c44562

Please sign in to comment.