Last active
November 15, 2024 01:36
-
-
Save Snipercaine/75fcfbb14f8dabc8918d7d6723501821 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## this part is the ESPhome Yaml file ## | |
esphome: | |
name: window_control_linear | |
platform: ESP8266 | |
board: d1_mini | |
wifi: | |
ssid: !secret wifi | |
password: !secret wifi_pw | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
ota: | |
output: | |
- platform: gpio | |
id: 'win_1' | |
pin: D1 | |
- platform: gpio | |
id: 'win_2' | |
pin: D2 | |
switch: | |
- platform: output | |
name: "win1" | |
output: 'win_1' | |
id: win1 | |
- platform: output | |
name: "win2" | |
output: 'win_2' | |
id: win2 | |
cover: | |
- platform: template | |
name: "Window Control" | |
id: win_open | |
optimistic: true | |
open_action: | |
- switch.turn_off: win2 | |
- switch.turn_on: win1 | |
- delay: 360s | |
- switch.turn_off: win1 | |
close_action: | |
- switch.turn_off: win1 | |
- switch.turn_on: win2 | |
- delay: 360s | |
- switch.turn_off: win2 | |
stop_action: | |
- switch.turn_off: win1 | |
- switch.turn_off: win2 | |
binary_sensor: | |
- platform: gpio | |
pin: D3 | |
name: "Window Control Button" | |
filters: | |
invert: | |
on_press: | |
then: | |
- lambda: | | |
if (id(win_open).state == cover::COVER_OPEN) { | |
if (id(win1).state){ | |
// window is opening | |
id(win_open).stop(); | |
} else { | |
// window is open and not moving | |
id(win_open).close(); | |
} | |
} else { | |
if (id(win2).state){ | |
// window is closing | |
id(win_open).stop(); | |
} else { | |
// win is closed and not moving | |
id(win_open).open(); | |
} | |
} | |
## this part goes in your Configuration.yaml ## | |
switch: | |
- platform: mqtt | |
name: "QuietCool Low" | |
command_topic: "cmnd/QuietCool/power1" | |
state_topic: "stat/QuietCool/POWER1" | |
qos: 1 | |
payload_on: "ON" | |
payload_off: "OFF" | |
retain: false | |
- platform: mqtt | |
name: "QuietCool Med" | |
command_topic: "cmnd/QuietCool/power2" | |
state_topic: "stat/QuietCool/POWER2" | |
qos: 1 | |
payload_on: "ON" | |
payload_off: "OFF" | |
retain: false | |
- platform: mqtt | |
name: "QuietCool High" | |
command_topic: "cmnd/QuietCool/power3" | |
state_topic: "stat/QuietCool/POWER3" | |
qos: 1 | |
payload_on: "ON" | |
payload_off: "OFF" | |
retain: false | |
## if you want to use the iOS Notifications (you'll need the iOS app too, duh)## | |
ios: | |
push: | |
categories: | |
- name: quietcool | |
identifier: 'quietcool' | |
actions: | |
- identifier: 'QC_LOW' | |
title: 'Fan on Low 1 hr' | |
- identifier: 'QC_MED' | |
title: 'Fan on Medium 1 hr' | |
- identifier: 'QC_HIGH' | |
title: 'Fan on High 1 hr' | |
## this part goes in your Automations.yaml ## | |
- alias: window open when quietcool fan is on | |
id: openwindowwhenquietcoolfanison2875478945y34y | |
trigger: | |
- platform: state | |
entity_id: switch.quietcool_low | |
from: 'off' | |
to: 'on' | |
- platform: state | |
entity_id: switch.quietcool_med | |
from: 'off' | |
to: 'on' | |
- platform: state | |
entity_id: switch.quietcool_high | |
from: 'off' | |
to: 'on' | |
condition: | |
- condition: state | |
entity_id: binary_sensor.theater_windows | |
state: 'off' | |
action: | |
- service: cover.open_cover | |
entity_id: cover.window_control | |
- alias: window close when quietcool fan is off | |
id: openwindowwhenquietcoolfanisoff28543545345345 | |
trigger: | |
- platform: state | |
entity_id: switch.quietcool_low | |
from: 'on' | |
to: 'off' | |
- platform: state | |
entity_id: switch.quietcool_med | |
from: 'on' | |
to: 'off' | |
- platform: state | |
entity_id: switch.quietcool_high | |
from: 'on' | |
to: 'off' | |
condition: | |
- condition: state | |
entity_id: binary_sensor.theater_windows | |
state: 'on' | |
action: | |
- service: cover.close_cover | |
entity_id: cover.window_control | |
- alias: temperature to start quietcool fan | |
id: temptostartqcfan7487238945y | |
trigger: | |
- platform: time | |
at: '07:00:00' | |
- platform: time | |
at: '20:00:00' | |
condition: | |
- condition: numeric_state | |
entity_id: sensor.yr_temperature | |
above: 50 | |
below: 68 | |
- condition: numeric_state | |
entity_id: sensor.upstairs_temp | |
above: 70 | |
action: | |
- service: notify.ios_justin_iphone7 | |
data: | |
title: It's really nice outside | |
message: Shall I open the window and turn on the fan? | |
data: | |
push: | |
category: "quietcool" | |
- alias: QCfanlow | |
id: qcfanlow234234234 | |
trigger: | |
platform: event | |
event_type: ios.notification_action_fired | |
event_data: | |
actionName: QC_LOW | |
action: | |
- service: switch.turn_on | |
entity_id: switch.quietcool_low | |
- delay: 01:00:00 | |
- service: switch.turn_off | |
entity_id: switch.quietcool_low | |
- alias: QCfanMed | |
id: qcfanmed234234234 | |
trigger: | |
platform: event | |
event_type: ios.notification_action_fired | |
event_data: | |
actionName: QC_MED | |
action: | |
- service: switch.turn_on | |
entity_id: switch.quietcool_med | |
- delay: 01:00:00 | |
- service: switch.turn_off | |
entity_id: switch.quietcool_med | |
- alias: QCfanHigh | |
id: qcfanhigh234234234 | |
trigger: | |
platform: event | |
event_type: ios.notification_action_fired | |
event_data: | |
actionName: QC_HIGH | |
action: | |
- service: switch.turn_on | |
entity_id: switch.quietcool_high | |
- delay: 01:00:00 | |
- service: switch.turn_off | |
entity_id: switch.quietcool_high |
Hi guys.
could you please help me to get this to work with a PIR sensor?
thanks, Justin! (@Snipercaine) it works great with the contact sensor, but I have no idea how to accomplish that with PIR to make sure that if there's an obstacle next to the door, it won't close (my dog...)
in the cover, could I achieve that? to have conditions that the PIR will act as the safety mechanism so that it won't close on my dog's head?
`cover:
- platform: template
name: "Nella Window Controller"
id: win_open
optimistic: true
open_action:- switch.turn_off: win2
- switch.turn_on: win1
- delay: 50s
- switch.turn_off: win1
close_action: - while:
condition: {lambda: "while (binary_sensor.pir_sensor)"}
then:
- condition: state
stop_action:# entity_id: sensor.breakbeam_sensor_dist ### maybe we need a while loop? to constantly check if the beam is not broken while closing the window? # state: "off" - switch.turn_on: win2 - delay: 50s - switch.turn_off: win2
- switch.turn_off: win1
- switch.turn_off: win2`
am I getting close? :/
is the code still vallid?
i tried getting it to work with no success....
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
with latest esphome this doesn't work, need to change
id(win_open).state
toid(win_open).position
in the Lamda function