Compare commits

...

10 Commits

32 changed files with 769 additions and 20 deletions

View File

@@ -1,6 +0,0 @@
Things I could do with a desk clamp:
- Strain relief for usb cables (3 or more)
- Holster for soldering iron
- Holsters for two magnifying glasses
Consider small one (usb cables) on right, larger one (magnifying glasses and maybe soldering iron) on left

View File

@@ -9,4 +9,8 @@ bedroom_tkm_lily2 192.168.87.47 esp32dev
bedroom_tkm_lily1 192.168.87.48 esp32dev ESP32 LilyGo T7 V1.5, with USB and battery
lr_bright_87_49 192.168.87.49 ESP32/wemos_d1_mini32
rf_bridge_87_60 192.168.87.60 esp01_1m Sonoff RF bridge
sonoff_s31a 192.168.87.71 esp01_1m
sonoff_s31a 192.168.87.71 esp01_1m Sonoff S31 power monitoring plug
sonoff_s31b 87.72 now DHCP esp01_1m Sonoff S31 power monitoring plug
sonoff-s31christmas 87.74 esp01_1m Sonoff S31 power monitoring plug
sonoff-s31e 87.75 now DHCP esp01_1m Sonoff S31 power monitoring plug
ifan04_a 192.168.87.73

29
ifan04.h Normal file
View File

@@ -0,0 +1,29 @@
#include "esphome.h"
using namespace esphome;
class IFan04Output : public Component, public FloatOutput {
public:
void write_state(float state) override {
if (state < 0.3) {
// OFF
digitalWrite(14, LOW);
digitalWrite(12, LOW);
digitalWrite(15, LOW);
} else if (state < 0.6) {
// low speed
digitalWrite(14, HIGH);
digitalWrite(12, LOW);
digitalWrite(15, LOW);
} else if (state < 0.9) {
// medium speed
digitalWrite(14, HIGH);
digitalWrite(12, HIGH);
digitalWrite(15, LOW);
} else {
// high speed
digitalWrite(14, HIGH);
digitalWrite(12, LOW);
digitalWrite(15, HIGH);
}
}
};

240
ifan04a.yaml Normal file
View File

@@ -0,0 +1,240 @@
substitutions:
device_name: ifan04a
friendly_name: iFan04-tim-office
device_ip: 192.168.87.73
<<: !include standard_wifi.yaml
captive_portal:
logger:
api:
ota:
web_server:
port: 80
time:
- platform: homeassistant
id: homeassistant_time
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
includes:
- ifan04.h
on_boot:
priority: 225
# turn off the light as early as possible
# no, turn it on - if somebody flips the switch, turn the light on
then:
- light.turn_on: ${device_name}_light
remote_receiver:
pin: GPIO3
binary_sensor:
- platform: gpio
id: button
pin:
number: GPIO0
on_press:
then:
- light.toggle: ${device_name}_light
- platform: remote_receiver
name: "Buzzer"
id: remote_buzzer
internal: true
raw:
code: [-207, 104, -103, 104, -104, 103, -104, 207, -104, 103, -104, 103, -104, 104, -103, 104, -103, 104, -104, 107, -721, 105, -206, 207, -518, 105, -931, 104, -104, 103, -725, 104, -104, 103, -725, 104, -104, 103, -207, 104, -414]
on_release:
then:
- switch.toggle: buzzer_dummy
- platform: remote_receiver
name: "Fan 0"
id: remote_0
raw:
code: [-207, 104, -103, 104, -104, 103, -104, 207, -104, 103, -104, 104, -103, 104, -104, 103, -104, 105, -102, 104, -725, 104, -311, 103, -518, 104, -933, 103, -104, 104, -725, 104, -932, 104, -207, 207, -519]
on_release:
then:
- fan.turn_off: ${device_name}_fan
internal: true
- platform: remote_receiver
id: remote_fan1
raw:
code: [-207, 104, -104, 103, -104, 104, -103, 207, -104, 104, -103, 104, -104, 103, -104, 104, -103, 104, -104, 103, -726, 103, -312, 103, -518, 104, -933, 103, -104, 104, -725, 104, -103, 104, -726, 103, -104, 311, -518]
on_release:
then:
- fan.turn_on:
id: ${device_name}_fan
speed: 1
- if:
condition:
and:
- switch.is_on: buzzer_dummy
then:
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
internal: true
- platform: remote_receiver
id: remote_fan2
raw:
code: [-208, 103, -104, 104, -103, 104, -103, 208, -103, 104, -104, 103, -104, 104, -103, 104, -104, 103, -104, 103, -726, 104, -310, 104, -518, 104, -933, 103, -104, 104, -725, 104, -207, 104, -622, 103, -416, 102, -415]
on_release:
then:
- fan.turn_on:
id: ${device_name}_fan
speed: 2
- if:
condition:
and:
- switch.is_on: buzzer_dummy
then:
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
- delay: 50ms
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
internal: true
- platform: remote_receiver
id: remote_fan3
raw:
code: [-207, 104, -104, 103, -104, 104, -103, 208, -103, 104, -104, 103, -104, 104, -103, 104, -104, 103, -104, 103, -726, 104, -311, 104, -518, 103, -934, 103, -103, 104, -726, 103, -104, 207, -622, 104, -103, 104, -207, 104, -415]
on_release:
then:
- fan.turn_on:
id: ${device_name}_fan
speed: 3
- if:
condition:
and:
- switch.is_on: buzzer_dummy
then:
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
- delay: 50ms
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
- delay: 50ms
- output.turn_on: buzzer
- delay: 50ms
- output.turn_off: buzzer
internal: true
- platform: remote_receiver
id: remote_light
raw:
code: [-207, 104, -103, 104, -104, 103, -104, 207, -104, 103, -104, 104, -103, 104, -103, 104, -104, 103, -104, 104, -725, 104, -311, 103, -518, 104, -933, 103, -104, 103, -726, 103, -311, 104, -518, 104, -207, 104, -103, 104, -414]
on_release:
then:
- light.toggle: ${device_name}_light
output:
- platform: custom
type: float
outputs:
id: fanoutput
lambda: |-
auto ${device_name}_fan = new IFan04Output();
App.register_component(${device_name}_fan);
return {${device_name}_fan};
- platform: gpio
pin: GPIO9
inverted: True
id: light_output
- platform: gpio
pin: GPIO10
id: buzzer
inverted: true
light:
- platform: binary
name: "${friendly_name} Light"
output: light_output
id: ${device_name}_light
switch:
- platform: template
id: buzzer_dummy
name: "Buzzer"
optimistic: True
- platform: template
id: update_fan_speed
optimistic: True
turn_on_action:
then:
- delay: 200ms
- if:
condition:
and:
- switch.is_off: fan_relay1
- switch.is_off: fan_relay2
- switch.is_off: fan_relay3
then:
- fan.turn_off: ${device_name}_fan
- if:
condition:
and:
- switch.is_on: fan_relay1
- switch.is_off: fan_relay2
- switch.is_off: fan_relay3
then:
- fan.turn_on:
id: ${device_name}_fan
speed: 1
- if:
condition:
and:
- switch.is_on: fan_relay1
- switch.is_on: fan_relay2
- switch.is_off: fan_relay3
then:
- fan.turn_on:
id: ${device_name}_fan
speed: 2
- if:
condition:
and:
- switch.is_on: fan_relay1
- switch.is_off: fan_relay2
- switch.is_on: fan_relay3
then:
- fan.turn_on:
id: ${device_name}_fan
speed: 3
- switch.turn_off: update_fan_speed
- platform: gpio
pin: GPIO14
id: fan_relay1
- platform: gpio
pin: GPIO12
id: fan_relay2
- platform: gpio
pin: GPIO15
id: fan_relay3
fan:
- platform: speed
output: fanoutput
id: ${device_name}_fan
name: "${friendly_name} Fan"
speed_count: 3

2
nightstand.bat Normal file
View File

@@ -0,0 +1,2 @@
esphome run .\nightstandtkm.yaml --device 192.168.87.45
esphome run .\nightstandljm.yaml --device 192.168.87.41

91
nightstandljm.yaml Normal file
View File

@@ -0,0 +1,91 @@
substitutions:
device_name: nightstandljm
#device_ip: 192.168.87.45
esphome:
name: ${device_name}
esp8266:
board: esp8285
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "RxgR/v9F6OQQmn37bnfqvgWlb2Img/TXKPFrHV88Cu8="
# key: "EgFzta0ZRgjSLEAfkzFDFlzs2ZDcs+2sD5LL7vSHSmE="
ota:
- platform: esphome
wifi:
ssid: "Meneely"
password: "punxsutawney1"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Nightstand LJM Fallback Hotspot"
password: "punxsutawney1"
captive_portal:
#######################################
# Device specific Config Begins Below #
#######################################
binary_sensor:
- platform: gpio
pin: GPIO00 # The built-in switch
id: reset
internal: true
filters:
- invert:
- delayed_off: 10ms
on_press:
- switch.toggle:
id: relay_1
- platform: gpio
name: ${device_name}_status
pin: GPIO04 # The external terminals
id: switch_1
filters:
- delayed_on: 100ms
on_press:
then:
- switch.toggle:
id: relay_1
# on_release:
# then:
# - switch.toggle:
# id: relay_1
switch:
- platform: gpio
name: ${device_name}_switch
icon: "mdi:lightbulb_outline"
pin: GPIO12
id: relay_1
restore_mode: restore_default_off
#status_led:
# pin:
# number: GPIO13
# inverted: true
output:
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: True
light:
# the 4 lines below define the Blue LED light on Sonoff Mini, to expose in HomeAssistant remove line "internal: true"
- platform: monochromatic
name: ${device_name}_blueled
output: blue_led
internal: true # hides the Blue LED from HomeAssistant

90
nightstandtkm.yaml Normal file
View File

@@ -0,0 +1,90 @@
substitutions:
device_name: nightstandtkm
#device_ip: 192.168.87.45
esphome:
name: ${device_name}
esp8266:
board: esp8285
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "EgFzta0ZRgjSLEAfkzFDFlzs2ZDcs+2sD5LL7vSHSmE="
ota:
- platform: esphome
wifi:
ssid: "Meneely"
password: "punxsutawney1"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Nightstand TKM Fallback Hotspot"
password: "punxsutawney1"
captive_portal:
#######################################
# Device specific Config Begins Below #
#######################################
binary_sensor:
- platform: gpio
pin: GPIO00 # The built-in switch
id: reset
internal: true
filters:
- invert:
- delayed_off: 10ms
on_press:
- switch.toggle:
id: relay_1
- platform: gpio
name: ${device_name}_status
pin: GPIO04 # The external terminals
id: switch_1
filters:
- delayed_on: 100ms
on_press:
then:
- switch.toggle:
id: relay_1
# on_release:
# then:
# - switch.toggle:
# id: relay_1
switch:
- platform: gpio
name: ${device_name}_switch
icon: "mdi:lightbulb_outline"
pin: GPIO12
id: relay_1
restore_mode: restore_default_off
#status_led:
# pin:
# number: GPIO13
# inverted: true
output:
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: True
light:
# the 4 lines below define the Blue LED light on Sonoff Mini, to expose in HomeAssistant remove line "internal: true"
- platform: monochromatic
name: ${device_name}_blueled
output: blue_led
internal: true # hides the Blue LED from HomeAssistant

61
sonoff-s31christmas.yaml Normal file
View File

@@ -0,0 +1,61 @@
substitutions:
device_name: sonoff-s31christmas
device_ip: 192.168.87.74
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
# platformio_options:
# upload_speed: 115200 #baud, tagging this so grep will find it later
<<: !include standard_wifi.yaml
logger:
baud_rate: 0 # (UART logging interferes with cse7766)
api:
# reboot_timeout: 15min
ota:
# Device Specific Config
uart:
rx_pin: RX
baud_rate: 4800
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: ${device_name}_button
on_press:
- switch.toggle: relay
- platform: status
name: ${device_name}_status
sensor:
- platform: wifi_signal
name: ${device_name}_wifi
update_interval: 60s
- platform: cse7766
current:
name: ${device_name}_current
accuracy_decimals: 1
voltage:
name: ${device_name}_voltage
accuracy_decimals: 1
power:
name: ${device_name}_power
accuracy_decimals: 1
switch:
- platform: gpio
name: ${device_name}_relay
pin: GPIO12
id: relay
status_led:
pin: GPIO13

71
sonoff-s31e.yaml Normal file
View File

@@ -0,0 +1,71 @@
substitutions:
device_name: sonoff-s31e
# device_ip: 192.168.87.75
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
on_boot:
- switch.turn_on: relay
# platformio_options:
# upload_speed: 115200 #baud, tagging this so grep will find it later
#<<: !include standard_wifi.yaml
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# manual_ip:
# # static_ip: ${device_ip}
# gateway: 192.168.86.1
# subnet: 255.255.254.0
fast_connect: True
logger:
baud_rate: 0 # (UART logging interferes with cse7766)
api:
# reboot_timeout: 15min
ota:
# Device Specific Config
uart:
rx_pin: RX
baud_rate: 4800
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: ${device_name}_button
on_press:
- switch.toggle: relay
- platform: status
name: ${device_name}_status
sensor:
- platform: wifi_signal
name: ${device_name}_wifi
update_interval: 60s
- platform: cse7766
current:
name: ${device_name}_current
accuracy_decimals: 1
voltage:
name: ${device_name}_voltage
accuracy_decimals: 1
power:
name: ${device_name}_power
accuracy_decimals: 1
switch:
- platform: gpio
name: ${device_name}_relay
pin: GPIO12
id: relay
status_led:
pin: GPIO13

71
sonoff-s31f.yaml Normal file
View File

@@ -0,0 +1,71 @@
substitutions:
device_name: sonoff-s31f
# device_ip: 192.168.87.75
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
on_boot:
- switch.turn_on: relay
# platformio_options:
# upload_speed: 115200 #baud, tagging this so grep will find it later
#<<: !include standard_wifi.yaml
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# manual_ip:
# # static_ip: ${device_ip}
# gateway: 192.168.86.1
# subnet: 255.255.254.0
fast_connect: True
logger:
baud_rate: 0 # (UART logging interferes with cse7766)
api:
# reboot_timeout: 15min
ota:
# Device Specific Config
uart:
rx_pin: RX
baud_rate: 4800
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: ${device_name}_button
on_press:
- switch.toggle: relay
- platform: status
name: ${device_name}_status
sensor:
- platform: wifi_signal
name: ${device_name}_wifi
update_interval: 60s
- platform: cse7766
current:
name: ${device_name}_current
accuracy_decimals: 1
voltage:
name: ${device_name}_voltage
accuracy_decimals: 1
power:
name: ${device_name}_power
accuracy_decimals: 1
switch:
- platform: gpio
name: ${device_name}_relay
pin: GPIO12
id: relay
status_led:
pin: GPIO13

View File

@@ -6,18 +6,10 @@ esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
# platformio_options:
# upload_speed: 115200 #baud, tagging this so grep will find it later
wifi:
ssid: "Meneely"
password: "punxsutawney1"
manual_ip:
static_ip: ${device_ip}
gateway: 192.168.86.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "ESPHOME"
password: "12345678"
<<: !include standard_wifi.yaml
logger:
baud_rate: 0 # (UART logging interferes with cse7766)
@@ -66,4 +58,4 @@ switch:
id: relay
status_led:
pin: GPIO13
pin: GPIO13

61
sonoff_s31b.yaml Normal file
View File

@@ -0,0 +1,61 @@
substitutions:
device_name: sonoff_s31b
device_ip: 192.168.87.72
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
# platformio_options:
# upload_speed: 115200 #baud, tagging this so grep will find it later
<<: !include standard_wifi.yaml
logger:
baud_rate: 0 # (UART logging interferes with cse7766)
api:
# reboot_timeout: 15min
ota:
# Device Specific Config
uart:
rx_pin: RX
baud_rate: 4800
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: ${device_name}_button
on_press:
- switch.toggle: relay
- platform: status
name: ${device_name}_status
sensor:
- platform: wifi_signal
name: ${device_name}_wifi
update_interval: 60s
- platform: cse7766
current:
name: ${device_name}_current
accuracy_decimals: 1
voltage:
name: ${device_name}_voltage
accuracy_decimals: 1
power:
name: ${device_name}_power
accuracy_decimals: 1
switch:
- platform: gpio
name: ${device_name}_relay
pin: GPIO12
id: relay
status_led:
pin: GPIO13

View File

@@ -1 +0,0 @@
Sonoff Mini: External switcth contacts are currently for a stay-in-place toggle switch. Change to momentary contact and debounce.

44
treatlife_ss01s_a.yaml Normal file
View File

@@ -0,0 +1,44 @@
substitutions:
device_name: treatlife_ss01s_a
device_ip: 192.168.87.76
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
# platformio_options:
# upload_speed: 115200 #baud, tagging this so grep will find it later
<<: !include standard_wifi.yaml
logger:
baud_rate: 0 # (UART logging interferes with cse7766)
api:
# reboot_timeout: 15min
ota:
# Device Specific Config
switch:
- platform: gpio
id: "relay"
name: "light"
pin: 12
output:
- platform: esp8266_pwm
id: status_led
pin:
number: GPIO4
inverted: True
binary_sensor:
- platform: gpio
name: "button"
pin:
number: 13
inverted: True
on_press:
- switch.toggle: relay