[ 이 글은 21년 7월에 HA 카페에 올렸던 것으로, 개인 자료화 하고자 다시 올립니다. ]
안녕하세요.
이 카페에서 많은 능력자님들의 도움을 많이 받았기에... 저도 이렇게 글을 올려보려고 합니다.
제가 한 것은, 다름이 아니라 완전히 구형, 즉, 버튼만 있는 선풍기에 sonoff basic을 달아서 밤새 켰다 꺼졌다가 하도록 한 것입니다. 항상 타이머 맞추지만, 꺼지고 나면 더워서 깨는게 약간의 짜증?을 유발시켜서 시작하였습니다.
이 방법이 그나마 최신(?) 리모컨 있는 선풍기보다 낫다는 생각이 드네요. ㅎㅎ
요즘같은 어중간한 밤더위에는 선풍기로도 괜찮은듯 합니다.
제가 가진 선풍기는 수년전에 홈플XX에서 구입한 것입니다. 100% 수동이죠. 리모컨도 없는...

그 선풍기를 뜯어서, 아래와 같이 sonoff basic을 달아 주었습니다.
아래 그림은 테스터 하다가 찍은 사진이지만, 전원선 연결시에는 전선에 납땜도 하고 전기테이프로 잘 감아주었습니다.
무엇보다 안전이 최우선이지요.
글루건으로 sonoff basic도 잘 고정 시켜 주었구요.

우선, sonoff basic에는 tasmota를 설치하고, booting시 'ON'되도록 조치하여 전원을 꽂으면 이전처럼 동작하게 만들었습니다. 이 카페에도 많은 분들의 참고 자료가 있지만 저는 아래 유튜브 영상의 도움을 받았습니다.
* 참고 영상 : https://www.youtube.com/watch?v=xFgs8dKkahE
그 다음은, 구성하기 - 도우미 에 들어가서 아래와 같이 5개의 버튼, 숫자, 시간을 만들었습니다.
fan_nightmode_start/end는 "시간"으로 설정하였습니다.



automation.yaml 에 아래의 2가지를 추가하였습니다.
fan_night_mode와 fan_night_mode_off 입니다.
fan_night_mode_off는 야간 반복 모드 off시, script.fan_123을 reset시켜 주기 위함입니다.
alias: fan_night_mode
description: ''
trigger:
- platform: state
entity_id: input_boolean.fan_night_mode
to: 'on'
from: 'off'
condition: []
action:
- service: script.fan_123
mode: single
alias: fan_night_mode _off
description: ''
trigger:
- platform: state
entity_id: input_boolean.fan_night_mode
to: 'off'
from: 'on'
condition: []
action:
- service: script.turn_off
target:
entity_id: script.fan_123
mode: single
아래는 UI mode로 작성했으나, '{{ states(''input_number.fan_ontime'') | multiply(60) | int }}' 가 들어가면서 자동으로 UI 모드가 풀리게 되었습니다.
fan ON과 fan OFF가 1 set로 동작하도록 하여서, ON mode후 "야간 반복 모드"를 끄게 되면, 1 set가 그대로 이어서 수행되어 automation.fan_night_mode_off 를 추가해 주었습니다.
alias: fan_123
sequence:
- repeat:
while:
- condition: time
after: input_datetime.fan_nightmode_start
before: input_datetime.fan_nightmode_end
- condition: state
entity_id: input_boolean.fan_night_mode
state: 'on'
sequence:
- service: switch.turn_on
target:
entity_id: switch.sonoff_basic_81
- delay: '{{ states(''input_number.fan_ontime'') | multiply(60) | int }}'
- service: switch.turn_off
target:
entity_id: switch.sonoff_basic_81
- delay: '{{ states(''input_number.fan_offtime'') | multiply(60) | int }}'
mode: single
그 다음은 lovelace에서 아래와 같이 심플하게 추가하였습니다.
잘 꾸미려고 했으나 잘 안되었네요. 어느 글에서 봤습니다만... 공돌이에게 예술은 사치다... 라던가요? ㅎㅎ
테스트를 위해서 "켜진시간", "꺼진시간" 을 1분씩으로 입력하였습니다.
예를들어, 여기에 20분, 10분 으로 입력하면 20분 켜지고, 10분 꺼지고 이렇게 반복 동작합니다.

lovelace에 추가한 code 입니다. (저는 UI 모드로 진행하였습니다.)
type: entities
entities:
- entity: switch.sonoff_basic_81
icon: mdi:fan
name: 선풍기 ON/OFF
title: 선풍기 켜고 끄기
state_color: true
type: entities
entities:
- entity: input_boolean.fan_night_mode
name: 야간 반복 모드
icon: mdi:fan
- entity: input_number.fan_ontime
name: 켜진시간(단위:분)
- entity: input_number.fan_offtime
name: 꺼진시간(단위:분)
- entity: input_datetime.fan_nightmode_start
name: 반복모드 시작시간
- entity: input_datetime.fan_nightmode_end
name: 반복모드 마침시간
state_color: true
title: 선풍기 야간 반복 모드
이상 간단한 구형 선풍기의 자동화였습니다.
감사합니다~
댓글