12v Switches Hardwired

New here, but can solder and stumble my way through programming. I had a plan for my RV with Blynk and ESP 8266s but now that Blynk has changed and HA has matured, I’m looking into it.

Main question: Can I hardwire lights and switches to work without HA and still show the proper on/off in HA? I can’t handle only network access, I’d really like to hit a button or switch and have the light turn on regardless of the network status. Plan with Blynk was to wire a switch to an ESP that would trigger a relay to turn the light on. Blynk would read the ESP and report the proper on/off status. If the connection to the Blynk hardware didn’t work, the physical ESP would still trigger the relay and turn the light on.

Is that possible in HA and how? Thank you!

Anyone? Bueller?

Not sure I understand how you are planning on connecting it.

But I believe it would be possible.
If I’m not mistaking that is how Shelly works.
You have a “trigger button”, it (could be) 12 volts and it shows the state in HA when there is network.

Thanks but Shelly requires 120v to operate. I guess I’m trying to figure out how I would make it work in HA.

With Blynk, I’d have an ESP8266 with a button that connects a pin to ground on the board. When the board sees ground on that pin, the board then sends a signal via another pin to a relay that turns on the light. Blynk reads that ground signal received from the board and updates to UI to note that the light is on. If there is no network connected at all or there is an issue with the Blynk server, the board still turns on the light regardless.

Thanks for the reply!

Look at the specs, or the pictures.

If you are using an esp, then esphome is the way to go. You can use a relay to turn the light on and also wire a switch to the esp.

You would be able to turn it on/off physically and through home assistant. It will show the correct state regardless of the turn on/off method.

You could do the same setup in ESP-Home.
You could even connect a wire between the relay output back to a pin on the ESP BUT with a voltage divider.
That way you can get the relay position.

Thank you!
I’ll look into ESP Home a little deeper as well. Hellis81 suggested wiring back to the ESP to see the state of the relay, but it sounds like your suggestion would not need it. Will ESP Home and HA stay in sync even if the relay is triggered outside of HA?
Thanks for taking the time to help a newb :slight_smile:

That depends on the switch.
If it’s momentary button then no.
If it’s a switch then yes.

1 Like

To me that’s backward. A switch will be problematic. If the switch is in the on position and the light is shut off from HA, you’d need to turn the switch off then on, to turn the light back on.

You’d need a momentary button. Then use

switch:

##Button config
  - platform: gpio
    pin: an unused pin
    id: light_switch
##    name: "My Light Switch" omit name to keep entity hidden from frontend, state is irrelvant
    on_turn_on:
    - delay: 250ms ##this requires the switch to be held x amount of time before triggering
    - switch.toggle: light_relay


##Relay config
  - platform: gpio
    pin: different unused pin
    id: light_relay
    name: "Light Relay"

Is there no on_toggle action?
That would work for a switch.

But you are right I was thinking backwards…

I would probably still use a feedback from the relay (if that is possible) to get the true state given that relays have a tendency to stick.

1 Like

That would give you two switch entities. ‘Light Relay’ would always be the actual state.
“My Light Switch” would toggle back and forth.

If you exclude the name of the momentary button switch, it will stay internal and not show in HA’s frontend. I’m editing the above to reflect that since the button switch state is irrelevant.

After a lot of digging, I found this thread: ESPHome 3ch relay and switch

It seems from this thread, I should just plan on wiring momentary buttons instead of switches. Seems like that would make life so much easier, except for outside lights, where you really need feedback from something to know if the light is actually off or not… So possible a momentary button with an led for feedback? Possibly the button Hellis81 linked to could be wired to the relay to turn on the led when the relay is active. That is a lot of extra wiring, but kind of makes sense I guess.

Any other ideas on providing feedback? Thanks again guys!

Perhaps a Sonoff 4 ch pro?

I don’t have one myself but it looks like it has LEDs to indicate on/off.
But not sure.

Read again:
POWER
Power supply AC 110-230V ±10%, 50/60Hz
Power supply DC 12V, 24 – 60V
Dry contacts Yes

So Shelly can use either AC or DC (set with a jumper).
Shelly is blizz to configure; it can re-use existing switches ’as-is’ (including the two-way hotelswitch); doesn’t need cloud (nor app) to configure, has some limited timer options and works fine without HA too.

1 Like

Yes that button has a separate pin that controls the led. You would create another switch to control the led and toggle it with the relay.

switch:

##Button config
  - platform: gpio
    pin: an unused pin
    id: light_switch
##    name: "My Light Switch" omit name to keep entity hidden from frontend, state is irrelvant
    on_turn_on:
    - delay: 250ms ##this requires the switch to be held x amount of time before triggering
    - switch.toggle: light_relay
    - switch.toggle: led_status


##Relay config
  - platform: gpio
    pin: different unused pin
    id: light_relay
    name: "Light Relay"

## LED config
  - platform: gpio
    pin: different unused pin
    id: led_status


You might consider a momentary rocker switch (spdt, center off) tied to the ESP to control on/off state. You will have fewer problems with contact bounce. The interface to HA could control the same state. I’d consider using a properly protected solid-state device (like a MOSFET) to control the 12 volts. It’d be more reliable and use less power than a relay.

The state information would always be from the ESP; no need for the relay state unless it’s a latching relay. If you use a latching relay, it can become the non-volatile memory device. You’d need to sense it’s position with a either separate contact or a voltage monitor on the relay output contact. If you pick an ESP device with flash user memory, it could remember the last-commanded state and restore the state at power-on.

One thing you need to remember is to properly isolate the ESP and the HA host from your 12 volt power source when the RV is not in use. Specifically, you don’t want the ESP to become a parasitic load to the RV battery unless it’s properly isolated by the vehicle’s power relay. Given enough time, even a milliamp load can drain a battery.

FWIW, I’d expect the ESP to be up and running before HA boots itself to an operational state.

1 Like

Looks like the Sonoff is only 120v and doesn’t have the capability for a manual switch…

Thank you. I’m leaning towards a momentary button setup with some sort of visual feedback. The system needs to be completely usable and user friendly for someone without a device.
I’ll look into mosfet devices as well.
The RV is pretty self-sufficient power wise, and does have a main battery disconnect that isolates everything when in storage.
I think hard wiring visual feedback is the way to go for me. When you toggle a light on from the button or HA, an led lights up letting you know the light is on. Hit the button or toggle it in HA and the light goes off. Another wire from the relay output to the led should do the trick I think.

1 Like

In case you missed it, there is a thread for RV/marine use. You may find it helpful.