diff --git a/components/daikin_rotex_can/__init__.py b/components/daikin_rotex_can/__init__.py index e5cd386..bdde64f 100644 --- a/components/daikin_rotex_can/__init__.py +++ b/components/daikin_rotex_can/__init__.py @@ -274,6 +274,7 @@ "data_offset": 5, "data_size": 2, "divider": 10.0, + "signed": True, "range": [-30, 90] }, { @@ -1293,8 +1294,8 @@ } ] +CODEOWNERS = ["@wrfz"] DEPENDENCIES = [] - AUTO_LOAD = ['binary_sensor', 'button', 'number', 'sensor', 'select', 'text', 'text_sensor'] CONF_CAN_ID = "canbus_id" @@ -1561,6 +1562,7 @@ async def set_lambda(): sens_conf.get("data_offset", 5), sens_conf.get("data_size", 1), divider, + sens_conf.get("signed", False), sens_conf.get("update_entity", ""), update_interval, await handle_lambda(), diff --git a/components/daikin_rotex_can/entity.h b/components/daikin_rotex_can/entity.h index a16573a..834b444 100644 --- a/components/daikin_rotex_can/entity.h +++ b/components/daikin_rotex_can/entity.h @@ -28,6 +28,7 @@ class TEntity { uint8_t data_offset; uint8_t data_size; float divider; + bool isSigned; std::string update_entity; uint16_t update_interval; THandleFunc handle_lambda; @@ -43,6 +44,7 @@ class TEntity { , data_offset(0) , data_size(0) , divider(1) + , isSigned(false) , update_entity({}) , update_interval(1000) , handle_lambda([](TMessage const&){ return 0; }) @@ -60,6 +62,7 @@ class TEntity { uint8_t _data_offset, uint8_t _data_size, float _divider, + bool _isSigned, std::string const& _update_entity, uint16_t _update_interval, THandleFunc _handle_lambda, @@ -74,6 +77,7 @@ class TEntity { , data_offset(_data_offset) , data_size(_data_size) , divider(_divider) + , isSigned(_isSigned) , update_entity(_update_entity) , update_interval(_update_interval) , handle_lambda(_handle_lambda) diff --git a/components/daikin_rotex_can/sensors.cpp b/components/daikin_rotex_can/sensors.cpp index a92b5d2..28a11d3 100644 --- a/components/daikin_rotex_can/sensors.cpp +++ b/components/daikin_rotex_can/sensors.cpp @@ -10,7 +10,12 @@ static const char* TAG = "daikin_rotex_can"; bool CanSensor::handleValue(uint16_t value, TEntity::TVariant& current, TVariant& previous) { previous = state; - current = value / m_config.divider; + if (m_config.isSigned) { + current = static_cast(value) / m_config.divider; + } else { + current = value / m_config.divider; + } + const float float_value = std::get(current); const bool valid = !m_range.required() || (float_value >= m_range.min && float_value <= m_range.max); if (valid) {