mirror of
https://github.com/nuttytree/ESPHome-Devices.git
synced 2024-08-30 18:12:19 +00:00
13f3977342
Finish folder re-org README updates
127 lines
3.7 KiB
YAML
127 lines
3.7 KiB
YAML
substitutions:
|
|
device_id: master_bed
|
|
device_name: Master Bed
|
|
platform: ESP8266
|
|
board: nodemcuv2
|
|
ip_address: !secret master_bed_ip
|
|
ota_pwd: !secret master_bed_ota_pwd
|
|
api_pwd: !secret master_bed_api_pwd
|
|
ap_wifi_pwd: !secret master_bed_ap_wifi_pwd
|
|
|
|
packages:
|
|
device_base: !include ../packages/device_base.yaml
|
|
|
|
esphome:
|
|
includes:
|
|
- ../custom/bed_sensor.h
|
|
|
|
binary_sensor:
|
|
- platform: template
|
|
name: "Melissa is in Bed"
|
|
id: melissa_in_bed
|
|
device_class: occupancy
|
|
on_state:
|
|
then:
|
|
- sensor.template.publish:
|
|
id: master_bed_count
|
|
state: !lambda 'return id(melissa_in_bed).state + id(chris_in_bed).state + id(someone_in_bed).state;'
|
|
- platform: template
|
|
name: "Chris is in Bed"
|
|
id: chris_in_bed
|
|
device_class: occupancy
|
|
on_state:
|
|
then:
|
|
- sensor.template.publish:
|
|
id: master_bed_count
|
|
state: !lambda 'return id(melissa_in_bed).state + id(chris_in_bed).state + id(someone_in_bed).state;'
|
|
- platform: template
|
|
name: "Someone is in Bed"
|
|
id: someone_in_bed
|
|
device_class: occupancy
|
|
on_state:
|
|
then:
|
|
- sensor.template.publish:
|
|
id: master_bed_count
|
|
state: !lambda 'return id(melissa_in_bed).state + id(chris_in_bed).state + id(someone_in_bed).state;'
|
|
|
|
sensor:
|
|
- platform: custom
|
|
lambda: |-
|
|
auto bedSensor = new BedSensor();
|
|
App.register_component(bedSensor);
|
|
return {bedSensor->melissaBedSensor, bedSensor->chrisBedSensor};
|
|
sensors:
|
|
- name: "Melissa Bed Sensor"
|
|
id: melissa_bed_sensor
|
|
on_value:
|
|
then:
|
|
- sensor.template.publish:
|
|
id: melissa_bed_percent
|
|
state: !lambda 'return (1024 - x) / 1024 * 100;'
|
|
- name: "Chris Bed Sensor"
|
|
id: chris_bed_sensor
|
|
on_value:
|
|
then:
|
|
- sensor.template.publish:
|
|
id: chris_bed_percent
|
|
state: !lambda 'return (1024 - x) / 1024 * 100;'
|
|
|
|
- platform: template
|
|
name: "Melissa Bed Percent"
|
|
id: melissa_bed_percent
|
|
icon: "mdi:bed"
|
|
unit_of_measurement: "%"
|
|
accuracy_decimals: 0
|
|
on_value:
|
|
then:
|
|
- binary_sensor.template.publish:
|
|
id: melissa_in_bed
|
|
state: !lambda 'return x > 75;'
|
|
- binary_sensor.template.publish:
|
|
id: someone_in_bed
|
|
state: !lambda 'return x <= 75 && !id(chris_in_bed).state && x > 40 && id(chris_bed_percent).state > 40;'
|
|
- platform: template
|
|
name: "Chris Bed Percent"
|
|
id: chris_bed_percent
|
|
icon: "mdi:bed"
|
|
unit_of_measurement: "%"
|
|
accuracy_decimals: 0
|
|
on_value:
|
|
then:
|
|
- binary_sensor.template.publish:
|
|
id: chris_in_bed
|
|
state: !lambda 'return x > 75;'
|
|
- binary_sensor.template.publish:
|
|
id: someone_in_bed
|
|
state: !lambda 'return !id(melissa_in_bed).state && x <= 75 && id(melissa_bed_percent).state > 40 && x > 40;'
|
|
|
|
- platform: template
|
|
name: "Master Bed Count"
|
|
id: master_bed_count
|
|
accuracy_decimals: 0
|
|
icon: "mdi:bed"
|
|
on_value:
|
|
then:
|
|
- text_sensor.template.publish:
|
|
id: master_bed_status
|
|
state: !lambda |-
|
|
if (x == 0) {
|
|
return "Empty";
|
|
} else if (x == 2) {
|
|
return "Melissa and Chris";
|
|
} else if (id(melissa_in_bed).state) {
|
|
return "Melissa";
|
|
} else if (id(chris_in_bed).state) {
|
|
return "Chris";
|
|
} else if (id(someone_in_bed).state) {
|
|
return "Someone";
|
|
} else {
|
|
return "Unknown";
|
|
}
|
|
|
|
text_sensor:
|
|
- platform: template
|
|
name: "Master Bed Status"
|
|
id: master_bed_status
|
|
icon: "mdi:bed"
|