Skip to content

Instantly share code, notes, and snippets.

@pauly7300
Created January 22, 2019 16:19
Show Gist options
  • Save pauly7300/b18795009ef2324aacaa58d51d8ad90c to your computer and use it in GitHub Desktop.
Save pauly7300/b18795009ef2324aacaa58d51d8ad90c to your computer and use it in GitHub Desktop.
esphomyaml for lights/switch/motion
esphomeyaml:
name: kitchen_main
platform: ESP32
board: mhetesp32devkit
wifi:
ssid: 'SSID'
password: 'password'
manual_ip:
static_ip: 192.168.x.x
gateway: 192.168.x.x
subnet: 255.255.255.0
mqtt:
broker: 'xxx.xxx.xxx.xxx'
username: 'username'
password: '*******'
# Enable logging
logger:
# Enable Home Assistant API
# I've purposely disabled the API for now as I'm using MQTT only at the moment.
# api:
# password: 'password'
ota:
password: 'password'
# Optional. I like the small interface it adds to the device if I want to check it manually.
web_server:
port: 80
dallas:
- pin: GPIO18
switch:
- platform: gpio
name: "Kitchen_Main_Onboard light"
id: Kitchen_Main_Onboard
inverted: ON
pin: 2
# I defined a random gpio pin even though i don't have anything connected to it so I can define the button below and turn the virtual device "kitchen_all" on and off.
# I then use the mqtt messages in nodered to send a blanket on/off message to all lights
- platform: gpio
name: "kitchen_all"
id: kitchen_all
pin: 5
# This is the output for the LED strip. It works in conjuction with the Light below. This is defining the pin and it's characteristics.
output:
- platform: ledc
pin: 16
frequency: 40000Hz
bit_depth: 10
id: LED_gpio_16
# This is the light attached to the output from above.
light:
- platform: monochromatic
name: "Kitchen_LED light_main"
default_transition_length: 4s
id: light_main1
output: LED_gpio_16
# This is the basic dallas temp sensor definition. You must 'learn' the address first before you can specify it in this manner.
# Read the 'Getting sensor IDs section here. https://esphomelib.com/esphomeyaml/components/sensor/dallas.html
sensor:
- platform: dallas
address: 0xxxxxxxx #address of the dallas sensor
name: "Kitchen_main_tempsensor"
# This is a PIR motion sensor AM312. It detects motion and broadcasts the motion detection to an MQTT topic. I built an automation in Nodered to
# Turn lights on/off based on these messages. This sensor has no adjustments for how long it remains on after movement so I've built all that
# logic into the nodered flow using trigger nodes.
binary_sensor:
- platform: gpio
pin: 23
name: "Kitchen_Motion"
device_class: motion
# This is the button definition i have connected to pin 22. The 'on-click' behaviors control the parameters for the detection of the button press.
# The action is to toggle the virtual 'kitchen_all' device referenced above. Then I use that state in nodered for turning lights on/off.
- platform: gpio
pin:
number: 22
mode: INPUT_PULLUP
inverted: True
name: button1
on_click:
min_length: 25ms
max_length: 550ms
then:
- switch.toggle:
id: kitchen_all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment