core/homeassistant/components/bsblan/climate.py

165 lines
5.3 KiB
Python
Raw Normal View History

Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
"""BSBLAN platform to control a compatible Climate Device."""
2021-03-17 22:34:25 +00:00
from __future__ import annotations
from typing import Any
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
from bsblan import BSBLANError
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
from homeassistant.components.climate import (
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
ATTR_HVAC_MODE,
ATTR_PRESET_MODE,
PRESET_ECO,
PRESET_NONE,
ClimateEntity,
ClimateEntityFeature,
HVACMode,
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.enum import try_parse_enum
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
from . import BSBLanData
from .const import ATTR_TARGET_TEMPERATURE, DOMAIN
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
from .entity import BSBLanEntity
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
PARALLEL_UPDATES = 1
HVAC_MODES = [
HVACMode.AUTO,
HVACMode.HEAT,
HVACMode.OFF,
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
]
PRESET_MODES = [
PRESET_ECO,
PRESET_NONE,
]
async def async_setup_entry(
hass: HomeAssistant,
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
) -> None:
"""Set up BSBLAN device based on a config entry."""
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
data: BSBLanData = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
[
BSBLANClimate(
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
data,
)
]
)
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
class BSBLANClimate(BSBLanEntity, ClimateEntity):
"""Defines a BSBLAN climate device."""
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
_attr_has_entity_name = True
_attr_name = None
# Determine preset modes
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.PRESET_MODE
| ClimateEntityFeature.TURN_OFF
| ClimateEntityFeature.TURN_ON
)
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
_attr_preset_modes = PRESET_MODES
_attr_hvac_modes = HVAC_MODES
_enable_turn_on_off_backwards_compatibility = False
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
def __init__(
2020-08-27 11:56:20 +00:00
self,
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
data: BSBLanData,
) -> None:
"""Initialize BSBLAN climate device."""
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
super().__init__(data.coordinator, data)
self._attr_unique_id = f"{format_mac(data.device.MAC)}-climate"
self._attr_min_temp = float(data.static.min_temp.value)
self._attr_max_temp = float(data.static.max_temp.value)
if data.static.min_temp.unit in ("&deg;C", "°C"):
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
else:
self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
@property
def current_temperature(self) -> float | None:
"""Return the current temperature."""
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
if self.coordinator.data.state.current_temperature.value == "---":
# device returns no current temperature
return None
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
return float(self.coordinator.data.state.current_temperature.value)
@property
def target_temperature(self) -> float | None:
"""Return the temperature we try to reach."""
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
return float(self.coordinator.data.state.target_temperature.value)
@property
def hvac_mode(self) -> HVACMode | None:
"""Return hvac operation ie. heat, cool mode."""
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
if self.coordinator.data.state.hvac_mode.value == PRESET_ECO:
return HVACMode.AUTO
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
return try_parse_enum(HVACMode, self.coordinator.data.state.hvac_mode.value)
@property
def preset_mode(self) -> str | None:
"""Return the current preset mode."""
if (
self.hvac_mode == HVACMode.AUTO
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
and self.coordinator.data.state.hvac_mode.value == PRESET_ECO
):
return PRESET_ECO
return PRESET_NONE
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set hvac mode."""
await self.async_set_data(hvac_mode=hvac_mode)
async def async_set_preset_mode(self, preset_mode: str) -> None:
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
"""Set preset mode."""
# only allow preset mode when hvac mode is auto
if self.hvac_mode == HVACMode.AUTO:
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
await self.async_set_data(preset_mode=preset_mode)
else:
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="set_preset_mode_error",
translation_placeholders={"preset_mode": preset_mode},
)
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
2022-08-19 07:54:13 +00:00
async def async_set_temperature(self, **kwargs: Any) -> None:
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
"""Set new target temperatures."""
await self.async_set_data(**kwargs)
async def async_set_data(self, **kwargs: Any) -> None:
"""Set device settings using BSBLAN."""
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
data = {}
if ATTR_TEMPERATURE in kwargs:
data[ATTR_TARGET_TEMPERATURE] = kwargs[ATTR_TEMPERATURE]
if ATTR_HVAC_MODE in kwargs:
data[ATTR_HVAC_MODE] = kwargs[ATTR_HVAC_MODE]
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
if ATTR_PRESET_MODE in kwargs:
# If preset mode is None, set hvac to auto
if kwargs[ATTR_PRESET_MODE] == PRESET_NONE:
data[ATTR_HVAC_MODE] = HVACMode.AUTO
else:
data[ATTR_HVAC_MODE] = kwargs[ATTR_PRESET_MODE]
Add BSBLan Climate integration (#32375) * Initial commit for BSBLan Climate component The most basic climate functions work. * Delete manifest 2.json wrongly added to commit * fix incorrect name current_hvac_mode * update coverage to exclude bsblan * sorted and add configflow * removed unused code, etc * fix hvac, preset mix up now it sets hvac mode to none and preset to eco * fix naming * removed commented code and cleaned code that isn't needed * Add test for the configflow * Update requirements fixing some issues in bsblan Lib * Update coverage file to include configflow bsblan * Fix hvac preset is not in hvac mode rewrote how to handle presets. * Add passkey option My device had a passkey so I needed to push this functionality to do testing * Update constants include passkey and added some more for device indentification * add passkey for configflow * Fix use discovery_info instead of user_input also added passkey * Fix name * Fix for discovery_info[CONF_PORT] is None * Fix get value CONF_PORT * Fix move translation to new location * Fix get the right info * Fix remove zeroconf and fix the code * Add init for mockConfigEntry * Fix removed zeroconfig and fix code * Fix changed ClimateDevice to ClimatEntity * Fix log error message * Removed debug code * Change name of device. * Remove check This is done in the configflow * Remove period from logging message * Update homeassistant/components/bsblan/strings.json Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Add passkey Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2020-05-10 02:16:21 +00:00
try:
Refactor bsblan coordinator (#124308) * chore: Refactor BSBLanUpdateCoordinator to improve code readability and maintainability * feat: Add BSBLan integration models This commit adds the models for the BSB-Lan integration. It includes a dataclass for the BSBLanCoordinatorData, which stores the state and sensor information. * refactor: Update BSBLANClimate class to use DataUpdateCoordinator without specifying the State type * chore: Remove unused Sensor import in BSBLan models * feat: Refactor BSBLanEntity to use CoordinatorEntity The BSBLanEntity class has been refactored to inherit from the CoordinatorEntity class, which provides better integration with the update coordinator. This change improves code readability and maintainability. * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: Update BSBLANClimate class to use DataUpdateCoordinator Refactor the BSBLANClimate class to use the Coordinator of the entity * refactor: Update tests to use the new structure * fix coverage it should be the same as before * refactor: moved dataclass BSBLanCoordinatorData * use the data class inside init * refactor: Remove unused config_entry variable in BSBLanUpdateCoordinator * refactor: use BSBLanData from init * remove entry data from diagnostics * fix: add random interval back * refactor: Simplify coordinator_data assignment in async_get_config_entry_diagnostics * revert back to original except dataclass import * revert: Add MAC address back to device info in BSBLanEntity
2024-08-23 06:42:36 +00:00
await self.coordinator.client.thermostat(**data)
except BSBLANError as err:
raise HomeAssistantError(
"An error occurred while updating the BSBLAN device",
translation_domain=DOMAIN,
translation_key="set_data_error",
) from err
await self.coordinator.async_request_refresh()