Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions helper_scripts/templates/switch_custom.js.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ const romasku = {
const parts = value.slice(0, -1).split(';'); // Drop last ;
if (parts.length < 2) throw new Error("Model and/or manufacturer missing");
for (const part of parts.slice(2)) {
if (part[0] == 'B' || part[0] == 'S') {
if (part == 'SLP') {
continue;
} if (part[0] == 'B' || part[0] == 'S') {
validatePin(part.slice(1,3));
if (!["u", "U", "d", "f"].includes(part[3])) {
throw new Error(`Pull up down ${part[3]} is invalid. Valid options are u, U, d, f`);
Expand All @@ -176,7 +178,7 @@ const romasku = {
} else if(part[0] == 'M') {
;
} else if(part[0] == 'i') {
; // TODO: write validatetion
; // TODO: write validation
} else {
throw new Error(`Invalid entry ${part}. Should start with one of B, R, L, S, I`);
}
Expand Down
2 changes: 2 additions & 0 deletions helper_scripts/templates/zha_quirk.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ for config in CONFIGS:
indicators_cnt = 0
has_dedicated_net_led = False
for peripheral in peripherals:
if peripheral == "SLP":
continue
if peripheral[0] == "R":
relay_cnt += 1
if peripheral[0] == 'S':
Expand Down
15 changes: 4 additions & 11 deletions src/base_components/relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stddef.h>

#ifndef RELAY_PULSE_MS
#define RELAY_PULSE_MS 125
#define RELAY_PULSE_MS 100
#endif

#ifndef PULSE_WAIT_END_MS
Expand Down Expand Up @@ -61,13 +61,9 @@ void relay_init(relay_t *relay) {
relay->latching_task.arg = relay;
hal_tasks_init(&relay->latching_task);

// switch off relay
if (!relay->off_pin) {
// Normal relay
hal_gpio_write(relay->pin, !relay->on_high);
} else {
// Bi-stable relay
hal_gpio_write(relay->pin, !relay->on_high);
// Turn off all pins
hal_gpio_write(relay->pin, !relay->on_high);
if (relay->off_pin) {
hal_gpio_write(relay->off_pin, !relay->on_high);
}
}
Expand Down Expand Up @@ -100,9 +96,6 @@ void relay_off(relay_t *relay) {
}
printf("relay_off\r\n");

// Clear both pins
hal_gpio_write(relay->pin, !relay->on_high);

relay->on = 0;
if (!relay->off_pin) {
// Normal relay
Expand Down