As I mentioned, my first step is to ignore the RS485 stuff and get the hot button mechanism working with this new hardware setup. Because I used ESPHome, things are mostly abstracted. Here are the changes I made based on testing the new assembly:
- Changed the node name to "hotbuttonrelay-al" ("al" for Atom Lite) to prevent a collision with the existing hardware.
- Modify the board definition and the referenced GPIO pins for the button and the relay trigger.
- I don't have an overly convenient way to wire in the BME280 climate sensor, so I just deleted that definition along with the I2C bus. (I have plenty of temperature sensors around the house, so no biggie).
- The Atom Lite doesn't have the usual on-board LED of typical ESP8266 or ESP32 development boards. Instead, it has a more sophisticated RGB LED. I redefined that as an ESPHome RGB light object using the fastled platform. (The compilation of the fastled libraries always gives a pile of warnings, but they don't seem harmful so far.)
- The mini relay board does not have an LED for visual feedback, so I configured the Atom Light LED to turn on and off colored green with the relay activation. Since the Atom Light is the same component used for the remote hot buttons, I cloned that bit of YAML to have it use the same hot and cold lighting effects. The relay activation uses 500ms. All the other handshaking and activity happens faster than that, so I put in a 600ms delay before the hot lighting effect starts. That lets me see the brief green signal for the relay activation.
Here's the YAML so far:
# https://hackaday.io/project/202744-calling-for-hot-water-the-recall
substitutions:
node_name: hotbuttonrelay-al
RELAY: 'GPIO26'
LED: 'GPIO27'
BUTTON: 'GPIO39'
log_level: 'DEBUG'
esphome:
name: ${node_name}
on_boot:
then:
# delay to allow other boot time stuff to settle down
- delay: 5s
- script.execute: set_led_cold
esp32:
board: pico32
wifi:
ssid: !secret wifi_ssid
id: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: high
fast_connect: on
manual_ip:
static_ip: !secret hotbuttonrelay-al_ip
gateway: !secret wifi_gateway
subnet: !secret wifi_subnet
dns1: !secret wifi_dns1
dns2: !secret wifi_dns2
logger:
level: ${log_level}
api:
encryption:
key: !secret hotbuttonrelay-al_apikey
reboot_timeout: 60min
services:
- service: set_led_hot
then:
- logger.log:
tag: 'hotbutton'
level: INFO
format: "service: set_led_hot"
- script.execute: set_led_hot
- service: set_led_cold
then:
- logger.log:
tag: 'hotbutton'
level: INFO
format: "service: set_led_cold"
- script.execute: set_led_cold
- service: set_led_off
then:
- logger.log:
tag: 'hotbutton'
level: INFO
format: "service: set_led_off"
- script.execute: set_led_off
ota:
platform: esphome
password: !secret ota_password
switch:
- platform: restart
name: "${node_name} Reboot"
- platform: gpio
id: i_relay
name: '${node_name} relay'
pin: '${RELAY}'
restore_mode: ALWAYS_OFF
icon: mdi:hot-tub
on_turn_on:
- light.turn_on:
id: bright_light
red: 0%
green: 100%
blue: 0%
- delay: 500ms
- switch.turn_off: i_relay
- light.turn_off:
id: bright_light
# Local test button. This goes through the relay logic,
# so it's not an analog press of the water heater button.
binary_sensor:
- platform: gpio
name: "${node_name} Button"
id: i_button
pin:
number: '${BUTTON}'
inverted: true
mode:
input: true
filters:
- delayed_on: 10ms
- delayed_off: 10ms
light:
- platform: fastled_clockless
id: bright_light
name: ${node_name} LED
chipset: SK6812
pin: '${LED}'
num_leds: 1
rgb_order: GRB # required
default_transition_length: 0s
icon: mdi:led-on
effects:
- pulse:
name: fast_pulse
transition_length: 0.25s
update_interval: 0.25s
min_brightness: 20%
max_brightness: 99%
script:
- id: set_led_hot
then:
- delay: 600ms # give the relay blink a chance to show
- light.turn_on:
id: bright_light
red: 100%
green: 60%
blue: 0%
effect: fast_pulse
- id: set_led_cold
then:
- light.turn_on:
id: bright_light
color_brightness: 20%
red: 0%
green: 0%
blue: 100%
effect: none
- id: set_led_off
then:
- light.turn_on:
id: bright_light
color_brightness: 0%
red: 0%
green: 0%
blue: 0%
effect: noneA side note for you young tinkerers: The first time I uploaded the firmware, I forgot to change the configured static IP. That meant an IP address collision with the existing hardware. In short order, both devices were knocked off the air. Don't be like me!
Without physically hooking this new assembly to the water heater, I tested it by configuring it into my Home Assistant automation that glues everything together. Everywhere that I have a reference to the old equipment in the automation and script, I made a cloned reference that instead references the new equipment. That means that the automation activates both the old and new relays. I can hear the tiny click when the new relay is activated.
WJCarpenter
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.