Skip to content

Instantly share code, notes, and snippets.

@GuySie
Created February 25, 2023 15:12
Show Gist options
  • Save GuySie/fc812ff6f5b6c01ccdd1da295f3c7971 to your computer and use it in GitHub Desktop.
Save GuySie/fc812ff6f5b6c01ccdd1da295f3c7971 to your computer and use it in GitHub Desktop.
Everything presence one 1.1.3
substitutions:
name: "everything-presence-one-123abc"
room: "Living Room"
friendly_name: "Everything Presence One"
project_name: "Everything Smart Technology.Everything Presence One"
project_version: "1.1.3"
temperature_offset: "-3"
humidity_offset: "5"
temperature_update_interval: "60s"
illuminance_update_interval: "30s"
pir_delay_off: "10s"
occupancy_delay_off: "15s"
hidden_ssid: "false"
factory_reset_disabled: "true"
uart_target_output_disabled: "true"
uart_presence_output_disabled: "true"
esphome:
name: "${name}"
name_add_mac_suffix: false
project:
name: "${project_name}"
version: "${project_version}"
esp32:
board: esp32dev
logger:
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: ${hidden_ssid}
ap: {}
captive_portal:
improv_serial:
bluetooth_proxy:
active: true
dashboard_import:
package_import_url: github://everythingsmarthome/presence-one/everything-presence-one.yaml@main
import_full_config: false
light:
- platform: status_led
name: "ESP32 Status LED"
pin: GPIO32
entity_category: config
i2c:
sda: 26
scl: 25
scan: true
sensor:
- platform: shtcx
temperature:
name: "${room} Temperature"
filters:
offset: ${temperature_offset}
humidity:
name: "${room} Humidity"
filters:
offset: ${humidity_offset}
address: 0x70
update_interval: ${temperature_update_interval}
- platform: bh1750
name: "${room} Illuminance"
address: 0x23
update_interval: ${illuminance_update_interval}
binary_sensor:
- platform: gpio
name: ${room} mmWave
id: mmwave
device_class: occupancy
pin:
number: GPIO15
mode: INPUT_PULLDOWN
- platform: gpio
pin:
number: 33
mode: INPUT_PULLDOWN
name: ${room} PIR
id: pir_motion_sensor
device_class: motion
filters:
- delayed_off: ${pir_delay_off}
- platform: template
name: ${room} Occupancy
id: occupancy
device_class: occupancy
filters:
- delayed_off: ${occupancy_delay_off}
lambda: |-
if ( id(mmwave).state or id(pir_motion_sensor).state) {
return true;
}
else if (id(mmwave).state == 0 and id(pir_motion_sensor).state == 0) {
return false;
}
else {
return id(occupancy).state;
}
uart:
id: uart_bus
tx_pin: GPIO13
rx_pin: GPIO14
baud_rate: 115200
debug:
direction: BOTH
dummy_receiver: true
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
switch:
- platform: template
name: "mmWave Sensor"
id: "mmwave_sensor"
entity_category: config
optimistic: true
restore_state: true
turn_on_action:
- uart.write: "sensorStart"
- delay: 1s
turn_off_action:
- uart.write: "sensorStop"
- delay: 1s
- platform: template
name: "mmWave LED"
id: "mmwave_led"
entity_category: config
optimistic: true
restore_state: true
turn_on_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setLedMode 1 0"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
turn_off_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setLedMode 1 1"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
- platform: template
name: "uart_presence_output"
id: "uart_presence_output"
entity_category: config
internal: ${uart_presence_output_disabled}
optimistic: true
restore_state: true
turn_on_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 1 1"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
turn_off_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 1 0"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
- platform: template
name: "uart_target_output"
id: "uart_target_output"
entity_category: config
internal: ${uart_target_output_disabled}
optimistic: true
restore_state: true
assumed_state: false
turn_on_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 2 1 1 1"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
turn_off_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "setUartOutput 2 0"
- delay: 1s
- uart.write: "saveConfig"
- delay: 3s
- switch.turn_on: mmwave_sensor
number:
- platform: template
name: mmWave Distance
id: mmwave_distance
entity_category: config
min_value: 0
max_value: 800
initial_value: 315
optimistic: true
step: 15
restore_value: true
unit_of_measurement: cm
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: !lambda int cm = (int)ceil(x / 15.0);
std::string cms = "detRangeCfg -1 0 " + to_string(cm);
return std::vector<unsigned char>(cms.begin(), cms.end());
- delay: 1s
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- switch.turn_on: mmwave_sensor
- platform: template
name: mmWave Off Latency
id: mmwave_off_latency
entity_category: config
min_value: 1
max_value: 60
initial_value: 15
optimistic: true
step: 1
restore_value: true
unit_of_measurement: seconds
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: !lambda |-
std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- switch.turn_on: mmwave_sensor
- platform: template
name: mmWave On Latency
id: mmwave_on_latency
entity_category: config
min_value: 0
max_value: 60
initial_value: 0
optimistic: true
step: 0.5
restore_value: true
unit_of_measurement: seconds
mode: slider
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: !lambda |-
std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- switch.turn_on: mmwave_sensor
- platform: template
name: mmWave Sensitivity
id: mmwave_sensitivity
entity_category: config
min_value: 0
max_value: 9
initial_value: 7
optimistic: true
step: 1
restore_value: true
set_action:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write:
!lambda std::string mss = "setSensitivity " + to_string((int)x);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write: "saveConfig"
- delay: 1s
- switch.turn_on: mmwave_sensor
button:
- platform: restart
name: Restart_internal
id: restart_internal
entity_category: config
internal: true
- platform: template
name: "Restart mmWave Sensor"
id: "restart_mmwave"
entity_category: config
internal: true
on_press:
- uart.write: "resetSystem"
- platform: template
name: Restart $name
entity_category: config
on_press:
- button.press: restart_mmwave
- button.press: restart_internal
- platform: safe_mode
internal: false
name: $name Safe Mode
entity_category: config
- platform: template
name: "Factory Reset mmWave"
id: "factory_reset_mmwave"
internal: ${factory_reset_disabled}
entity_category: config
on_press:
- switch.turn_off: mmwave_sensor
- delay: 1s
- uart.write: "resetCfg"
- delay: 3s
- switch.turn_on: mmwave_sensor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment