KaufHA / kauf-rgb-switch

Files for the KAUF RGB Wall Switch
21 stars 8 forks source link

Relay forced into Always On mode #6

Closed JoshHawley closed 1 year ago

JoshHawley commented 1 year ago

When I intially installed 2 of these switches they worked great. I have one that controls the power to the lights using a relay, and another one setup through HA to simulate a 3-way switch configuration. This worked great for a while.

I'm not sure when, but at some point the switches rebooted (due to a power outage I think), and the relay would not switch. I found that the relay mode had changed from switched to always on. I changed the setting on the web page, and normal functionality was restored. After further troubleshooting, I discovered that this happens every time it reboots.

My yaml file does not configure any of the settings, this file is referenced in the config: github://KaufHA/kauf-rgb-switch/yaml-features/rotate-colors-sync-to-ha-light.yaml Inside this file is the following:

esphome:
  on_boot:
    then:
      - select.set:
          id: select_button
          option: "Toggle on Release"
      - if:
          condition:
            lambda: return (!$stay_switched && (id(select_relay).state == "Switched") );
          then:
            - select.set:
                id: select_relay
                option: "Always On"

It appears to always be overwriting the setting. Why is this? Is this intended behavior?

My yaml is pretty basic:

substitutions:
  name: "kit-overhead-sw"
packages:
  rotate: github://KaufHA/kauf-rgb-switch/yaml-features/rotate-colors-sync-to-ha-light.yaml
  Kauf.RGBSw: github://KaufHA/kauf-rgb-switch/kauf-rgbs.yaml
esphome:
  name: ${name}
  name_add_mac_suffix: false

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  use_address: -Redacted-
bkaufx commented 1 year ago

When I made that rotate-colors-sync-to-ha-light.yaml I had intended it to be controlling a smart bulb so the relay wouldn't be needed or would need to always be on so that the bulb would keep power. That's why the default is to switch to always on. If you want the relay to be switched, you need to add the following substitution to your yaml.

stay_switched: 'true'

JoshHawley commented 1 year ago

Ahh that makes sense. I like the color changing of the button's light (and my family does too), but its controlling the dumb lights in our kitchen. Thanks for the help