Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device temp offset is not taken into account in the regulated temp sending step calculation #705

Open
FockeOeuf opened this issue Dec 12, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@FockeOeuf
Copy link

Version of the custom_component

6.8.2

Describe the bug

When using the auto_regulation_use_device_temp parameter, the comparison with the regulated temperature sending step is performed before taking into account the device temp offset.

Let's take the situation where the regulated temperature doesn't have to change during the cycle calculation, but one underlying device temp offset have moved by a value superior to the regulated temperature step parameter, the new target temp isn't sent to any device, whereas it should have been.

With a 5 min cycle and auto regulation parameters which do not make the regulated temp move a lot, the target temp is almost never sent to the device, even though the device temp is far off the last regulated temperature sent (with the offset).

To fix the behavior, when using the auto_regulation_device_temp, the following test
if not force and abs(dtemp) < self._auto_regulation_dtemp
should be located further down the code when sending the target temp per underlying device using the following dtemp formula
dtemp = device target temp - (self.regulated_target_temp + offset_temp)

That way each device temp offset is correctly taken into account for the regulation step comparison.

The final code would look like (I didn't test it, just my assumption)

# use _attr_target_temperature_step to round value if _auto_regulation_dtemp is equal to 0
        regulation_step = self._auto_regulation_dtemp if self._auto_regulation_dtemp else self._attr_target_temperature_step
        _LOGGER.debug("%s - usage regulation_step: %.2f ", self, regulation_step)

        if self.current_temperature is not None:
            new_regulated_temp = round_to_nearest(
                self._regulation_algo.calculate_regulated_temperature(
                    self.current_temperature, self._cur_ext_temp
                ),
                regulation_step,
            )
        else:
            new_regulated_temp = self.target_temperature
        
        self._regulated_target_temp = new_regulated_temp
        _LOGGER.info(
            "%s - Regulated temp have changed to %.1f. Resend it to underlyings if target temp difference is above regulation step",
            self,
            new_regulated_temp,
        )

        self._last_regulation_change = self.now
        for under in self._underlyings:
            # issue 348 - use device temperature if configured as offset
            offset_temp = 0
            device_temp = 0
            if (
                # current_temperature is set
                self.current_temperature is not None
                # regulation can use the device_temp
                and self.auto_regulation_use_device_temp
                # and we have access to the device temp
                and (device_temp := under.underlying_current_temperature) is not None
            ):
                offset_temp = device_temp - self.current_temperature

            target_temp = round_to_nearest(self.regulated_target_temp + offset_temp, regulation_step)
            dtemp = self.current_temperature - target_temp

                if not force and abs(dtemp) < self._auto_regulation_dtemp:
                    _LOGGER.info(
                        "%s - dtemp (%.1f) is < %.1f -> forget the regulation send",
                        self,
                        dtemp,
                        self._auto_regulation_dtemp,
                    )
                    
                else:
                    _LOGGER.debug(
                        "%s - The device offset temp for regulation is %.2f - internal temp is %.2f. New target is %.2f",
                        self,
                        offset_temp,
                        device_temp,
                        target_temp,
                    )
            
                    await under.set_temperature(
                        target_temp,
                        self._attr_max_temp,
                        self._attr_min_temp,
                    )
@FockeOeuf FockeOeuf changed the title Device temp offset is not taken into account in the regulated temp sending threshold Device temp offset is not taken into account in the regulated temp sending step Dec 12, 2024
@FockeOeuf FockeOeuf changed the title Device temp offset is not taken into account in the regulated temp sending step Device temp offset is not taken into account in the regulated temp sending step calculation Dec 12, 2024
FockeOeuf added a commit to FockeOeuf/versatile_thermostat that referenced this issue Dec 12, 2024
Fix issue jmcollin78#705 Device temp offset is not taken into account in the regulated temp sending step calculation
@jmcollin78 jmcollin78 added the enhancement New feature or request label Dec 12, 2024
@jmcollin78
Copy link
Owner

jmcollin78 commented Dec 12, 2024

Hello @FockeOeuf ,

I will need some time to analyse and eventually take this proposal into account. Please be patient.

@FockeOeuf
Copy link
Author

Hi @jmcollin78, no worries for the moment I use an automation to compensate the offset every 5 minutes. Not so pretty but it kinda works.

This enhancement would be very useful for the cases where TRVs have a very different offset, and especially when they are linked to the same climate entity.

@andyxpert

This comment was marked as off-topic.

@SP2FET

This comment was marked as off-topic.

@jmcollin78
Copy link
Owner

Hello @SP2FET

Have you tried without "use the internal device's temperature" but set the regulation to 'Strong' ?
The 'use internal temp' flag is not reliable and depend of the quality of this value, The results are often unpredictable.

@SP2FET
Copy link

SP2FET commented Dec 15, 2024

Hi @jmcollin78, thanks for answer. I'll switch to strong regulation and observe that, will let you know

@andyxpert

This comment was marked as off-topic.

@SP2FET

This comment was marked as off-topic.

@jmcollin78
Copy link
Owner

Hello all,

This thread is now a mix of many question, proposal and discussion. I will keep only the first post of @FockeOeuf which a proposal to change the algo and this has nothing to do with your posts @andyxpert and @SP2FET.

@andyxpert and @SP2FET you have regulation problems which should be easily resolve (I hope so), by uncheck the "use internal temp" and set the self regulation to Strong (or expert if Strong is not enough). See here: https://github.com/jmcollin78/versatile_thermostat/blob/main/documentation/en/self-regulation.md#other-self-regulation

@SP2FET for the window detection issue, look at the #683 and check it is the same. I guess yes. The workaround is to set the window action to "turn off", while waiting for a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants