Describe the bug
The sensor platform fails to set up entirely, throwing an unhandled exception,
even though the energy_sensor and power_sensor options were correctly
configured via the options flow (confirmed by re-opening the options flow,
which shows the correct suggested_value for energy_data_format and
energy_data_scale).
Traceback
Error while setting up midea_ac platform for sensor:
'NoneType' object has no attribute 'get'
File ".../custom_components/midea_ac/sensor.py", line 69, in _get_energy_config
config = config_entry.options.get(key)
format = device.EnergyDataFormat.get_from_name(
config.get(CONF_ENERGY_DATA_FORMAT).upper())
AttributeError: 'NoneType' object has no attribute 'get'
Impact
Because this exception is raised while building the entities list (before
add_entities() is called), it aborts the ENTIRE sensor platform setup, not
just the energy/power sensors. This also removes unrelated sensors like
indoor_temperature and outdoor_temperature for the device.
Reproduction
- Set up a device that supports
enable_energy_usage_requests
- Configure
energy_sensor and power_sensor options via the options flow
- Reload the integration
- Sensor platform fails to load entirely
Workaround applied locally
Made _get_energy_config defensive against a missing/None config:
def _get_energy_config(key: str) -> tuple[EnergyFormat, float]:
config = config_entry.options.get(key) or {}
format = device.EnergyDataFormat.get_from_name(
config.get(CONF_ENERGY_DATA_FORMAT, "bcd").upper())
scale = config.get(CONF_ENERGY_DATA_SCALE, 1.0)
return format, scale
After this change, all sensors (including energy/power) load correctly.
Environment
- Integration version: 2026.4.0 (also reproduced on 2026.7.1)
- Device: Midea PortaSplit
- Home Assistant Core: 2026.7.4
Additional context
Not sure if this is related to #453 (the _DEFAULT_OPTIONS mutation fix),
but the symptom here is the opposite: an expected key is missing/None for
a single, correctly-configured device, rather than unexpected keys leaking
in from other devices.
Describe the bug
The sensor platform fails to set up entirely, throwing an unhandled exception,
even though the
energy_sensorandpower_sensoroptions were correctlyconfigured via the options flow (confirmed by re-opening the options flow,
which shows the correct
suggested_valueforenergy_data_formatandenergy_data_scale).Traceback
Error while setting up midea_ac platform for sensor:
'NoneType' object has no attribute 'get'
File ".../custom_components/midea_ac/sensor.py", line 69, in _get_energy_config
config = config_entry.options.get(key)
format = device.EnergyDataFormat.get_from_name(
config.get(CONF_ENERGY_DATA_FORMAT).upper())
AttributeError: 'NoneType' object has no attribute 'get'
Impact
Because this exception is raised while building the
entitieslist (beforeadd_entities()is called), it aborts the ENTIRE sensor platform setup, notjust the energy/power sensors. This also removes unrelated sensors like
indoor_temperature and outdoor_temperature for the device.
Reproduction
enable_energy_usage_requestsenergy_sensorandpower_sensoroptions via the options flowWorkaround applied locally
Made
_get_energy_configdefensive against a missing/None config:After this change, all sensors (including energy/power) load correctly.
Environment
Additional context
Not sure if this is related to #453 (the
_DEFAULT_OPTIONSmutation fix),but the symptom here is the opposite: an expected key is missing/None for
a single, correctly-configured device, rather than unexpected keys leaking
in from other devices.