sockless-coding / panasonic_cc

Panasonic Comfort Cloud - Home Assistant Component
MIT License
144 stars 35 forks source link

Power Off Command Inverts AC Unit State #324

Open peteger opened 3 days ago

peteger commented 3 days ago

Checklist

What version of Home Assistant Core?

core-2024.10.2

Describe the issue

The problem

Issue: HomeKit Bridge Integration Inverts AC Unit State on Power Off Command

Description:

When using HomeKit Bridge to control the AC unit from Apple HomeKit, the power off command inverts the current state of the unit.

• If the AC is turned on, issuing the off command through HomeKit will turn it off, as expected. • However, if the AC is already off, issuing the off command will turn it on instead of keeping it off. This causes confusion and requires manual intervention to ensure the AC is in the correct state. It would be helpful if the off command consistently kept the unit off, regardless of its prior state.

Steps to Reproduce:

  1. Turn off the AC unit via HomeKit.
  2. Issue a power off command via Shortcut
  3. Observe the state of the AC unit Expected Result: The AC unit should remain off when issuing the power off command.

Actual Result: The power off command turns the AC unit on if it was previously off.

367175619-6883141e-52f8-4268-a1d7-ef08c0b89e11 367175623-41e6f4b3-eb35-4ad9-9347-dff4a4888342

Log file:

home-assistant_2024-09-13T06-15-02.870Z.log

Error/Debug Logs

No response

sockless-coding commented 3 days ago

@peteger as far as I can see, you do not seem to be using this integration to control your AC. This integration has nothing to do with HomeKit.

mkz212 commented 3 days ago

I also notice this problem. Using HomeKit, when AC is turned on and I will send command to turn off it will turn off. But if it is turned off and I send command (via automation) to turn off it will... turn on!

peteger commented 3 days ago

@sockless-coding Thanks, Jimmy, and sorry if I misunderstood. I thought the way I was using it was that the HomeKit Bridge integration simply exposes the controls of this integration to Apple HomeKit, and when I send a command from the iOS HomeKit app, it is relayed to this integration via the HomeKit Bridge. Or is this working differently?

mkz212 commented 3 days ago

I think that I know what is wrong. If you set automation in Apple Home to turn off AC it send not only command to set off but also command to set target temperature. If you create scene using Eve app and in this scene you set only turn off command it works ok. I think it is bug cause set target temp should not enable AC. (Other plugin for other brand AC not have this behaviour).

sockless-coding commented 3 days ago

This integration talks directly to the Panasonic API, it reads and sets the states directly... You should probably avoid mixing "controller", adding automations in HA and HomeKit is just asking for trouble.

mkz212 commented 2 days ago

This integration talks directly to the Panasonic API, it reads and sets the states directly... You should probably avoid mixing "controller", adding automations in HA and HomeKit is just asking for trouble.

I know it can be solved, cause Gree Integration works ok. In HomeKit it also shows as thermostat + fan.

peteger commented 2 days ago

This integration talks directly to the Panasonic API, it reads and sets the states directly... You should probably avoid mixing "controller", adding automations in HA and HomeKit is just asking for trouble.

Yes, that’s correct. When I use this integration within HA, it works fine (the “turn off” action only sends a signal to turn off the unit, without setting the temperature). I reported this issue because many users rely on this integration to control Panasonic AC units through HomeKit via HA. It worked well before, but since a recent update (not sure if this was related to HA Core or this integration), I’ve been experiencing problems. Fixing this would be a great help.

At the moment, I’ve had to remove all my HomeKit automations related to Panasonic AC units because they’re not functioning as expected. For example, I want to turn off all AC units when I leave the house, but currently, it turns some units off and others on. I even discussed this with a few Apple HomeKit engineers and reported the issue, but I don’t believe they see it as a problem as setting the target temperature on a turned-off unit shouldn’t turn it back on.

peteger commented 2 days ago

I believe the issue is related to this line of code, which turns the AC unit on when a set_target_temperature command is called:

// custom_components/panasonic_cc/pcomfortcloud/changerequestbuilder.py

@property
    def target_temperature(self) -> int | None:
        return self._request["temperatureSet"] if "temperatureSet" in self._request else None

    def set_target_temperature(self, new_value: int):
        """ Set target temperature """
        self._ensure_powered_on() // <---- THIS LINE
        self._request["temperatureSet"] = new_value
        return self

You can replicate the issue directly in HA by setting a temperature on a turned-off AC unit—it turns the unit back on.

peteger commented 2 days ago

A suggestion for a workaround if you want to keep the functionality as it is:

This would resolve the automation issue in HomeKit, as I can set the same temperature for both On and Off automations.

mkz212 commented 2 days ago

I believe the issue is related to this line of code, which turns the AC unit on when a set_target_temperature command is called:

// custom_components/panasonic_cc/pcomfortcloud/changerequestbuilder.py

@property
    def target_temperature(self) -> int | None:
        return self._request["temperatureSet"] if "temperatureSet" in self._request else None

    def set_target_temperature(self, new_value: int):
        """ Set target temperature """
        self._ensure_powered_on() // <---- THIS LINE
        self._request["temperatureSet"] = new_value
        return self

You can replicate the issue directly in HA by setting a temperature on a turned-off AC unit—it turns the unit back on.

If your AC is turned off and you select quiet mode it also turn on AC (see #325). So it is not only to set target temp. But this is not correct behaviour. Only set mode (auto/heat/cool/off) should turn AC on / off.

mkz212 commented 2 days ago

@peteger I see you're using HomeKit. Do you also have such an error as I described here : #323 ? Problem setting speed in HomeKit?

sockless-coding commented 2 days ago

The reason most calls has the self._ensure_powered_on() is because these actions requires the AC to be on when setting them from the App. Making requests not available in the app can result in "suspicious activity blocks".

peteger commented 2 days ago

The reason most calls has the self._ensure_powered_on() is because these actions requires the AC to be on when setting them from the App. Making requests not available in the app can result in "suspicious activity blocks".

Thank you, Jimmy. Does this mean you cannot set or get the target temperature if the AC unit is off? Would my suggested workaround be helpful in this situation? I appreciate your time and patience with us!

peteger commented 2 days ago

@peteger I see you're using HomeKit. Do you also have such an error as I described here : #323 ? Problem setting speed in HomeKit?

When I try to change the fan speed of the turned-off unit in HomeKit, it has no effect (the unit is not turned on).

mkz212 commented 2 days ago

@peteger I see you're using HomeKit. Do you also have such an error as I described here : #323 ? Problem setting speed in HomeKit?

When I try to change the fan speed of the turned-off unit in HomeKit, it has no effect (the unit is not turned on).

But when AC is turned on can you change speed via HomeKit?

mkz212 commented 2 days ago

The reason most calls has the self._ensure_powered_on() is because these actions requires the AC to be on when setting them from the App. Making requests not available in the app can result in "suspicious activity blocks".

Panasonic block IP for 24h when:

There is no blocking if you send set target temp or or other command when AC is turned off. I have automation that works every 15 minutes and it never blocked api (using Homebridge plugin for years with this setup).

So maybe make this function as option, to enable / disable in config?

peteger commented 2 days ago

@peteger I see you're using HomeKit. Do you also have such an error as I described here : #323 ? Problem setting speed in HomeKit?

When I try to change the fan speed of the turned-off unit in HomeKit, it has no effect (the unit is not turned on).

But when AC is turned on can you change speed via HomeKit?

I just tried and changing the fan speed does not have any effect on my AC unit.

mkz212 commented 2 days ago

@peteger I see you're using HomeKit. Do you also have such an error as I described here : #323 ? Problem setting speed in HomeKit?

When I try to change the fan speed of the turned-off unit in HomeKit, it has no effect (the unit is not turned on).

But when AC is turned on can you change speed via HomeKit?

I just tried and changing the fan speed does not have any effect on my AC unit.

Ok thank you. Same here. Everything works well in HomeKit, except speed. And turning on AC via commands that should not turn on AC (this behaviour exist also directly in HA).