Hope this will give other user ideas and a little bit of help
Ill keep add to this as I think of more ideas on making the FAN SMARTER
with the help of HA
2 replay 1 for on/off other one for speed (off= low / on=high
Yellow is the hot wire
red = low speed
black = high speed
Blue is power on/off
red vcc 5v form the Wemos
black gound form wemos
yellow D1 on the wemos relay1
other yellow D8 on the wemos relay2
red vcc 3+ on the wemos
yellow D2 on the wemos
black GND
red vcc 3+
yellow D4 of the wemos
black ground
need to of theres Capacitive Touch Switch
Black ground
Yellow D7 switch 1
red vcc 3+
other one
black ground
yellow D5 switch 2
red vcc 3+
with it hot glue in place had to take the old push switch on the inside
the DHT11 on the back of the fan
motion senser on the front
I flash the wemos with tasmota 5.13
setting up the GPIO pins in Tasmota
Switch3 is the motion senser how to add a relay3 to so it would send the MQTT commands
in the Console of tasmota
need to set the switchMode
so
Switchmode1 4
and
switchmode2 4
this make them puhbuttons
if job done right the home screen should look like this
toggle 1 is relay 1 fan on/off
toggle 2 is relay 2 fan speed on high off low
toggle 3 is the montion senser
yeap tasmota is sending the MQTT messages
only problem had was the motion senser would send a ON and them send the OFF
dont want that
I used node-red to fix it
here is the commands
[{"id":"52127a09.656d34","type":"mqtt in","z":"52e056f1.f36ff8","name":"Office Motion","topic":"stat/SONOFF-FAN/POWER3","qos":"2","broker":"d3f7744e.a9cb78","x":70,"y":20,"wires":[["23361fe8.1754b"]]},{"id":"9e920ab6.f68048","type":"debug","z":"52e056f1.f36ff8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":100,"wires":[]},{"id":"cfe6a421.aa0598","type":"delay","z":"52e056f1.f36ff8","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":120,"y":200,"wires":[["e681dcb8.4aa1c"]]},{"id":"e7c5d7f4.3c23e8","type":"mqtt out","z":"52e056f1.f36ff8","name":"","topic":"nodered/motion","qos":"","retain":"","broker":"d3f7744e.a9cb78","x":700,"y":20,"wires":[]},{"id":"23361fe8.1754b","type":"function","z":"52e056f1.f36ff8","name":"","func":"if (msg.payload ==\"ON\") {\n msg.reset = true;\n msg.payload = \"ON\"\n}\nelse{\n \n msg.payload = \"ON\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":20,"wires":[["e7c5d7f4.3c23e8","9e920ab6.f68048","cfe6a421.aa0598"]]},{"id":"96a290b2.7908f","type":"mqtt out","z":"52e056f1.f36ff8","name":"","topic":"nodered/motion","qos":"","retain":"","broker":"d3f7744e.a9cb78","x":700,"y":200,"wires":[]},{"id":"e681dcb8.4aa1c","type":"function","z":"52e056f1.f36ff8","name":"","func":"if (msg.payload ==\"ON\") {\n msg.payload = \"OFF\"\n}\nelse{\n msg.payload = \"OFF\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":200,"wires":[["96a290b2.7908f","9e920ab6.f68048"]]},{"id":"d3f7744e.a9cb78","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
it has a delay in it for 3 min ( and a rest of the msg.reset)
Node red wait for the topic
stat/SONOFF-FAN/POWER3
does its thing
then send out a ON/OFF to
nodered/motion
Now the HA stuff
Switches for the fan
- platform: mqtt
entity_id: officefan
name: "Office Fan"
state_topic: "stat/SONOFF-FAN/POWER1"
command_topic: "cmnd/SONOFF-FAN/POWER1"
payload_on: "ON"
payload_off: "OFF"
optimistic: false
qos: 0
- platform: mqtt
entity_id: officefanSpeed
name: "Office Fan Speed"
state_topic: "stat/SONOFF-FAN/POWER2"
command_topic: "cmnd/SONOFF-FAN/POWER2"
payload_on: "ON"
payload_off: "OFF"
optimistic: false
qos: 0
motion
- platform: mqtt
name: "Office Motion"
state_topic: "nodered/motion"
qos: 2
retain: true
payload_on: "ON"
payload_off: "OFF"
DHT11
- platform: mqtt
name: "Office Temperature"
state_topic: "tele/SONOFF-FAN/SENSOR"
value_template: "{{value_json['DHT11'].Temperature }}"
qos: 1
unit_of_measurement : "°C"
- platform: mqtt
name: "Office Humidity"
state_topic: "tele/SONOFF-FAN/SENSOR"
value_template: "{{value_json['DHT11'].Humidity }}"
qos: 1
unit_of_measurement : "%"
Now take it over the TOP
add the fan control
- platform: mqtt
name: "Office Fan"
state_topic: "stat/SONOFF-FAN/POWER1"
command_topic: "cmnd/SONOFF-FAN/POWER1"
speed_state_topic: "stat/SONOFF-FAN/POWER2"
speed_command_topic: "cmnd/SONOFF-FAN/POWER2"
qos: 0
payload_on: "ON"
payload_off: "OFF"
payload_low_speed: "OFF"
payload_medium_speed: "ON"
speeds:
- "OFF"
- "ON"
take it even more over the TOP
why not add climate to it
- platform: generic_thermostat
entity_id: office_temp
name: "Office Temperature"
heater: switch.office_fan
target_sensor: sensor.office_temperature
min_temp: 15
max_temp: 30
ac_mode: true
target_temp: 22
initial_operation_mode: "auto"
away_temp: 16
now the customize.yaml
light.office_light:
extra_badge:
- entity_id: binary_sensor.office_motion
- entity_id: sensor.office_temperature
- entity_id: sensor.office_humidity
show_last_changed: true
Put all the bits into a group
main_office:
name: Office
control: hidden
entities:
- light.office_light
- fan.office_fan
- climate.office_temperature
- binary_sensor.office_motion
- sensor.office_computer
and i have ended up with this
And I powder it with one of these
AC tap into the Power line
-Vo GND on the wemos
+Vo 5v on the wemos
hope this turn the light on (fan) for someone else.
OK Now it let put some Automation behind it
As my office is dark I would like the Light to come on when I walk in
- id: Office Light On
alias: Office Light On
trigger:
- entity_id: binary_sensor.office_motion
platform: state
to: 'on'
condition:
- condition: state
entity_id: light.office_light
state: 'off'
action:
- data:
entity_id: light.office_light
service: light.turn_on
that fix it way cool walk in and light come on
(bugger walk pass the door light come on) fan can see me turn fan a bit that fix it.
now how can i get turn off the light when there no motion for x mins NO as my chair is in front of fan so motion can’t see and turn off light even if im there
thinking “what about when computer goes off line” that it
make a sensor
- platform: command_line
name: "Office Computer"
command: ping -W 1 -c 1 IPADDRESS > /dev/null 2>&1 && echo success || echo fail
device_class: connectivity
payload_on: "success"
payload_off: "fail"
value_template: >-
{% if value is equalto "success" %}
On-Line
{% else %}
Off-Line
{% endif %}
have no idea how the above works found some on here and it does the job
so now the automation
- id: Office
alias: 'Office '
trigger:
- entity_id: sensor.office_computer
platform: state
to: Off-Line
condition: []
action:
- data:
entity_id: light.office_light
service: light.turn_off
- data:
entity_id: switch.office_fan
service: switch.turn_off
- data:
entity_id: switch.office_fan_speed
service: switch.turn_off
mite as well turn the fan off if the computer offline
way cool it works just got to remember to (window+L) Lock the computer walk way
and after some time the light goes off. Think ill have to play around with computer
to turn off when the computer is lock
the cool thing about this its just keep growing and growing
the bad part about is
Yes I could just lean across and turn the fan on
yes I could as i walk into the office turn light on/off
nop HA does it for me know
UPDATED
if someone walks into office it turn ON light nice
But Want it to turn off if the computer is still offline
so
- id: 'Office Light Off No Motion'
alias: Office Light Off No Motion
trigger:
- entity_id: binary_sensor.office_motion
platform: state
to: 'off'
condition:
- condition: state
entity_id: sensor.office_computer
state: Off-Line
action:
- data:
entity_id: light.office_light
service: light.turn_off