├── 1m(s) └── yaml │ └── human-sensor-1m(s)-github.yaml ├── 1u └── yaml │ ├── README.md │ └── human-sensor-1u-github.yaml ├── 1w └── yaml │ └── human-sensor-1w-github.yaml ├── 1wx └── yaml │ ├── experiment │ ├── README.yaml │ └── human-sensor-1wx-experiment-v1.yaml │ └── human-sensor-1wx-github.yaml ├── 2a └── yaml │ └── human-sensor-2a-stable-github.yaml ├── README.md ├── f2 └── yaml │ ├── README.md │ ├── beta-version │ └── human-sensor-f2-beta.yaml │ └── human-sensor-f2-stable.yaml ├── l12 └── yaml │ ├── README.md │ └── human-sensor-l12-github.yaml └── l13 └── yaml └── human-sensor-l13-github.yaml /1m(s)/yaml/human-sensor-1m(s)-github.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: humen-sensor-1m 3 | comment: Human Sensor 1M 4 | friendly_name: Human Sensor 1M 5 | name_add_mac_suffix: True 6 | platformio_options: 7 | board_build.flash_mode: dio 8 | project: 9 | name: Screek.Human_Sensor 10 | version: 1M 11 | 12 | external_components: 13 | - source: 14 | type: git 15 | url: https://github.com/screekworkshop/custom_components_support_for_screek_1w 16 | ref: main 17 | components: [uart, ld2410] 18 | 19 | esp32: 20 | board: lolin_c3_mini 21 | framework: 22 | type: arduino 23 | version: 2.0.9 24 | platform_version: 6.3.2 25 | 26 | logger: 27 | hardware_uart: uart0 28 | 29 | api: 30 | 31 | ota: 32 | password: "YOUR_OTA_PASSWORD" 33 | 34 | wifi: 35 | # ssid: !secret wifi_ssid 36 | # password: !secret wifi_password 37 | # fast_connect: True 38 | 39 | power_save_mode: LIGHT 40 | # output_power: 20dB 41 | # Enable fallback hotspot (captive portal) in case wifi connection fails 42 | ap: 43 | ssid: "HUMAN-SENSOR 1M" 44 | 45 | captive_portal: 46 | 47 | web_server: 48 | port: 80 49 | 50 | binary_sensor: 51 | - platform: status 52 | name: Online 53 | id: ink_ha_connected 54 | - platform: ld2410 55 | has_target: 56 | name: Presence 57 | has_moving_target: 58 | name: Moving Target 59 | has_still_target: 60 | name: Still Target 61 | 62 | sensor: 63 | - platform: template 64 | id: sys_esp_temperature 65 | name: ESP Temperature 66 | lambda: return temperatureRead(); 67 | unit_of_measurement: °C 68 | device_class: TEMPERATURE 69 | update_interval: 30s 70 | entity_category: "diagnostic" 71 | - platform: uptime 72 | name: Uptime 73 | id: sys_uptime 74 | update_interval: 10s 75 | - platform: wifi_signal 76 | name: RSSI 77 | id: wifi_signal_db 78 | update_interval: 1s 79 | entity_category: "diagnostic" 80 | - platform: template 81 | id: esp_memory 82 | icon: mdi:memory 83 | name: ESP Free Memory 84 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 85 | unit_of_measurement: 'kB' 86 | state_class: measurement 87 | entity_category: "diagnostic" 88 | - platform: ld2410 89 | moving_distance: 90 | name : Moving Distance 91 | id: moving_distance 92 | still_distance: 93 | name: Still Distance 94 | id: still_distance 95 | moving_energy: 96 | name: Move Energy 97 | still_energy: 98 | name: Still Energy 99 | detection_distance: 100 | name: Detection Distance 101 | light: 102 | name: Sun Light 103 | 104 | light: 105 | - platform: status_led 106 | name: sys_status 107 | pin: 108 | number: GPIO8 109 | inverted: True 110 | internal: True 111 | restore_mode: ALWAYS_OFF 112 | 113 | time: 114 | - platform: sntp 115 | id: time_now 116 | servers: 117 | - ntp.aliyun.com 118 | 119 | uart: 120 | id: uart_ld2410 121 | tx_pin: GPIO4 122 | rx_pin: GPIO3 123 | baud_rate: 256000 124 | parity: NONE 125 | stop_bits: 1 126 | 127 | ld2410: 128 | timeout: 150s 129 | id: ld2410_radar 130 | # max_move_distance : 6m 131 | # max_still_distance: 0.75m 132 | # g0_move_threshold: 10 133 | # g0_still_threshold: 20 134 | # g1_move_threshold: 10 135 | # g1_still_threshold: 20 136 | # g2_move_threshold: 20 137 | # g2_still_threshold: 21 138 | # g3_move_threshold: 30 139 | # g3_still_threshold: 31 140 | # g4_move_threshold: 40 141 | # g4_still_threshold: 41 142 | # g5_move_threshold: 50 143 | # g5_still_threshold: 51 144 | # g6_move_threshold: 60 145 | # g6_still_threshold: 61 146 | # g7_move_threshold: 70 147 | # g7_still_threshold: 71 148 | # g8_move_threshold: 80 149 | # g8_still_threshold: 81 150 | 151 | button: 152 | - platform: template 153 | name: "Enable LD2410 BLE" 154 | entity_category: "config" 155 | icon: mdi:bluetooth 156 | on_press: 157 | lambda: |- 158 | id(ld2410_radar) -> ble_control(true); 159 | - platform: template 160 | name: "Disable LD2410 BLE" 161 | entity_category: "config" 162 | icon: mdi:bluetooth-off 163 | on_press: 164 | lambda: |- 165 | id(ld2410_radar) -> ble_control(false); 166 | - platform: template 167 | name: "LD2410 Reboot" 168 | icon: mdi:radar 169 | entity_category: "config" 170 | on_press: 171 | lambda: |- 172 | // auto* radar = LD2410Component::get(ld2410); 173 | // radar -> roboot(); 174 | id(ld2410_radar) -> reboot(); 175 | - platform: restart 176 | icon: mdi:power-cycle 177 | name: "ESP Reboot" 178 | - platform: factory_reset 179 | disabled_by_default: True 180 | name: Factory Reset 181 | id: factory_reset_all 182 | -------------------------------------------------------------------------------- /1u/yaml/README.md: -------------------------------------------------------------------------------- 1 | This is a custom firmware for Human Presence Sensor 1U, you can get help for using the firmware and some FAQ on our website: https://screek.tech 2 | - If you want to buy one of our DIY products, you can also find our eBay store on our homepage. 3 | - In order to adapt to work in a small space, we made some optimizations: including adjusting the WIFI transmit mode (we lowered it to 15dB), and downconverting the ESP32 to 80Mhz. 4 | - Two of our modified libraries were used: the LD2410 modified the initialization mechanism based on the official one (thanks to @regevbr) (we abandoned setting it in the esphome and used the HLKRadarTool configuration instead), added the BLE switch, and added the resistance value to get the LDR; while the uart library, with some slight modifications, aims to make both uart work on s2 at the same time, so that we can keep the serial port support. 5 | 6 | Thank you for your support! It's been a pleasure to share them. 7 | Have a great day. -------------------------------------------------------------------------------- /1u/yaml/human-sensor-1u-github.yaml: -------------------------------------------------------------------------------- 1 | # This is a custom firmware for Human Presence Sensor 1U 2 | # https://screek.io/1u 3 | 4 | esphome: 5 | name: screek-humen-sensor-1u 6 | comment: Screek Human Presence Sensor 1U 7 | friendly_name: Screek Human Presence Sensor 1U 8 | name_add_mac_suffix: True 9 | platformio_options: 10 | board_build.flash_mode: dio 11 | board_build.f_cpu: 80000000L 12 | on_boot: 13 | priority: 900 14 | then: 15 | lambda: |- 16 | id(cpu_speed) = ESP.getCpuFreqMHz() ; 17 | project: 18 | name: Screek.Human_Presence_Sensor 19 | version: 1U 20 | min_version: 2023.6.1 21 | 22 | globals: 23 | - id: cpu_speed 24 | type: int 25 | restore_value: no 26 | initial_value: '0' 27 | 28 | external_components: 29 | # - source: github://screek-workshop/custom_components_support_for_screek_1u 30 | - source: 31 | type: git 32 | url: https://github.com/screek-workshop/custom_components_support_for_screek_1u 33 | ref: master 34 | # components: [ ld2410, uart ] 35 | 36 | esp32: 37 | board: lolin_s2_mini 38 | framework: 39 | type: arduino 40 | version: 2.0.9 41 | platform_version: 6.3.2 42 | 43 | improv_serial: 44 | 45 | logger: 46 | hardware_uart: uart0 47 | 48 | api: 49 | # encryption: 50 | # key: "YOUR-API-PASSWORD" 51 | 52 | ota: 53 | # This won't work for the original firmware(we use diffrent ota password), 54 | # so if you want to turn it into your own OTA, 55 | # make sure to completely flash your custom yaml in the firmware once. 56 | # after that, you may always ota with your own password. 57 | password: "all-things-in-their-being-are-good-for-something" # words by Socrates 58 | safe_mode: False 59 | 60 | # By automatically importing to the console, 61 | # subsequent adjustments can be easily made without having to manually fix a specific name. 62 | # dashboard_import: 63 | # package_import_url: github://screekworkshop/screek-human-sensor/1u/yaml/Screek-Humen-Dectet-1u.yaml@2023.06 64 | # import_full_config: False 65 | 66 | wifi: 67 | # power_save_mode: NONE 68 | output_power: 15dB 69 | power_save_mode: LIGHT 70 | reboot_timeout: 10min 71 | ap: 72 | ssid: "SCREEK HUMAN-SENSOR" 73 | # password: "YOUR-AP-PASSWORD" 74 | 75 | captive_portal: 76 | 77 | web_server: 78 | port: 80 79 | 80 | binary_sensor: 81 | - platform: status 82 | name: Online 83 | id: ink_ha_connected 84 | - platform: ld2410 85 | has_target: 86 | name: Presence 87 | has_moving_target: 88 | name: Moving Target 89 | has_still_target: 90 | name: Still Target 91 | 92 | sensor: 93 | - platform: template 94 | name: "ESP Cpu Speed" 95 | accuracy_decimals: 0 96 | unit_of_measurement: Mhz 97 | lambda: |- 98 | return (id(cpu_speed)); 99 | entity_category: "diagnostic" 100 | 101 | # - platform: internal_temperature 102 | # id: sys_esp_temperature 103 | # name: ESP Temperature 104 | # unit_of_measurement: °C 105 | # device_class: TEMPERATURE 106 | # update_interval: 1s 107 | # entity_category: "diagnostic" 108 | 109 | - platform: template 110 | id: sys_esp_temperature 111 | name: ESP Temperature 112 | lambda: return temperatureRead(); 113 | unit_of_measurement: °C 114 | device_class: TEMPERATURE 115 | update_interval: 5s 116 | entity_category: "diagnostic" 117 | 118 | - platform: uptime 119 | name: Uptime 120 | id: sys_uptime 121 | update_interval: 10s 122 | 123 | - platform: wifi_signal 124 | name: RSSI 125 | id: wifi_signal_db 126 | update_interval: 5s 127 | entity_category: "diagnostic" 128 | 129 | - platform: template 130 | id: esp_memory 131 | icon: mdi:memory 132 | name: ESP Free Memory 133 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 134 | unit_of_measurement: 'kB' 135 | state_class: measurement 136 | entity_category: "diagnostic" 137 | 138 | - platform: ld2410 139 | moving_distance: 140 | name : Moving Distance 141 | id: moving_distance 142 | still_distance: 143 | name: Still Distance 144 | id: still_distance 145 | moving_energy: 146 | name: Move Energy 147 | still_energy: 148 | name: Still Energy 149 | detection_distance: 150 | name: Detection Distance 151 | light: 152 | name: Sun Light 153 | 154 | light: 155 | - platform: status_led 156 | name: sys_status 157 | pin: GPIO15 158 | internal: True 159 | restore_mode: ALWAYS_OFF 160 | 161 | time: 162 | - platform: sntp 163 | id: time_sntp 164 | 165 | uart: 166 | id: uart_ld2410 167 | tx_pin: GPIO18 168 | rx_pin: GPIO33 169 | baud_rate: 256000 170 | parity: NONE 171 | stop_bits: 1 172 | 173 | ld2410: 174 | timeout: 150s 175 | id: ld2410_radar 176 | # max_move_distance : 6m 177 | # max_still_distance: 0.75m 178 | # g0_move_threshold: 10 179 | # g0_still_threshold: 20 180 | # g1_move_threshold: 10 181 | # g1_still_threshold: 20 182 | # g2_move_threshold: 20 183 | # g2_still_threshold: 21 184 | # g3_move_threshold: 30 185 | # g3_still_threshold: 31 186 | # g4_move_threshold: 40 187 | # g4_still_threshold: 41 188 | # g5_move_threshold: 50 189 | # g5_still_threshold: 51 190 | # g6_move_threshold: 60 191 | # g6_still_threshold: 61 192 | # g7_move_threshold: 70 193 | # g7_still_threshold: 71 194 | # g8_move_threshold: 80 195 | # g8_still_threshold: 81 196 | 197 | button: 198 | - platform: template 199 | name: "Enable LD2410 BLE" 200 | # disabled_by_default: True 201 | entity_category: "config" 202 | icon: mdi:bluetooth 203 | on_press: 204 | lambda: |- 205 | id(ld2410_radar) -> ble_control(true); 206 | 207 | - platform: template 208 | name: "Disable LD2410 BLE" 209 | # disabled_by_default: True 210 | entity_category: "config" 211 | icon: mdi:bluetooth-off 212 | on_press: 213 | lambda: |- 214 | id(ld2410_radar) -> ble_control(false); 215 | 216 | - platform: template 217 | name: "LD2410 Reboot" 218 | icon: mdi:radar 219 | entity_category: "config" 220 | on_press: 221 | lambda: |- 222 | // auto* radar = LD2410Component::get(ld2410); 223 | // radar -> roboot(); 224 | id(ld2410_radar) -> reboot(); 225 | 226 | - platform: restart 227 | icon: mdi:power-cycle 228 | name: "ESP Reboot" 229 | 230 | - platform: factory_reset 231 | disabled_by_default: True 232 | name: Factory Reset 233 | id: factory_reset_all 234 | -------------------------------------------------------------------------------- /1w/yaml/human-sensor-1w-github.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: screek-humen-sensor-1w 3 | comment: Screek Human Sensor 1W 4 | friendly_name: Human Sensor 1W 5 | name_add_mac_suffix: True 6 | platformio_options: 7 | board_build.flash_mode: dio 8 | project: 9 | name: Screek.Human_Sensor 10 | version: 1W 11 | 12 | external_components: 13 | - source: 14 | type: git 15 | url: https://github.com/screekworkshop/custom_components_support_for_screek_1w 16 | ref: main 17 | components: [uart, ld2410] 18 | 19 | esp32: 20 | board: esp32-c3-devkitm-1 21 | 22 | logger: 23 | 24 | api: 25 | 26 | ota: 27 | password: "YOUR_OTA_PASSWORD" 28 | 29 | wifi: 30 | # ssid: !secret wifi_ssid 31 | # password: !secret wifi_password 32 | # fast_connect: True 33 | 34 | power_save_mode: NONE 35 | # output_power: 20dB 36 | # Enable fallback hotspot (captive portal) in case wifi connection fails 37 | ap: 38 | ssid: "SCREEK HUMAN-SENSOR" 39 | 40 | captive_portal: 41 | 42 | web_server: 43 | port: 80 44 | 45 | binary_sensor: 46 | - platform: status 47 | name: Online 48 | id: ink_ha_connected 49 | - platform: ld2410 50 | has_target: 51 | name: Presence 52 | has_moving_target: 53 | name: Moving Target 54 | has_still_target: 55 | name: Still Target 56 | 57 | sensor: 58 | - platform: template 59 | id: sys_esp_temperature 60 | name: ESP Temperature 61 | lambda: return temperatureRead(); 62 | unit_of_measurement: °C 63 | device_class: TEMPERATURE 64 | update_interval: 30s 65 | entity_category: "diagnostic" 66 | - platform: uptime 67 | name: Uptime 68 | id: sys_uptime 69 | update_interval: 10s 70 | - platform: wifi_signal 71 | name: RSSI 72 | id: wifi_signal_db 73 | update_interval: 1s 74 | entity_category: "diagnostic" 75 | - platform: template 76 | id: esp_memory 77 | icon: mdi:memory 78 | name: ESP Free Memory 79 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 80 | unit_of_measurement: 'kB' 81 | state_class: measurement 82 | entity_category: "diagnostic" 83 | - platform: ld2410 84 | moving_distance: 85 | name : Moving Distance 86 | id: moving_distance 87 | still_distance: 88 | name: Still Distance 89 | id: still_distance 90 | moving_energy: 91 | name: Move Energy 92 | still_energy: 93 | name: Still Energy 94 | detection_distance: 95 | name: Detection Distance 96 | light: 97 | name: Sun Light 98 | 99 | time: 100 | - platform: sntp 101 | id: time_now 102 | servers: 103 | - ntp.aliyun.com 104 | 105 | uart: 106 | id: uart_ld2410 107 | tx_pin: GPIO5 108 | rx_pin: GPIO4 109 | baud_rate: 256000 110 | parity: NONE 111 | stop_bits: 1 112 | 113 | ld2410: 114 | timeout: 150s 115 | id: ld2410_radar 116 | # max_move_distance : 6m 117 | # max_still_distance: 0.75m 118 | # g0_move_threshold: 10 119 | # g0_still_threshold: 20 120 | # g1_move_threshold: 10 121 | # g1_still_threshold: 20 122 | # g2_move_threshold: 20 123 | # g2_still_threshold: 21 124 | # g3_move_threshold: 30 125 | # g3_still_threshold: 31 126 | # g4_move_threshold: 40 127 | # g4_still_threshold: 41 128 | # g5_move_threshold: 50 129 | # g5_still_threshold: 51 130 | # g6_move_threshold: 60 131 | # g6_still_threshold: 61 132 | # g7_move_threshold: 70 133 | # g7_still_threshold: 71 134 | # g8_move_threshold: 80 135 | # g8_still_threshold: 81 136 | 137 | button: 138 | - platform: template 139 | name: "Enable LD2410 BLE" 140 | entity_category: "config" 141 | icon: mdi:bluetooth 142 | on_press: 143 | lambda: |- 144 | id(ld2410_radar) -> ble_control(true); 145 | - platform: template 146 | name: "Disable LD2410 BLE" 147 | entity_category: "config" 148 | icon: mdi:bluetooth-off 149 | on_press: 150 | lambda: |- 151 | id(ld2410_radar) -> ble_control(false); 152 | - platform: template 153 | name: "LD2410 Reboot" 154 | icon: mdi:radar 155 | entity_category: "config" 156 | on_press: 157 | lambda: |- 158 | // auto* radar = LD2410Component::get(ld2410); 159 | // radar -> roboot(); 160 | id(ld2410_radar) -> reboot(); 161 | - platform: restart 162 | icon: mdi:power-cycle 163 | name: "ESP Reboot" 164 | - platform: factory_reset 165 | disabled_by_default: True 166 | name: Factory Reset 167 | id: factory_reset_all 168 | -------------------------------------------------------------------------------- /1wx/yaml/experiment/README.yaml: -------------------------------------------------------------------------------- 1 | Experimental YAML Configurations 2 | 3 | The YAML configuration files in this directory are experimental and are intended for testing and exploratory development purposes. They have not undergone comprehensive testing or validation and may contain unresolved bugs and issues. Please use these configurations with caution, keeping in mind that they are meant solely for experimentation and learning, and their functionality and stability cannot be guaranteed. -------------------------------------------------------------------------------- /1wx/yaml/experiment/human-sensor-1wx-experiment-v1.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: screek-humen-sensor-1wx 3 | comment: Screek Human Sensor 1WX 4 | friendly_name: Human Sensor 1WX 5 | name_add_mac_suffix: True 6 | platformio_options: 7 | board_build.flash_mode: dio 8 | project: 9 | name: Screek.Human_Sensor 10 | version: 1W 11 | 12 | external_components: 13 | - source: 14 | type: git 15 | url: https://github.com/screekworkshop/custom_components_support_for_screek_1w 16 | ref: main 17 | components: [esp32, uart] 18 | 19 | esp32: 20 | board: esp32-c3-devkitm-1 21 | 22 | logger: 23 | 24 | api: 25 | 26 | ota: 27 | - platform: esphome 28 | password: "YOUR_OTA_PASSWORD" 29 | 30 | wifi: 31 | # ssid: !secret wifi_ssid 32 | # password: !secret wifi_password 33 | # fast_connect: True 34 | 35 | power_save_mode: NONE 36 | # output_power: 20dB 37 | # Enable fallback hotspot (captive portal) in case wifi connection fails 38 | ap: 39 | ssid: "HUMAN-SENSOR 1WX" 40 | 41 | captive_portal: 42 | 43 | web_server: 44 | port: 80 45 | 46 | binary_sensor: 47 | - platform: status 48 | name: Online 49 | id: ink_ha_connected 50 | - platform: ld2410 51 | has_target: 52 | name: Presence 53 | has_moving_target: 54 | name: Moving Target 55 | has_still_target: 56 | name: Still Target 57 | 58 | sensor: 59 | - platform: template 60 | id: sys_esp_temperature 61 | name: ESP Temperature 62 | lambda: return temperatureRead(); 63 | unit_of_measurement: °C 64 | device_class: TEMPERATURE 65 | update_interval: 30s 66 | entity_category: "diagnostic" 67 | - platform: uptime 68 | name: Uptime 69 | id: sys_uptime 70 | update_interval: 10s 71 | - platform: wifi_signal 72 | name: RSSI 73 | id: wifi_signal_db 74 | update_interval: 1s 75 | entity_category: "diagnostic" 76 | - platform: template 77 | id: esp_memory 78 | icon: mdi:memory 79 | name: ESP Free Memory 80 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 81 | unit_of_measurement: 'kB' 82 | state_class: measurement 83 | entity_category: "diagnostic" 84 | - platform: ld2410 85 | moving_distance: 86 | name : Moving Distance 87 | id: moving_distance 88 | still_distance: 89 | name: Still Distance 90 | id: still_distance 91 | moving_energy: 92 | name: Move Energy 93 | still_energy: 94 | name: Still Energy 95 | detection_distance: 96 | name: Detection Distance 97 | light: 98 | name: Sun Light 99 | 100 | time: 101 | - platform: sntp 102 | id: time_now 103 | servers: 104 | - ntp.aliyun.com 105 | 106 | uart: 107 | id: uart_ld2410 108 | tx_pin: GPIO7 109 | rx_pin: GPIO6 110 | baud_rate: 256000 111 | parity: NONE 112 | stop_bits: 1 113 | 114 | switch: 115 | - platform: ld2410 116 | engineering_mode: 117 | name: "engineering mode" 118 | bluetooth: 119 | name: "control bluetooth" 120 | 121 | ld2410: 122 | id: ld2410_radar 123 | 124 | text_sensor: 125 | - platform: ld2410 126 | version: 127 | name: "firmware version" 128 | mac_address: 129 | name: "mac address" 130 | 131 | button: 132 | - platform: ld2410 133 | factory_reset: 134 | name: "ld2410 factory reset" 135 | restart: 136 | name: "LD2410 Reboot" 137 | icon: mdi:radar 138 | entity_category: "config" 139 | - platform: restart 140 | icon: mdi:power-cycle 141 | name: "ESP Reboot" 142 | - platform: factory_reset 143 | disabled_by_default: True 144 | name: Factory Reset 145 | id: factory_reset_all 146 | 147 | number: 148 | - platform: ld2410 149 | timeout: 150 | name: timeout 151 | light_threshold: 152 | name: light threshold 153 | max_move_distance_gate: 154 | name: max move distance gate 155 | max_still_distance_gate: 156 | name: max still distance gate -------------------------------------------------------------------------------- /1wx/yaml/human-sensor-1wx-github.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: screek-humen-sensor-1wx 3 | comment: Screek Human Sensor 1WX 4 | friendly_name: Human Sensor 1WX 5 | name_add_mac_suffix: True 6 | platformio_options: 7 | board_build.flash_mode: dio 8 | project: 9 | name: Screek.Human_Sensor 10 | version: 1W 11 | 12 | external_components: 13 | - source: 14 | type: git 15 | url: https://github.com/screekworkshop/custom_components_support_for_screek_1w 16 | ref: main 17 | components: [uart, ld2410] 18 | 19 | esp32: 20 | board: esp32-c3-devkitm-1 21 | 22 | logger: 23 | 24 | api: 25 | 26 | ota: 27 | - platform: esphome 28 | password: "YOUR_OTA_PASSWORD" 29 | 30 | wifi: 31 | # ssid: !secret wifi_ssid 32 | # password: !secret wifi_password 33 | # fast_connect: True 34 | 35 | power_save_mode: NONE 36 | # output_power: 20dB 37 | # Enable fallback hotspot (captive portal) in case wifi connection fails 38 | ap: 39 | ssid: "SCREEK HUMAN-SENSOR" 40 | 41 | captive_portal: 42 | 43 | web_server: 44 | port: 80 45 | 46 | binary_sensor: 47 | - platform: status 48 | name: Online 49 | id: ink_ha_connected 50 | - platform: ld2410 51 | has_target: 52 | name: Presence 53 | has_moving_target: 54 | name: Moving Target 55 | has_still_target: 56 | name: Still Target 57 | 58 | sensor: 59 | - platform: template 60 | id: sys_esp_temperature 61 | name: ESP Temperature 62 | lambda: return temperatureRead(); 63 | unit_of_measurement: °C 64 | device_class: TEMPERATURE 65 | update_interval: 30s 66 | entity_category: "diagnostic" 67 | - platform: uptime 68 | name: Uptime 69 | id: sys_uptime 70 | update_interval: 10s 71 | - platform: wifi_signal 72 | name: RSSI 73 | id: wifi_signal_db 74 | update_interval: 1s 75 | entity_category: "diagnostic" 76 | - platform: template 77 | id: esp_memory 78 | icon: mdi:memory 79 | name: ESP Free Memory 80 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 81 | unit_of_measurement: 'kB' 82 | state_class: measurement 83 | entity_category: "diagnostic" 84 | - platform: ld2410 85 | moving_distance: 86 | name : Moving Distance 87 | id: moving_distance 88 | still_distance: 89 | name: Still Distance 90 | id: still_distance 91 | moving_energy: 92 | name: Move Energy 93 | still_energy: 94 | name: Still Energy 95 | detection_distance: 96 | name: Detection Distance 97 | light: 98 | name: Sun Light 99 | 100 | time: 101 | - platform: sntp 102 | id: time_now 103 | servers: 104 | - ntp.aliyun.com 105 | 106 | uart: 107 | id: uart_ld2410 108 | tx_pin: GPIO7 109 | rx_pin: GPIO6 110 | baud_rate: 256000 111 | parity: NONE 112 | stop_bits: 1 113 | 114 | ld2410: 115 | timeout: 150s 116 | id: ld2410_radar 117 | # max_move_distance : 6m 118 | # max_still_distance: 0.75m 119 | # g0_move_threshold: 10 120 | # g0_still_threshold: 20 121 | # g1_move_threshold: 10 122 | # g1_still_threshold: 20 123 | # g2_move_threshold: 20 124 | # g2_still_threshold: 21 125 | # g3_move_threshold: 30 126 | # g3_still_threshold: 31 127 | # g4_move_threshold: 40 128 | # g4_still_threshold: 41 129 | # g5_move_threshold: 50 130 | # g5_still_threshold: 51 131 | # g6_move_threshold: 60 132 | # g6_still_threshold: 61 133 | # g7_move_threshold: 70 134 | # g7_still_threshold: 71 135 | # g8_move_threshold: 80 136 | # g8_still_threshold: 81 137 | 138 | button: 139 | - platform: template 140 | name: "Enable LD2410 BLE" 141 | entity_category: "config" 142 | icon: mdi:bluetooth 143 | on_press: 144 | lambda: |- 145 | id(ld2410_radar) -> ble_control(true); 146 | - platform: template 147 | name: "Disable LD2410 BLE" 148 | entity_category: "config" 149 | icon: mdi:bluetooth-off 150 | on_press: 151 | lambda: |- 152 | id(ld2410_radar) -> ble_control(false); 153 | - platform: template 154 | name: "LD2410 Reboot" 155 | icon: mdi:radar 156 | entity_category: "config" 157 | on_press: 158 | lambda: |- 159 | // auto* radar = LD2410Component::get(ld2410); 160 | // radar -> roboot(); 161 | id(ld2410_radar) -> reboot(); 162 | - platform: restart 163 | icon: mdi:power-cycle 164 | name: "ESP Reboot" 165 | - platform: factory_reset 166 | disabled_by_default: True 167 | name: Factory Reset 168 | id: factory_reset_all 169 | -------------------------------------------------------------------------------- /2a/yaml/human-sensor-2a-stable-github.yaml: -------------------------------------------------------------------------------- 1 | # This is a custom firmware for Human Presence Sensor 2A 2 | # https://docs.screek.io/2a 3 | 4 | esphome: 5 | name: screek-human-sensor-2a 6 | comment: Screek Human Sensor 2A 7 | friendly_name: Human Sensor 2A 8 | name_add_mac_suffix: True 9 | platformio_options: 10 | board_build.flash_mode: dio 11 | # board_build.f_cpu: 80000000L 12 | project: 13 | name: Screek.Human_Presence_Sensor 14 | version: 2A 15 | on_boot: 16 | - priority: 100 17 | then: 18 | lambda: |- 19 | id(cpu_speed) = ESP.getCpuFreqMHz(); 20 | - priority: -200 21 | then: 22 | lambda: |- 23 | id(zone1_target_exsits).publish_state(false); 24 | id(zone2_target_exsits).publish_state(false); 25 | id(zone3_target_exsits).publish_state(false); 26 | id(zone_ex1_target_exsits).publish_state(false); 27 | 28 | preferences: 29 | flash_write_interval: 5s 30 | 31 | external_components: 32 | - source: 33 | type: git 34 | url: https://github.com/screekworkshop/custom_components_support_for_screek_2a 35 | ref: main 36 | components: [uart] 37 | 38 | esp32: 39 | board: lolin_c3_mini 40 | framework: 41 | type: arduino 42 | version: 2.0.9 43 | platform_version: 6.3.0 44 | 45 | globals: 46 | - id: cpu_speed 47 | type: int 48 | restore_value: no 49 | initial_value: '0' 50 | - id: last_update_ld2450 51 | type: unsigned long 52 | restore_value: no 53 | initial_value: '0' 54 | - id: init_zone_publish 55 | type: bool 56 | restore_value: no 57 | initial_value: "false" 58 | - id: last_illuminance 59 | type: float 60 | restore_value: no 61 | initial_value: "-1" 62 | - id: last_illuminance_timestamp 63 | type: int 64 | restore_value: no 65 | initial_value: "-1" 66 | 67 | improv_serial: 68 | 69 | logger: 70 | 71 | debug: 72 | update_interval: 30s 73 | 74 | api: 75 | 76 | ota: 77 | - platform: esphome 78 | # use your own ota password plz. this is a words by Socrates. 79 | password: "all-things-in-their-being-are-good-for-something" 80 | 81 | safe_mode: 82 | disabled: True 83 | 84 | wifi: 85 | power_save_mode: LIGHT 86 | reboot_timeout: 10min 87 | ap: 88 | ssid: "HUMAN-SENSOR 2A" 89 | 90 | captive_portal: 91 | 92 | web_server: 93 | port: 80 94 | 95 | 96 | text_sensor: 97 | - platform: debug 98 | reset_reason: 99 | name: "ESP Reset Reason" 100 | icon: mdi:anchor 101 | disabled_by_default: True 102 | - platform: wifi_info 103 | ip_address: 104 | name: ESP IP Address 105 | entity_category: "diagnostic" 106 | disabled_by_default: True 107 | icon: mdi:ip-network 108 | mac_address: 109 | name: ESP MAC 110 | entity_category: "diagnostic" 111 | icon: mdi:ip-network 112 | disabled_by_default: True 113 | - platform: template 114 | name: "Zone1 Info" 115 | id: tips_zone1_conf 116 | icon: mdi:information-outline 117 | entity_category: config 118 | lambda: |- 119 | return {"Configure below" }; 120 | update_interval: 1000s 121 | - platform: template 122 | name: "Zone2 Info" 123 | id: tips_zone2_conf 124 | icon: mdi:information-outline 125 | entity_category: config 126 | lambda: |- 127 | return {"Configure below" }; 128 | update_interval: 1000s 129 | - platform: template 130 | name: "Zone3 Info" 131 | id: tips_zone3_conf 132 | icon: mdi:information-outline 133 | entity_category: config 134 | lambda: |- 135 | return {"Configure below" }; 136 | update_interval: 1000s 137 | - platform: template 138 | name: "Zout1 Info" 139 | id: tips_zone_ex1_conf 140 | icon: mdi:information-outline 141 | entity_category: config 142 | lambda: |- 143 | return {"Zone Exclusion 1" }; 144 | update_interval: 1000s 145 | - platform: template 146 | name: "Any-Presence Info" 147 | id: tips_any_presence_conf 148 | icon: mdi:information-outline 149 | entity_category: config 150 | lambda: |- 151 | return {"Any Presence Config" }; 152 | update_interval: 1000s 153 | - platform: template 154 | name: "Target1 Direction" 155 | id: target1_direction 156 | icon: mdi:directions 157 | - platform: template 158 | name: "Target2 Direction" 159 | id: target2_direction 160 | icon: mdi:directions 161 | - platform: template 162 | name: "Target3 Direction" 163 | id: target3_direction 164 | icon: mdi:directions 165 | - platform: template 166 | name: "Target1 Position" 167 | id: target1_position 168 | icon: mdi:directions 169 | - platform: template 170 | name: "Target2 Position" 171 | id: target2_position 172 | icon: mdi:directions 173 | - platform: template 174 | name: "Target3 Position" 175 | id: target3_position 176 | icon: mdi:directions 177 | 178 | number: 179 | - platform: template 180 | name: "Any Presence Timeout" 181 | id: any_presence_timeout 182 | min_value: 0 183 | max_value: 1800 184 | mode: box 185 | device_class: duration 186 | entity_category: config 187 | unit_of_measurement: s 188 | icon: mdi:timer-off 189 | step: 1 190 | optimistic: True 191 | initial_value: 0 192 | restore_value: True 193 | - platform: template 194 | name: "Zone1 Timeout" 195 | id: zone1_x_timeout 196 | min_value: 0 197 | max_value: 1800 198 | mode: box 199 | device_class: duration 200 | entity_category: config 201 | unit_of_measurement: s 202 | icon: mdi:timer-off 203 | step: 1 204 | optimistic: True 205 | initial_value: 0 206 | restore_value: True 207 | - platform: template 208 | name: "Zone2 Timeout" 209 | id: zone2_x_timeout 210 | min_value: 0 211 | max_value: 1800 212 | mode: box 213 | device_class: duration 214 | entity_category: config 215 | unit_of_measurement: s 216 | icon: mdi:timer-off 217 | step: 1 218 | optimistic: True 219 | initial_value: 0 220 | restore_value: True 221 | - platform: template 222 | name: "Zone3 Timeout" 223 | id: zone3_x_timeout 224 | min_value: 0 225 | max_value: 1800 226 | mode: box 227 | device_class: duration 228 | entity_category: config 229 | unit_of_measurement: s 230 | icon: mdi:timer-off 231 | step: 1 232 | optimistic: True 233 | initial_value: 0 234 | restore_value: True 235 | # Zone 1 236 | - platform: template 237 | name: Zone1 X-Begin 238 | id: zone1_x_begin 239 | min_value: -4000 240 | max_value: 4000 241 | mode: box 242 | device_class: distance 243 | entity_category: config 244 | unit_of_measurement: mm 245 | icon: mdi:arrow-left-bold 246 | step: 10 247 | optimistic: True 248 | initial_value: 0 249 | restore_value: True 250 | on_value: 251 | then: 252 | - script.execute: check_zone1_vaild 253 | - platform: template 254 | name: Zone1 X-End 255 | id: zone1_x_end 256 | mode: box 257 | min_value: -4000 258 | max_value: 4000 259 | device_class: distance 260 | unit_of_measurement: mm 261 | entity_category: config 262 | icon: mdi:arrow-right-bold 263 | step: 10 264 | initial_value: 0 265 | optimistic: True 266 | restore_value: True 267 | on_value: 268 | then: 269 | - script.execute: check_zone1_vaild 270 | - platform: template 271 | name: Zone1 Y-Begin 272 | id: zone1_y_begin 273 | mode: box 274 | min_value: 0 275 | max_value: 6000 276 | device_class: distance 277 | entity_category: config 278 | icon: mdi:arrow-up-bold 279 | unit_of_measurement: mm 280 | step: 10 281 | initial_value: 0 282 | optimistic: True 283 | restore_value: True 284 | on_value: 285 | then: 286 | - script.execute: check_zone1_vaild 287 | - platform: template 288 | name: Zone1 Y-End 289 | id: zone1_y_end 290 | icon: mdi:arrow-down-bold 291 | mode: box 292 | min_value: 0 293 | max_value: 6000 294 | initial_value: 0 295 | entity_category: config 296 | device_class: distance 297 | unit_of_measurement: mm 298 | step: 10 299 | optimistic: True 300 | restore_value: True 301 | on_value: 302 | then: 303 | - script.execute: check_zone1_vaild 304 | 305 | # Zone 2 306 | - platform: template 307 | name: Zone2 X-Begin 308 | id: zone2_x_begin 309 | min_value: -4000 310 | max_value: 4000 311 | mode: box 312 | device_class: distance 313 | entity_category: config 314 | unit_of_measurement: mm 315 | icon: mdi:arrow-left-bold 316 | step: 10 317 | optimistic: True 318 | initial_value: 0 319 | restore_value: True 320 | on_value: 321 | then: 322 | - script.execute: check_zone2_vaild 323 | - platform: template 324 | name: Zone2 X-End 325 | id: zone2_x_end 326 | mode: box 327 | min_value: -4000 328 | max_value: 4000 329 | device_class: distance 330 | unit_of_measurement: mm 331 | entity_category: config 332 | icon: mdi:arrow-right-bold 333 | step: 10 334 | initial_value: 0 335 | optimistic: True 336 | restore_value: True 337 | on_value: 338 | then: 339 | - script.execute: check_zone2_vaild 340 | - platform: template 341 | name: Zone2 Y-Begin 342 | id: zone2_y_begin 343 | mode: box 344 | min_value: 0 345 | max_value: 6000 346 | device_class: distance 347 | entity_category: config 348 | icon: mdi:arrow-up-bold 349 | unit_of_measurement: mm 350 | step: 10 351 | initial_value: 0 352 | optimistic: True 353 | restore_value: True 354 | on_value: 355 | then: 356 | - script.execute: check_zone2_vaild 357 | - platform: template 358 | name: Zone2 Y-End 359 | id: zone2_y_end 360 | icon: mdi:arrow-down-bold 361 | mode: box 362 | min_value: 0 363 | max_value: 6000 364 | initial_value: 0 365 | entity_category: config 366 | device_class: distance 367 | unit_of_measurement: mm 368 | step: 10 369 | optimistic: True 370 | restore_value: True 371 | on_value: 372 | then: 373 | - script.execute: check_zone2_vaild 374 | 375 | # Zone 3 376 | - platform: template 377 | name: Zone3 X-Begin 378 | id: zone3_x_begin 379 | min_value: -4000 380 | max_value: 4000 381 | mode: box 382 | device_class: distance 383 | entity_category: config 384 | unit_of_measurement: mm 385 | icon: mdi:arrow-left-bold 386 | step: 10 387 | optimistic: True 388 | initial_value: 0 389 | restore_value: True 390 | on_value: 391 | then: 392 | - script.execute: check_zone3_vaild 393 | - platform: template 394 | name: Zone3 X-End 395 | id: zone3_x_end 396 | mode: box 397 | min_value: -4000 398 | max_value: 4000 399 | device_class: distance 400 | unit_of_measurement: mm 401 | entity_category: config 402 | icon: mdi:arrow-right-bold 403 | step: 10 404 | initial_value: 0 405 | optimistic: True 406 | restore_value: True 407 | on_value: 408 | then: 409 | - script.execute: check_zone3_vaild 410 | - platform: template 411 | name: Zone3 Y-Begin 412 | id: zone3_y_begin 413 | mode: box 414 | min_value: 0 415 | max_value: 6000 416 | device_class: distance 417 | entity_category: config 418 | icon: mdi:arrow-up-bold 419 | unit_of_measurement: mm 420 | step: 10 421 | initial_value: 0 422 | optimistic: True 423 | restore_value: True 424 | on_value: 425 | then: 426 | - script.execute: check_zone3_vaild 427 | - platform: template 428 | name: Zone3 Y-End 429 | id: zone3_y_end 430 | icon: mdi:arrow-down-bold 431 | mode: box 432 | min_value: 0 433 | max_value: 6000 434 | initial_value: 0 435 | entity_category: config 436 | device_class: distance 437 | unit_of_measurement: mm 438 | step: 10 439 | optimistic: True 440 | restore_value: True 441 | on_value: 442 | then: 443 | - script.execute: check_zone3_vaild 444 | 445 | # Zout1 446 | - platform: template 447 | name: Zout1 X-Begin 448 | id: zone_ex1_x_begin 449 | min_value: -4000 450 | max_value: 4000 451 | mode: box 452 | device_class: distance 453 | entity_category: config 454 | unit_of_measurement: mm 455 | icon: mdi:arrow-left-bold 456 | step: 10 457 | optimistic: True 458 | initial_value: 0 459 | restore_value: True 460 | on_value: 461 | then: 462 | - script.execute: check_zout1_vaild 463 | - platform: template 464 | name: Zout1 X-End 465 | id: zone_ex1_x_end 466 | mode: box 467 | min_value: -4000 468 | max_value: 4000 469 | device_class: distance 470 | unit_of_measurement: mm 471 | entity_category: config 472 | icon: mdi:arrow-right-bold 473 | step: 10 474 | initial_value: 0 475 | optimistic: True 476 | restore_value: True 477 | on_value: 478 | then: 479 | - script.execute: check_zout1_vaild 480 | - platform: template 481 | name: Zout1 Y-Begin 482 | id: zone_ex1_y_begin 483 | mode: box 484 | min_value: 0 485 | max_value: 6000 486 | device_class: distance 487 | entity_category: config 488 | icon: mdi:arrow-up-bold 489 | unit_of_measurement: mm 490 | step: 10 491 | initial_value: 0 492 | optimistic: True 493 | restore_value: True 494 | on_value: 495 | then: 496 | - script.execute: check_zout1_vaild 497 | - platform: template 498 | name: Zout1 Y-End 499 | id: zone_ex1_y_end 500 | icon: mdi:arrow-down-bold 501 | mode: box 502 | min_value: 0 503 | max_value: 6000 504 | initial_value: 0 505 | entity_category: config 506 | device_class: distance 507 | unit_of_measurement: mm 508 | step: 10 509 | optimistic: True 510 | restore_value: True 511 | on_value: 512 | then: 513 | - script.execute: check_zout1_vaild 514 | 515 | binary_sensor: 516 | - platform: status 517 | name: Online 518 | id: ink_ha_connected 519 | - platform: template 520 | name: "Any Presence" 521 | id: any_target_exsits 522 | device_class: occupancy 523 | filters: 524 | - delayed_off: !lambda |- 525 | if (!id(init_zone_publish) || !id(zone_fn_enable).state) { 526 | return 0; 527 | }; 528 | return id(any_presence_timeout).state * 1000.0; 529 | - platform: template 530 | name: "Zone1 Presence" 531 | id: zone1_target_exsits 532 | device_class: occupancy 533 | filters: 534 | - delayed_off: !lambda |- 535 | if (!id(init_zone_publish) || !id(zone_fn_enable).state) { 536 | return 0; 537 | } 538 | return id(zone1_x_timeout).state * 1000.0; 539 | - platform: template 540 | name: "Zone2 Presence" 541 | id: zone2_target_exsits 542 | device_class: occupancy 543 | filters: 544 | - delayed_off: !lambda |- 545 | if (!id(init_zone_publish) || !id(zone_fn_enable).state) { 546 | return 0; 547 | } 548 | return id(zone2_x_timeout).state * 1000.0; 549 | - platform: template 550 | name: "Zone3 Presence" 551 | id: zone3_target_exsits 552 | device_class: occupancy 553 | filters: 554 | - delayed_off: !lambda |- 555 | if (!id(init_zone_publish) || !id(zone_fn_enable).state) { 556 | return 0; 557 | } 558 | return id(zone3_x_timeout).state * 1000.0; 559 | - platform: template 560 | name: "Zout1 Presence" 561 | id: zone_ex1_target_exsits 562 | icon: mdi:account-multiple-remove 563 | device_class: occupancy 564 | 565 | i2c: 566 | sda: GPIO7 567 | scl: GPIO11 568 | scan: true 569 | id: bus_a 570 | 571 | script: 572 | - id: check_zone1_vaild 573 | then: 574 | - lambda: |- 575 | if (id(zone1_x_begin).state > id(zone1_x_end).state){ 576 | id(tips_zone1_conf).publish_state("Err: X-Begin > X-End"); 577 | return; 578 | } 579 | if (id(zone1_y_begin).state > id(zone1_y_end).state){ 580 | id(tips_zone1_conf).publish_state("Err: Y-Begin > Y-End"); 581 | return; 582 | } 583 | if (id(zone1_x_begin).state == 0 && id(zone1_x_end).state == 0 && id(zone1_y_begin).state == 0 && id(zone1_y_end).state == 0){ 584 | id(tips_zone1_conf).publish_state("Configure below"); 585 | return; 586 | } 587 | 588 | int x_size = id(zone1_x_end).state - id(zone1_x_begin).state; 589 | int y_size = id(zone1_y_end).state - id(zone1_y_begin).state; 590 | 591 | char combined[80]; 592 | sprintf(combined, "Curr Size: %d x %d", x_size, y_size); 593 | id(tips_zone1_conf).publish_state(combined); 594 | - id: check_zone2_vaild 595 | then: 596 | - lambda: |- 597 | if (id(zone2_x_begin).state > id(zone2_x_end).state){ 598 | id(tips_zone2_conf).publish_state("Err: X-Begin > X-End"); 599 | return; 600 | } 601 | if (id(zone2_y_begin).state > id(zone2_y_end).state){ 602 | id(tips_zone2_conf).publish_state("Err: Y-Begin > Y-End"); 603 | return; 604 | } 605 | if (id(zone2_x_begin).state == 0 && id(zone2_x_end).state == 0 && id(zone2_y_begin).state == 0 && id(zone2_y_end).state == 0){ 606 | id(tips_zone2_conf).publish_state("Configure below"); 607 | return; 608 | } 609 | 610 | int x_size = id(zone2_x_end).state - id(zone2_x_begin).state; 611 | int y_size = id(zone2_y_end).state - id(zone2_y_begin).state; 612 | 613 | char combined[80]; 614 | sprintf(combined, "Curr Size: %d x %d", x_size, y_size); 615 | id(tips_zone2_conf).publish_state(combined); 616 | - id: check_zone3_vaild 617 | then: 618 | - lambda: |- 619 | if (id(zone3_x_begin).state > id(zone3_x_end).state){ 620 | id(tips_zone3_conf).publish_state("Err: X-Begin > X-End"); 621 | return; 622 | } 623 | if (id(zone3_y_begin).state > id(zone3_y_end).state){ 624 | id(tips_zone3_conf).publish_state("Err: Y-Begin > Y-End"); 625 | return; 626 | } 627 | if (id(zone3_x_begin).state == 0 && id(zone3_x_end).state == 0 && id(zone3_y_begin).state == 0 && id(zone3_y_end).state == 0){ 628 | id(tips_zone3_conf).publish_state("Configure below"); 629 | return; 630 | } 631 | 632 | int x_size = id(zone3_x_end).state - id(zone3_x_begin).state; 633 | int y_size = id(zone3_y_end).state - id(zone3_y_begin).state; 634 | 635 | char combined[80]; 636 | sprintf(combined, "Curr Size: %d x %d", x_size, y_size); 637 | id(tips_zone3_conf).publish_state(combined); 638 | - id: check_zout1_vaild 639 | then: 640 | - lambda: |- 641 | if (id(zone_ex1_x_begin).state > id(zone_ex1_x_end).state){ 642 | id(tips_zone_ex1_conf).publish_state("Err: X-Begin > X-End"); 643 | return; 644 | } 645 | if (id(zone_ex1_y_begin).state > id(zone_ex1_y_end).state){ 646 | id(tips_zone_ex1_conf).publish_state("Err: Y-Begin > Y-End"); 647 | return; 648 | } 649 | id(tips_zone_ex1_conf).publish_state("Zone Exclusion 1"); 650 | 651 | sensor: 652 | - platform: template 653 | name: "ESP CPU Speed" 654 | accuracy_decimals: 0 655 | icon: mdi:cpu-32-bit 656 | unit_of_measurement: Mhz 657 | disabled_by_default: True 658 | lambda: |- 659 | return (id(cpu_speed)); 660 | entity_category: "diagnostic" 661 | update_interval: 600s 662 | - platform: template 663 | id: sys_esp_temperature 664 | name: ESP Temperature 665 | lambda: return temperatureRead(); 666 | unit_of_measurement: °C 667 | device_class: TEMPERATURE 668 | update_interval: 45s 669 | entity_category: "diagnostic" 670 | - platform: uptime 671 | name: ESP Uptime 672 | id: sys_uptime 673 | update_interval: 60s 674 | - platform: wifi_signal 675 | name: RSSI 676 | id: wifi_signal_db 677 | update_interval: 60s 678 | entity_category: "diagnostic" 679 | - platform: template 680 | id: esp_memory 681 | icon: mdi:memory 682 | name: ESP Free Memory 683 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 684 | unit_of_measurement: 'kB' 685 | state_class: measurement 686 | entity_category: "diagnostic" 687 | update_interval: 60s 688 | - platform: bh1750 689 | name: "Illuminance" 690 | accuracy_decimals: 1 691 | id: bh1750_light 692 | update_interval: 1s 693 | force_update: true 694 | filters: 695 | - lambda: !lambda |- 696 | auto time = id(time_now).utcnow().timestamp; 697 | if (id(last_illuminance) == x){ 698 | if (time >= (id(last_illuminance_timestamp) + 60)){ 699 | id(last_illuminance_timestamp) = time; 700 | return x; 701 | } else { 702 | return {}; 703 | } 704 | } 705 | if (id(bh1750_fast_update).state){ 706 | id(last_illuminance) = x; 707 | // ESP_LOGD("custom", "Fast Update BH1850"); 708 | id(last_illuminance_timestamp) = time; 709 | return x; 710 | } 711 | if (abs(id(last_illuminance) - x) > 1){ 712 | 713 | id(last_illuminance) = x; 714 | id(last_illuminance_timestamp) = time; 715 | return x; 716 | } 717 | return {}; 718 | 719 | #-------------------------------------# 720 | # 高级雷达数据 721 | - platform: template 722 | name: "All Target Counts" 723 | id: all_target_count 724 | accuracy_decimals: 0 725 | icon: "mdi:counter" 726 | unit_of_measurement: "targets" 727 | - platform: template 728 | name: "Zone1 Target Counts" 729 | id: zone1_target_count 730 | accuracy_decimals: 0 731 | icon: "mdi:counter" 732 | unit_of_measurement: "targets" 733 | - platform: template 734 | name: "Zone2 Target Counts" 735 | id: zone2_target_count 736 | accuracy_decimals: 0 737 | icon: "mdi:counter" 738 | unit_of_measurement: "targets" 739 | - platform: template 740 | name: "Zone3 Target Counts" 741 | id: zone3_target_count 742 | accuracy_decimals: 0 743 | icon: "mdi:counter" 744 | unit_of_measurement: "targets" 745 | - platform: template 746 | name: "Zout1 Target Counts" 747 | id: zone_ex1_target_count 748 | accuracy_decimals: 0 749 | icon: mdi:account-multiple-minus-outline 750 | unit_of_measurement: "targets" 751 | 752 | # Target 1 753 | - platform: template 754 | name: "Target1 X" 755 | id: target1_x 756 | accuracy_decimals: 0 757 | unit_of_measurement: 'mm' 758 | state_class: measurement 759 | icon: mdi:focus-field-horizontal 760 | device_class: distance 761 | - platform: template 762 | name: "Target1 Y" 763 | id: target1_y 764 | accuracy_decimals: 0 765 | unit_of_measurement: 'mm' 766 | state_class: measurement 767 | device_class: distance 768 | icon: mdi:focus-field-vertical 769 | - platform: template 770 | name: "Target1 Speed" 771 | id: target1_speed 772 | accuracy_decimals: 2 773 | unit_of_measurement: 'm/s' 774 | state_class: measurement 775 | device_class: speed 776 | - platform: template 777 | name: "Target1 Resolution" 778 | id: target1_resolution 779 | accuracy_decimals: 0 780 | unit_of_measurement: 'mm' 781 | state_class: measurement 782 | device_class: distance 783 | 784 | # Target 2 785 | - platform: template 786 | name: "Target2 X" 787 | id: target2_x 788 | accuracy_decimals: 0 789 | unit_of_measurement: 'mm' 790 | state_class: measurement 791 | device_class: distance 792 | icon: mdi:focus-field-horizontal 793 | - platform: template 794 | name: "Target2 Y" 795 | id: target2_y 796 | accuracy_decimals: 0 797 | unit_of_measurement: 'mm' 798 | state_class: measurement 799 | device_class: distance 800 | icon: mdi:focus-field-vertical 801 | - platform: template 802 | name: "Target2 Speed" 803 | id: target2_speed 804 | accuracy_decimals: 0 805 | unit_of_measurement: 'm/s' 806 | state_class: measurement 807 | device_class: speed 808 | - platform: template 809 | name: "Target2 Resolution" 810 | id: target2_resolution 811 | accuracy_decimals: 0 812 | unit_of_measurement: 'mm' 813 | state_class: measurement 814 | device_class: distance 815 | 816 | # Target 3 817 | - platform: template 818 | name: "Target3 X" 819 | id: target3_x 820 | accuracy_decimals: 0 821 | unit_of_measurement: 'mm' 822 | state_class: measurement 823 | device_class: distance 824 | icon: mdi:focus-field-horizontal 825 | - platform: template 826 | name: "Target3 Y" 827 | id: target3_y 828 | accuracy_decimals: 0 829 | unit_of_measurement: 'mm' 830 | state_class: measurement 831 | device_class: distance 832 | icon: mdi:focus-field-vertical 833 | - platform: template 834 | name: "Target3 Speed" 835 | id: target3_speed 836 | accuracy_decimals: 0 837 | unit_of_measurement: 'm/s' 838 | state_class: measurement 839 | device_class: speed 840 | - platform: template 841 | name: "Target3 Resolution" 842 | id: target3_resolution 843 | accuracy_decimals: 0 844 | unit_of_measurement: 'mm' 845 | state_class: measurement 846 | device_class: distance 847 | - platform: template 848 | name: "Target1 Angle" 849 | id: target1_angle 850 | unit_of_measurement: 'º' 851 | accuracy_decimals: 1 852 | icon: mdi:angle-acute 853 | - platform: template 854 | name: "Target2 Angle" 855 | id: target2_angle 856 | accuracy_decimals: 1 857 | unit_of_measurement: 'º' 858 | icon: mdi:angle-acute 859 | - platform: template 860 | name: "Target3 Angle" 861 | id: target3_angle 862 | accuracy_decimals: 1 863 | unit_of_measurement: 'º' 864 | icon: mdi:angle-acute 865 | 866 | light: 867 | - platform: status_led 868 | name: sys_status 869 | pin: 870 | number: GPIO13 871 | ignore_pin_validation_error: true 872 | internal: True 873 | restore_mode: ALWAYS_OFF 874 | - platform: binary 875 | name: "Red Info Light" 876 | output: board_info_ed 877 | entity_category: diagnostic 878 | restore_mode: ALWAYS_OFF 879 | 880 | time: 881 | - platform: sntp 882 | id: time_now 883 | 884 | output: 885 | - platform: gpio 886 | id: board_info_ed 887 | pin: 888 | number: GPIO12 889 | ignore_pin_validation_error: true 890 | 891 | switch: 892 | - platform: factory_reset 893 | name: Factory Reset 894 | disabled_by_default: True 895 | icon: mdi:heart-broken 896 | entity_category: diagnostic 897 | - platform: template 898 | name: Zout1 Enable 899 | id: zone_ex1_enable 900 | optimistic: True 901 | icon: mdi:account-cancel 902 | entity_category: config 903 | restore_mode: RESTORE_DEFAULT_OFF 904 | - platform: template 905 | name: Zone Enable 906 | id: zone_fn_enable 907 | optimistic: True 908 | icon: mdi:target-variant 909 | entity_category: config 910 | restore_mode: RESTORE_DEFAULT_ON 911 | - platform: template 912 | name: Illuminance Fast-Update 913 | id: bh1750_fast_update 914 | optimistic: True 915 | entity_category: diagnostic 916 | restore_mode: RESTORE_DEFAULT_OFF 917 | icon: mdi:run-fast 918 | 919 | button: 920 | - platform: restart 921 | icon: mdi:power-cycle 922 | name: "ESP Reboot" 923 | entity_category: diagnostic 924 | 925 | uart: 926 | id: uart_bus 927 | tx_pin: 928 | number: GPIO5 929 | mode: 930 | input: true 931 | pullup: true 932 | rx_pin: 933 | number: GPIO4 934 | mode: 935 | input: true 936 | pullup: true 937 | baud_rate: 256000 938 | parity: NONE 939 | stop_bits: 1 940 | data_bits: 8 941 | debug: 942 | direction: BOTH 943 | dummy_receiver: True 944 | after: 945 | delimiter: [0X55, 0XCC] 946 | sequence: 947 | - lambda: |- 948 | if ((millis() - id(last_update_ld2450)) <= 500) { 949 | return; 950 | }; 951 | id(last_update_ld2450) = millis(); 952 | 953 | // p1 954 | int16_t p1_x = (uint16_t((bytes[5] << 8) | bytes[4] )); 955 | if ((bytes[5] & 0x80) >> 7){ 956 | p1_x -= pow(2, 15); 957 | }else{ 958 | p1_x = 0 - p1_x; 959 | } 960 | 961 | int16_t p1_y = (uint16_t((bytes[7] << 8) | bytes[6] )); 962 | if ((bytes[7] & 0x80) >> 7){ 963 | p1_y -= pow(2, 15); 964 | }else{ 965 | p1_y = 0 - p1_y; 966 | } 967 | 968 | int p1_speed = (bytes[9] << 8 | bytes[8] ); 969 | if ((bytes[9] & 0x80) >> 7){ 970 | p1_speed -= pow(2, 15); 971 | }else{ 972 | p1_speed = 0 - p1_speed; 973 | } 974 | int16_t p1_distance_resolution = (uint16_t((bytes[11] << 8) | bytes[10] )); 975 | 976 | // p2 977 | int16_t p2_x = (uint16_t((bytes[13] << 8) | bytes[12] )); 978 | if ((bytes[13] & 0x80) >> 7){ 979 | p2_x -= pow(2, 15); 980 | }else{ 981 | p2_x = 0 - p2_x; 982 | } 983 | 984 | int16_t p2_y = (uint16_t((bytes[15] << 8) | bytes[14] )); 985 | if ((bytes[15] & 0x80) >> 7){ 986 | p2_y -= pow(2, 15); 987 | }else{ 988 | p2_y = 0 - p2_y; 989 | } 990 | 991 | int p2_speed = (bytes[17] << 8 | bytes[16] ); 992 | if ((bytes[17] & 0x80) >> 7){ 993 | p2_speed -= pow(2, 15); 994 | }else{ 995 | p2_speed = 0 - p2_speed; 996 | } 997 | int16_t p2_distance_resolution = (uint16_t((bytes[19] << 8) | bytes[18] )); 998 | 999 | // p3 1000 | int16_t p3_x = (uint16_t((bytes[21] << 8) | bytes[20] )); 1001 | if ((bytes[21] & 0x80) >> 7){ 1002 | p3_x -= pow(2, 15); 1003 | }else{ 1004 | p3_x = 0 - p3_x; 1005 | } 1006 | 1007 | int16_t p3_y = (uint16_t((bytes[23] << 8) | bytes[22] )); 1008 | if ((bytes[23] & 0x80) >> 7){ 1009 | p3_y -= pow(2, 15); 1010 | }else{ 1011 | p3_y = 0 - p3_y; 1012 | } 1013 | 1014 | int p3_speed = (bytes[25] << 8 | bytes[24] ); 1015 | if ((bytes[25] & 0x80) >> 7){ 1016 | p3_speed -= pow(2, 15); 1017 | }else{ 1018 | p3_speed = 0 - p3_speed; 1019 | } 1020 | 1021 | int16_t p3_distance_resolution = (uint16_t((bytes[27] << 8) | bytes[26] )); 1022 | 1023 | bool p1_vaild = (p1_x != 0 || p1_y > 0); 1024 | bool p2_vaild = (p2_x != 0 || p2_y > 0); 1025 | bool p3_vaild = (p3_x != 0 || p3_y > 0); 1026 | 1027 | // zone exlude 1 1028 | 1029 | int16_t target_count_in_zone_ex1 = 0; 1030 | 1031 | int16_t zone_ex1_x_min = id(zone_ex1_x_begin).state; 1032 | int16_t zone_ex1_x_max = id(zone_ex1_x_end).state; 1033 | int16_t zone_ex1_y_min = id(zone_ex1_y_begin).state; 1034 | int16_t zone_ex1_y_max = id(zone_ex1_y_end).state; 1035 | 1036 | bool p1_zone_ex_enter = false; 1037 | bool p2_zone_ex_enter = false; 1038 | bool p3_zone_ex_enter = false; 1039 | 1040 | if (id(zone_ex1_enable).state){ 1041 | if (p1_vaild){ 1042 | if (p1_x >= zone_ex1_x_min && p1_x <= zone_ex1_x_max && p1_y >= zone_ex1_y_min && p1_y <= zone_ex1_y_max){ 1043 | p1_zone_ex_enter = true; 1044 | target_count_in_zone_ex1 ++; 1045 | } 1046 | } 1047 | if (p2_vaild){ 1048 | if (p2_x >= zone_ex1_x_min && p2_x <= zone_ex1_x_max && p2_y >= zone_ex1_y_min && p2_y <= zone_ex1_y_max){ 1049 | p2_zone_ex_enter = true; 1050 | target_count_in_zone_ex1 ++; 1051 | } 1052 | } 1053 | if (p3_vaild){ 1054 | if (p3_x >= zone_ex1_x_min && p3_x <= zone_ex1_x_max && p3_y >= zone_ex1_y_min && p3_y <= zone_ex1_y_max){ 1055 | p3_zone_ex_enter = true; 1056 | target_count_in_zone_ex1 ++; 1057 | } 1058 | } 1059 | } 1060 | 1061 | bool has_target_in_zone_ex1 = (target_count_in_zone_ex1 > 0); 1062 | 1063 | int16_t all_target_counts = 0; 1064 | if (p1_vaild && !p1_zone_ex_enter){ 1065 | all_target_counts ++; 1066 | } 1067 | if (p2_vaild && !p2_zone_ex_enter){ 1068 | all_target_counts ++; 1069 | } 1070 | if (p3_vaild && !p3_zone_ex_enter){ 1071 | all_target_counts ++; 1072 | } 1073 | 1074 | bool has_target_in_zone_all = (all_target_counts > 0); 1075 | 1076 | int16_t target_count_in_zone1 = 0; 1077 | bool has_target_in_zone1 = false; 1078 | 1079 | int16_t target_count_in_zone2 = 0; 1080 | bool has_target_in_zone2 = false; 1081 | 1082 | int16_t target_count_in_zone3 = 0; 1083 | bool has_target_in_zone3 = false; 1084 | 1085 | if (id(zone_fn_enable).state){ 1086 | 1087 | // zone 1 check 1088 | 1089 | int16_t zone1_x_min = id(zone1_x_begin).state; 1090 | int16_t zone1_x_max = id(zone1_x_end).state; 1091 | int16_t zone1_y_min = id(zone1_y_begin).state; 1092 | int16_t zone1_y_max = id(zone1_y_end).state; 1093 | 1094 | if (p1_vaild && !p1_zone_ex_enter){ 1095 | if (p1_x >= zone1_x_min && p1_x <= zone1_x_max && p1_y >= zone1_y_min && p1_y <= zone1_y_max){ 1096 | target_count_in_zone1 ++; 1097 | } 1098 | } 1099 | if (p2_vaild && !p2_zone_ex_enter){ 1100 | if (p2_x >= zone1_x_min && p2_x <= zone1_x_max && p2_y >= zone1_y_min && p2_y <= zone1_y_max){ 1101 | target_count_in_zone1 ++; 1102 | } 1103 | } 1104 | if (p3_vaild && !p3_zone_ex_enter){ 1105 | if (p3_x >= zone1_x_min && p3_x <= zone1_x_max && p3_y >= zone1_y_min && p3_y <= zone1_y_max){ 1106 | target_count_in_zone1 ++; 1107 | } 1108 | } 1109 | has_target_in_zone1 = (target_count_in_zone1 > 0); 1110 | 1111 | // zone 2 check 1112 | 1113 | int16_t zone2_x_min = id(zone2_x_begin).state; 1114 | int16_t zone2_x_max = id(zone2_x_end).state; 1115 | int16_t zone2_y_min = id(zone2_y_begin).state; 1116 | int16_t zone2_y_max = id(zone2_y_end).state; 1117 | 1118 | if (p1_vaild && !p1_zone_ex_enter){ 1119 | if (p1_x >= zone2_x_min && p1_x <= zone2_x_max && p1_y >= zone2_y_min && p1_y <= zone2_y_max){ 1120 | target_count_in_zone2 ++; 1121 | } 1122 | } 1123 | if (p2_vaild && !p2_zone_ex_enter){ 1124 | if (p2_x >= zone2_x_min && p2_x <= zone2_x_max && p2_y >= zone2_y_min && p2_y <= zone2_y_max){ 1125 | target_count_in_zone2 ++; 1126 | } 1127 | } 1128 | if (p3_vaild && !p3_zone_ex_enter){ 1129 | if (p3_x >= zone2_x_min && p3_x <= zone2_x_max && p3_y >= zone2_y_min && p3_y <= zone2_y_max){ 1130 | target_count_in_zone2 ++; 1131 | } 1132 | } 1133 | 1134 | has_target_in_zone2 = (target_count_in_zone2 > 0); 1135 | 1136 | // zone 3 check 1137 | 1138 | int16_t zone3_x_min = id(zone3_x_begin).state; 1139 | int16_t zone3_x_max = id(zone3_x_end).state; 1140 | int16_t zone3_y_min = id(zone3_y_begin).state; 1141 | int16_t zone3_y_max = id(zone3_y_end).state; 1142 | 1143 | if (p1_vaild && !p1_zone_ex_enter){ 1144 | if (p1_x >= zone3_x_min && p1_x <= zone3_x_max && p1_y >= zone3_y_min && p1_y <= zone3_y_max){ 1145 | target_count_in_zone3 ++; 1146 | } 1147 | } 1148 | if (p2_vaild && !p2_zone_ex_enter){ 1149 | if (p2_x >= zone3_x_min && p2_x <= zone3_x_max && p2_y >= zone3_y_min && p2_y <= zone3_y_max){ 1150 | target_count_in_zone3 ++; 1151 | } 1152 | } 1153 | if (p3_vaild && !p3_zone_ex_enter){ 1154 | if (p3_x >= zone3_x_min && p3_x <= zone3_x_max && p3_y >= zone3_y_min && p3_y <= zone3_y_max){ 1155 | target_count_in_zone3 ++; 1156 | } 1157 | } 1158 | has_target_in_zone3 = (target_count_in_zone3 > 0); 1159 | 1160 | } 1161 | 1162 | // Angle, Position and Direction, idea from walberjunior. 1163 | 1164 | float p1_angle = 0; 1165 | if (p1_vaild){ 1166 | p1_angle = ((float)p1_x / (float)p1_y) * 180 / M_PI;; 1167 | } 1168 | 1169 | std::basic_string p1_position = "Static"; 1170 | if (p1_speed > 0) { 1171 | p1_position = "Moving away"; 1172 | } else if (p1_speed < 0) { 1173 | p1_position = "Approaching"; 1174 | } 1175 | 1176 | std::basic_string p1_direction = "None"; 1177 | if (p1_x > 0) { 1178 | p1_direction = "Right"; 1179 | } else if (p1_x < 0) { 1180 | p1_direction = "Left"; 1181 | } else if (p1_y > 0){ 1182 | p1_direction = "Middle"; 1183 | } 1184 | 1185 | float p2_angle = 0; 1186 | if (p2_vaild){ 1187 | p2_angle = ((float)p2_x / (float)p2_y) * 180 / M_PI;; 1188 | } 1189 | 1190 | std::basic_string p2_position = "Static";; 1191 | if (p2_speed > 0) { 1192 | p2_position = "Moving away"; 1193 | } else if (p2_speed < 0) { 1194 | p2_position = "Approaching"; 1195 | } 1196 | 1197 | std::basic_string p2_direction = "None"; 1198 | if (p2_x > 0) { 1199 | p2_direction = "Right"; 1200 | } else if (p2_x < 0) { 1201 | p2_direction = "Left"; 1202 | } else if (p2_y > 0){ 1203 | p2_direction = "Middle"; 1204 | } 1205 | 1206 | float p3_angle = 0; 1207 | if (p3_vaild){ 1208 | p3_angle = ((float)p3_x / (float)p3_y) * 180 / M_PI;; 1209 | } 1210 | 1211 | std::basic_string p3_position = "Static";; 1212 | if (p3_speed > 0) { 1213 | p3_position = "Moving away"; 1214 | } else if (p3_speed < 0) { 1215 | p3_position = "Approaching"; 1216 | } 1217 | 1218 | std::basic_string p3_direction = "None"; 1219 | if (p3_x > 0) { 1220 | p3_direction = "Right"; 1221 | } else if (p3_x < 0) { 1222 | p3_direction = "Left"; 1223 | } else if (p3_y > 0){ 1224 | p3_direction = "Middle"; 1225 | } 1226 | 1227 | if (id(target1_angle).state != p1_angle){ 1228 | id(target1_angle).publish_state(p1_angle); 1229 | } 1230 | if (id(target2_angle).state != p2_angle){ 1231 | id(target2_angle).publish_state(p2_angle); 1232 | } 1233 | if (id(target3_angle).state != p3_angle){ 1234 | id(target3_angle).publish_state(p3_angle); 1235 | } 1236 | 1237 | if (p1_position != id(target1_position).state){ 1238 | id(target1_position).publish_state(p1_position); 1239 | } 1240 | if (p2_position != id(target2_position).state){ 1241 | id(target2_position).publish_state(p2_position); 1242 | } 1243 | if (p3_position != id(target3_position).state){ 1244 | id(target3_position).publish_state(p3_position); 1245 | } 1246 | 1247 | if (p1_direction != id(target1_direction).state){ 1248 | id(target1_direction).publish_state(p1_direction); 1249 | } 1250 | if (p2_direction != id(target2_direction).state){ 1251 | id(target2_direction).publish_state(p2_direction); 1252 | } 1253 | if (p3_direction != id(target3_direction).state){ 1254 | id(target3_direction).publish_state(p3_direction); 1255 | } 1256 | 1257 | // public all info 1258 | 1259 | if (id(target1_x).state != p1_x){ 1260 | id(target1_x).publish_state(p1_x); 1261 | } 1262 | if (id(target1_y).state != p1_y){ 1263 | id(target1_y).publish_state(p1_y); 1264 | } 1265 | 1266 | float p1_m_speed = float(p1_speed) / 100.0; 1267 | if (id(target1_speed).state != p1_m_speed){ 1268 | id(target1_speed).publish_state(p1_m_speed); 1269 | } 1270 | if (id(target1_resolution).state != p1_distance_resolution){ 1271 | id(target1_resolution).publish_state(p1_distance_resolution); 1272 | } 1273 | 1274 | if (id(target2_x).state != p2_x){ 1275 | id(target2_x).publish_state(p2_x); 1276 | } 1277 | if (id(target2_y).state != p2_y){ 1278 | id(target2_y).publish_state(p2_y); 1279 | } 1280 | if (id(target2_speed).state != p2_speed){ 1281 | id(target2_speed).publish_state(p2_speed); 1282 | } 1283 | if (id(target2_resolution).state != p2_distance_resolution){ 1284 | id(target2_resolution).publish_state(p2_distance_resolution); 1285 | } 1286 | 1287 | if (id(target3_x).state != p3_x){ 1288 | id(target3_x).publish_state(p3_x); 1289 | } 1290 | if (id(target3_y).state != p3_y){ 1291 | id(target3_y).publish_state(p3_y); 1292 | } 1293 | if (id(target3_speed).state != p3_speed){ 1294 | id(target3_speed).publish_state(p3_speed); 1295 | } 1296 | if (id(target3_resolution).state != p3_distance_resolution){ 1297 | id(target3_resolution).publish_state(p3_distance_resolution); 1298 | } 1299 | 1300 | // publish target info 1301 | 1302 | if (id(all_target_count).state != all_target_counts){ 1303 | id(all_target_count).publish_state(all_target_counts); 1304 | id(any_target_exsits).publish_state(has_target_in_zone_all); 1305 | }else if (id(any_target_exsits).state != has_target_in_zone_all){ 1306 | id(any_target_exsits).publish_state(has_target_in_zone_all); 1307 | } 1308 | 1309 | if (id(zone1_target_count).state != target_count_in_zone1){ 1310 | id(zone1_target_count).publish_state(target_count_in_zone1); 1311 | id(zone1_target_exsits).publish_state(has_target_in_zone1); 1312 | }else if (id(zone1_target_exsits).state != has_target_in_zone1){ 1313 | id(zone1_target_exsits).publish_state(has_target_in_zone1); 1314 | } 1315 | 1316 | if (id(zone2_target_count).state != target_count_in_zone2){ 1317 | id(zone2_target_count).publish_state(target_count_in_zone2); 1318 | id(zone2_target_exsits).publish_state(has_target_in_zone2); 1319 | }else if (id(zone2_target_exsits).state != has_target_in_zone2){ 1320 | id(zone2_target_exsits).publish_state(has_target_in_zone2); 1321 | } 1322 | 1323 | if (id(zone3_target_count).state != target_count_in_zone3){ 1324 | id(zone3_target_count).publish_state(target_count_in_zone3); 1325 | id(zone3_target_exsits).publish_state(has_target_in_zone3); 1326 | }else if (id(zone3_target_exsits).state != has_target_in_zone3){ 1327 | id(zone3_target_exsits).publish_state(has_target_in_zone3); 1328 | } 1329 | 1330 | // zout 1331 | if (id(zone_ex1_target_count).state != target_count_in_zone_ex1){ 1332 | id(zone_ex1_target_count).publish_state(target_count_in_zone_ex1); 1333 | } 1334 | 1335 | if (id(zone_ex1_target_exsits).state != has_target_in_zone_ex1){ 1336 | id(zone_ex1_target_exsits).publish_state(has_target_in_zone_ex1); 1337 | } 1338 | 1339 | if (!id(init_zone_publish)){ 1340 | id(init_zone_publish) = true; 1341 | } 1342 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SCREEK Human Sensor DIY Firmware Support 2 | 3 | ## About 4 | This is the source code for the DIY sensors we make, you are free to modify them and use them, and feel free to provide suggestions to us. 5 | 6 | Consider the current privacy so extravagant, and the severe dependence on cloud services. Open source can bring better privacy, and more personalized customization. 7 | 8 | If you would like to purchase one of our DIY products, or take a look at our documentation, feel free to visit 9 | https://www.screek.io/ 10 | 11 | Our Store: 12 | https://store.screek.io 13 | 14 | Our eBay Store: 15 | https://www.ebay.com/str/screekworkshop 16 | 17 | And Here is A FB Group: 18 | https://www.facebook.com/groups/screekworkshop 19 | 20 | And Reddit: 21 | https://www.reddit.com/r/screekworkshop/ 22 | 23 | Happy DIYing! 24 | 25 | ## 🙏 26 | The sensor builds and code have gotten a lot of concerted effort, and ingenuity, from many, many people. 27 | 28 | 29 | ## Something else to say 30 | 31 | We insist on keeping our principles of code openness on Home Assistant sensors because we strongly believe in it: 32 | - Code that is fully localized to run without malicious behavior and is readily available for everyone to review is more reassuring. 33 | - It's great to have the wisdom of everyone working together to improve the source code. 34 | 35 | But at the same time we must apologize that we don't have enough energy to run an open source community at the moment, so our open source code may not be up to date or well commented. 36 | 37 | We hope you'll forgive us for having to spend most of our spare time limited to building and testing hardware, as well as exploring some new areas, and hopefully often getting a chance to take a walk with our families. 38 | -------------------------------------------------------------------------------- /f2/yaml/README.md: -------------------------------------------------------------------------------- 1 | sensor main page: https://docs.screek.io/f2 2 | 3 | The main LD1125F part of the code comes from the LD1125H code driver from [Link_mmWave_Radar_ESPHome](https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome). 4 | 5 | Acknowledgements patrick3399, ssieb. 6 | -------------------------------------------------------------------------------- /f2/yaml/beta-version/human-sensor-f2-beta.yaml: -------------------------------------------------------------------------------- 1 | # screek f2 yaml code 2 | # main ld1125h code from: https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome 3 | # 4 | substitutions: 5 | devicename: "" 6 | upper_devicename: "" 7 | 8 | esphome: 9 | name: screek-human-sensor-f2 10 | comment: Screek Human Sensor F2 11 | friendly_name: Human Sensor F2 12 | name_add_mac_suffix: True 13 | platformio_options: 14 | board_build.flash_mode: dio 15 | # board_build.f_cpu: 80000000L 16 | project: 17 | name: Screek.Human_Presence_Sensor 18 | version: F2 19 | on_boot: 20 | - priority: 100 21 | then: 22 | lambda: |- 23 | id(cpu_speed) = ESP.getCpuFreqMHz(); 24 | - priority: 300 25 | then: 26 | lambda: |- 27 | id(screek_version).publish_state("Beta_V240708_1"); 28 | - priority: -200 29 | then: 30 | - uart.write: 31 | id: LD1125F_UART_BUS 32 | data: !lambda |- 33 | std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125F_mth1).state) +"\r\n"; 34 | return std::vector(th1st.begin(), th1st.end()); 35 | - delay: 100ms 36 | - uart.write: 37 | id: LD1125F_UART_BUS 38 | data: !lambda |- 39 | std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125F_mth2).state) +"\r\n"; 40 | return std::vector(th2st.begin(), th2st.end()); 41 | - delay: 100ms 42 | - uart.write: 43 | id: LD1125F_UART_BUS 44 | data: !lambda |- 45 | std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125F_mth3).state) +"\r\n"; 46 | return std::vector(th3st.begin(), th3st.end()); 47 | - delay: 100ms 48 | - uart.write: 49 | id: LD1125F_UART_BUS 50 | data: !lambda |- 51 | std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125F_rmax).state) +"\r\n"; 52 | return std::vector(rmaxst.begin(), rmaxst.end()); 53 | - delay: 100ms 54 | - uart.write: 55 | id: LD1125F_UART_BUS 56 | data: !lambda |- 57 | std::string utonsst = "utons=" + str_sprintf("%.1f",id(LD1125F_utons).state) +"\r\n"; 58 | return std::vector(utonsst.begin(), utonsst.end()); 59 | 60 | 61 | safe_mode: 62 | disabled: true 63 | 64 | preferences: 65 | flash_write_interval: 5s 66 | 67 | external_components: 68 | - source: 69 | type: git 70 | url: https://github.com/screekworkshop/custom_components_support_for_screek_2a 71 | ref: main 72 | components: [uart] 73 | - source: 74 | type: git 75 | url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. 76 | components: [ serial ] 77 | 78 | esp32: 79 | board: lolin_c3_mini 80 | framework: 81 | type: arduino 82 | version: 2.0.9 83 | platform_version: 6.3.0 84 | 85 | globals: 86 | - id: cpu_speed 87 | type: int 88 | restore_value: no 89 | initial_value: '0' 90 | - id: last_update_ld2450 91 | type: unsigned long 92 | restore_value: no 93 | initial_value: '0' 94 | - id: init_zone_publish 95 | type: bool 96 | restore_value: no 97 | initial_value: "false" 98 | - id: last_illuminance 99 | type: float 100 | restore_value: no 101 | initial_value: "-1" 102 | - id: LD1125F_Last_Time 103 | type: time_t 104 | restore_value: no 105 | initial_value: time(NULL) 106 | - id: LD1125F_Last_Mov_Time 107 | type: time_t 108 | restore_value: no 109 | initial_value: time(NULL) 110 | - id: LD1125F_Clearence_Status 111 | type: bool 112 | restore_value: no 113 | initial_value: "false" 114 | 115 | improv_serial: 116 | 117 | logger: 118 | logs: 119 | bh1750.sensor: INFO 120 | 121 | debug: 122 | update_interval: 30s 123 | 124 | # Enable Home Assistant API 125 | api: 126 | # encryption: 127 | # key: "your-api-key" 128 | 129 | ota: 130 | - platform: esphome 131 | password: "your-ota-password" 132 | 133 | wifi: 134 | # output_power: 15dB 135 | power_save_mode: LIGHT 136 | # power_save_mode: NONE 137 | reboot_timeout: 10min 138 | ap: 139 | ssid: "HUMAN-SENSOR F2" 140 | 141 | captive_portal: 142 | 143 | web_server: 144 | port: 80 145 | 146 | text_sensor: 147 | - platform: template 148 | name: "SCREEK Version" 149 | id: screek_version 150 | icon: mdi:information-outline 151 | entity_category: "diagnostic" 152 | update_interval: never 153 | 154 | - platform: debug 155 | reset_reason: 156 | name: "ESP Reset Reason" 157 | icon: mdi:anchor 158 | disabled_by_default: True 159 | - platform: wifi_info 160 | ip_address: 161 | name: ESP IP Address 162 | entity_category: "diagnostic" 163 | disabled_by_default: True 164 | icon: mdi:ip-network 165 | mac_address: 166 | name: ESP MAC 167 | entity_category: "diagnostic" 168 | icon: mdi:ip-network 169 | disabled_by_default: True 170 | - platform: serial 171 | uart_id: LD1125F_UART_BUS 172 | name: ${upper_devicename} UART Text 173 | id: LD1125F_UART_Text 174 | icon: "mdi:format-text" 175 | entity_category: "diagnostic" 176 | internal: False #If Don't Want to See UART Receive Data, Set To True 177 | filters: 178 | - lambda: |- 179 | static std::string last; 180 | if (x == last) 181 | return {}; 182 | last = x; 183 | return x; 184 | on_value: 185 | lambda: |- 186 | std::string uart_text = id(LD1125F_UART_Text).state; 187 | 188 | if (uart_text == "null"){ 189 | return; 190 | } 191 | 192 | float distance = -1; 193 | std::string uart_state = ""; 194 | if (uart_text.length() > 3) { 195 | uart_state = id(LD1125F_UART_Text).state.substr(0,3); 196 | if (uart_text.length() >= 9) { 197 | if (uart_state == "occ" || uart_state == "mov") { 198 | distance = std::stof(uart_text.substr(9)); 199 | } 200 | } 201 | } 202 | 203 | if (uart_state == "occ" && distance > 0) { 204 | id(LD1125F_Distance).publish_state(distance); 205 | if ((time(NULL)-id(LD1125F_Last_Mov_Time)) >= id(LD1125F_Mov_Time).state) { 206 | id(LD1125F_Occupancy).publish_state("Occupancy"); 207 | if (id(LD1125F_MovOcc_Binary).state == false) { 208 | id(LD1125F_MovOcc_Binary).publish_state(true); 209 | } 210 | if (id(LD1125F_Mov_Binary).state == true) { 211 | id(LD1125F_Mov_Binary).publish_state(false); 212 | } 213 | } 214 | if (id(LD1125F_MovOcc_Binary).state == false) { 215 | id(LD1125F_MovOcc_Binary).publish_state(true); 216 | } 217 | id(LD1125F_Last_Time) = time(NULL); 218 | if (id(LD1125F_Clearence_Status) == true) { 219 | id(LD1125F_Clearence_Status) = false; 220 | } 221 | } 222 | else if (uart_state == "mov" && distance > 0) { 223 | id(LD1125F_Distance).publish_state(distance); 224 | id(LD1125F_Occupancy).publish_state("Movement"); 225 | if (id(LD1125F_MovOcc_Binary).state == false) { 226 | id(LD1125F_MovOcc_Binary).publish_state(true); 227 | } 228 | if (id(LD1125F_Mov_Binary).state == false) { 229 | id(LD1125F_Mov_Binary).publish_state(true); 230 | } 231 | id(LD1125F_Last_Mov_Time) = time(NULL); 232 | id(LD1125F_Last_Time) = time(NULL); 233 | if (id(LD1125F_Clearence_Status) == true) { 234 | id(LD1125F_Clearence_Status) = false; 235 | } 236 | } 237 | - platform: template 238 | name: ${upper_devicename} Occupancy Status 239 | id: LD1125F_Occupancy 240 | icon: "mdi:motion-sensor" 241 | 242 | binary_sensor: 243 | - platform: status 244 | name: Online 245 | id: ink_ha_connected 246 | - platform: template 247 | name: ${upper_devicename} Occupancy or Movement 248 | id: LD1125F_MovOcc_Binary 249 | device_class: occupancy 250 | publish_initial_state: True 251 | - platform: template 252 | name: ${upper_devicename} Movement 253 | id: LD1125F_Mov_Binary 254 | device_class: motion 255 | publish_initial_state: True 256 | 257 | sensor: 258 | - platform: template 259 | name: "ESP CPU Speed" 260 | accuracy_decimals: 0 261 | icon: mdi:cpu-32-bit 262 | unit_of_measurement: Mhz 263 | disabled_by_default: True 264 | lambda: |- 265 | return (id(cpu_speed)); 266 | entity_category: "diagnostic" 267 | update_interval: 600s 268 | - platform: template 269 | id: sys_esp_temperature 270 | name: ESP Temperature 271 | lambda: return temperatureRead(); 272 | unit_of_measurement: "°C" 273 | device_class: TEMPERATURE 274 | update_interval: 45s 275 | entity_category: "diagnostic" 276 | - platform: uptime 277 | name: ESP Uptime 278 | id: sys_uptime 279 | update_interval: 60s 280 | - platform: wifi_signal 281 | name: RSSI 282 | id: wifi_signal_db 283 | update_interval: 60s 284 | entity_category: "diagnostic" 285 | - platform: template 286 | id: esp_memory 287 | icon: mdi:memory 288 | name: ESP Free Memory 289 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 290 | unit_of_measurement: 'kB' 291 | state_class: measurement 292 | entity_category: "diagnostic" 293 | update_interval: 60s 294 | - platform: template 295 | name: ${upper_devicename} Distance 296 | id: LD1125F_Distance 297 | icon: "mdi:signal-distance-variant" 298 | unit_of_measurement: "m" 299 | accuracy_decimals: 2 300 | # filters: # Use Fliter To Debounce 301 | # - sliding_window_moving_average: 302 | # window_size: 8 303 | # send_every: 2 304 | # - heartbeat: 0.2s 305 | - platform: bh1750 306 | name: "Illuminance" 307 | accuracy_decimals: 1 308 | id: bh1750_light 309 | update_interval: 1s 310 | filters: 311 | - delta: 0.1 312 | 313 | light: 314 | - platform: status_led 315 | name: sys_status 316 | pin: 317 | number: GPIO13 318 | ignore_pin_validation_error: true 319 | internal: True 320 | restore_mode: ALWAYS_OFF 321 | - platform: binary 322 | name: "Red Info Light" 323 | output: board_info_ed 324 | entity_category: "config" 325 | restore_mode: ALWAYS_OFF 326 | 327 | i2c: 328 | sda: GPIO7 329 | scl: GPIO11 330 | scan: true 331 | id: bus_a 332 | 333 | output: 334 | - platform: gpio 335 | id: board_info_ed 336 | pin: 337 | number: GPIO12 338 | ignore_pin_validation_error: true 339 | 340 | switch: 341 | - platform: factory_reset 342 | name: Factory Reset 343 | disabled_by_default: True 344 | icon: mdi:heart-broken 345 | 346 | button: 347 | - platform: restart 348 | icon: mdi:power-cycle 349 | name: "ESP Reboot" 350 | entity_category: diagnostic 351 | 352 | uart: 353 | id: LD1125F_UART_BUS 354 | rx_pin: GPIO5 355 | tx_pin: GPIO4 356 | baud_rate: 115200 357 | data_bits: 8 358 | stop_bits: 1 359 | parity: NONE 360 | 361 | interval: 362 | - interval: 1s #Clearance Scan Time 363 | setup_priority: -200 364 | then: 365 | lambda: |- 366 | if ((time(NULL)-id(LD1125F_Last_Time))>id(LD1125F_Clear_Time).state) { 367 | if (id(LD1125F_Distance).state != 0){ 368 | id(LD1125F_Distance).publish_state(0); 369 | } 370 | if ((id(LD1125F_Clearence_Status) == false) || (id(LD1125F_Occupancy).state != "Clearance")) { 371 | id(LD1125F_Occupancy).publish_state("Clearance"); 372 | id(LD1125F_Clearence_Status) = true; 373 | } 374 | if (id(LD1125F_MovOcc_Binary).state == true) { 375 | id(LD1125F_MovOcc_Binary).publish_state(false); 376 | } 377 | if (id(LD1125F_Mov_Binary).state == true) { 378 | id(LD1125F_Mov_Binary).publish_state(false); 379 | } 380 | } 381 | 382 | number: 383 | - platform: template 384 | name: ${upper_devicename} mth1 #mth1 is 0~2.8m Sensitivity. 385 | id: LD1125F_mth1 386 | icon: "mdi:cogs" 387 | optimistic: true 388 | entity_category: config 389 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 390 | initial_value: "60.0" #Default mth1 Setting 391 | min_value: 10.0 392 | max_value: 600.0 393 | step: 5.0 394 | set_action: 395 | then: 396 | - uart.write: 397 | id: LD1125F_UART_BUS 398 | data: !lambda |- 399 | std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n"; 400 | return std::vector(th1st.begin(), th1st.end()); 401 | - delay: 100ms 402 | - uart.write: # save 403 | id: LD1125F_UART_BUS 404 | data: "save\r\n" 405 | - platform: template 406 | name: ${upper_devicename} mth2 #mth2 is 2.8~8m Sensitivity. 407 | id: LD1125F_mth2 408 | icon: "mdi:cogs" 409 | optimistic: true 410 | entity_category: config 411 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 412 | initial_value: "30" #Default mth2 Setting 413 | min_value: 5 414 | max_value: 300 415 | step: 5 416 | set_action: 417 | then: 418 | - uart.write: 419 | id: LD1125F_UART_BUS 420 | data: !lambda |- 421 | std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n"; 422 | return std::vector(th2st.begin(), th2st.end()); 423 | - delay: 100ms 424 | - uart.write: # save 425 | id: LD1125F_UART_BUS 426 | data: "save\r\n" 427 | - platform: template 428 | name: ${upper_devicename} mth3 #mth3 is above 8m Sensitivity. 429 | id: LD1125F_mth3 430 | icon: "mdi:cogs" 431 | entity_category: config 432 | optimistic: true 433 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 434 | initial_value: "20" #Default mth3 Setting 435 | min_value: 5 436 | max_value: 200 437 | step: 5 438 | set_action: 439 | then: 440 | - uart.write: 441 | id: LD1125F_UART_BUS 442 | data: !lambda |- 443 | std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n"; 444 | return std::vector(th3st.begin(), th3st.end()); 445 | - delay: 100ms 446 | - uart.write: # save 447 | id: LD1125F_UART_BUS 448 | data: "save\r\n" 449 | - platform: template 450 | name: ${upper_devicename} Max Distance #rmax is max detection distance. 451 | id: LD1125F_rmax 452 | icon: "mdi:cogs" 453 | entity_category: config 454 | optimistic: true 455 | unit_of_measurement: m 456 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 457 | initial_value: "8" #Default rmax Setting 458 | min_value: 0.4 459 | max_value: 12 460 | step: 0.2 461 | set_action: 462 | then: 463 | - uart.write: 464 | id: LD1125F_UART_BUS 465 | data: !lambda |- 466 | std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; 467 | return std::vector(rmaxst.begin(), rmaxst.end()); 468 | - delay: 100ms 469 | - uart.write: # save 470 | id: LD1125F_UART_BUS 471 | data: "save\r\n" 472 | - platform: template 473 | name: ${upper_devicename} LD1125F Refresh Rate 474 | id: LD1125F_utons 475 | icon: "mdi:refresh" 476 | entity_category: config 477 | optimistic: true 478 | unit_of_measurement: ms 479 | restore_value: true 480 | initial_value: "100" 481 | min_value: 100 482 | max_value: 5000 483 | step: 50 484 | set_action: 485 | then: 486 | - uart.write: 487 | id: LD1125F_UART_BUS 488 | data: !lambda |- 489 | std::string utonsst = "utons=" + std::to_string(x) + "\r\n"; 490 | return std::vector(utonsst.begin(), utonsst.end()); 491 | - delay: 100ms 492 | - uart.write: # save 493 | id: LD1125F_UART_BUS 494 | data: "save\r\n" 495 | - platform: template 496 | name: ${upper_devicename} Clearence Time 497 | id: LD1125F_Clear_Time 498 | icon: "mdi:cogs" 499 | optimistic: true 500 | entity_category: config 501 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 502 | initial_value: "5" #LD1125F Mov/Occ > Clearence Time Here 503 | min_value: 0.5 504 | max_value: 20 505 | step: 0.5 506 | - platform: template 507 | name: ${upper_devicename} Movement Time 508 | id: LD1125F_Mov_Time 509 | icon: "mdi:cogs" 510 | optimistic: true 511 | entity_category: config 512 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 513 | initial_value: "1" #LD1125F Mov > Occ Time Here 514 | min_value: 0.5 515 | max_value: 10 516 | step: 0.5 517 | -------------------------------------------------------------------------------- /f2/yaml/human-sensor-f2-stable.yaml: -------------------------------------------------------------------------------- 1 | # screek f2 yaml code 2 | # main ld1125h code from: https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome 3 | # 4 | substitutions: 5 | devicename: "" 6 | upper_devicename: "" 7 | 8 | esphome: 9 | name: screek-human-sensor-f2 10 | comment: Screek Human Sensor F2 11 | friendly_name: Human Sensor F2 12 | name_add_mac_suffix: True 13 | platformio_options: 14 | board_build.flash_mode: dio 15 | # board_build.f_cpu: 80000000L 16 | project: 17 | name: Screek.Human_Presence_Sensor 18 | version: F2 19 | on_boot: 20 | - priority: 100 21 | then: 22 | lambda: |- 23 | id(cpu_speed) = ESP.getCpuFreqMHz(); 24 | - priority: 300 25 | then: 26 | lambda: |- 27 | id(screek_version).publish_state("V240708_1"); 28 | - priority: -200 29 | then: 30 | - uart.write: 31 | id: LD1125F_UART_BUS 32 | data: !lambda |- 33 | std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125F_mth1).state) +"\r\n"; 34 | return std::vector(th1st.begin(), th1st.end()); 35 | - delay: 100ms 36 | - uart.write: 37 | id: LD1125F_UART_BUS 38 | data: !lambda |- 39 | std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125F_mth2).state) +"\r\n"; 40 | return std::vector(th2st.begin(), th2st.end()); 41 | - delay: 100ms 42 | - uart.write: 43 | id: LD1125F_UART_BUS 44 | data: !lambda |- 45 | std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125F_mth3).state) +"\r\n"; 46 | return std::vector(th3st.begin(), th3st.end()); 47 | - delay: 100ms 48 | - uart.write: 49 | id: LD1125F_UART_BUS 50 | data: !lambda |- 51 | std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125F_rmax).state) +"\r\n"; 52 | return std::vector(rmaxst.begin(), rmaxst.end()); 53 | - delay: 100ms 54 | - uart.write: 55 | id: LD1125F_UART_BUS 56 | data: !lambda |- 57 | std::string utonsst = "utons=" + str_sprintf("%.1f",id(LD1125F_utons).state) +"\r\n"; 58 | return std::vector(utonsst.begin(), utonsst.end()); 59 | 60 | 61 | safe_mode: 62 | disabled: true 63 | 64 | preferences: 65 | flash_write_interval: 5s 66 | 67 | external_components: 68 | - source: 69 | type: git 70 | url: https://github.com/screekworkshop/custom_components_support_for_screek_2a 71 | ref: main 72 | components: [uart] 73 | - source: 74 | type: git 75 | url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. 76 | components: [ serial ] 77 | 78 | esp32: 79 | board: lolin_c3_mini 80 | framework: 81 | type: arduino 82 | version: 2.0.9 83 | platform_version: 6.3.0 84 | 85 | globals: 86 | - id: cpu_speed 87 | type: int 88 | restore_value: no 89 | initial_value: '0' 90 | - id: last_update_ld2450 91 | type: unsigned long 92 | restore_value: no 93 | initial_value: '0' 94 | - id: init_zone_publish 95 | type: bool 96 | restore_value: no 97 | initial_value: "false" 98 | - id: last_illuminance 99 | type: float 100 | restore_value: no 101 | initial_value: "-1" 102 | - id: LD1125F_Last_Time 103 | type: time_t 104 | restore_value: no 105 | initial_value: time(NULL) 106 | - id: LD1125F_Last_Mov_Time 107 | type: time_t 108 | restore_value: no 109 | initial_value: time(NULL) 110 | - id: LD1125F_Clearence_Status 111 | type: bool 112 | restore_value: no 113 | initial_value: "false" 114 | 115 | improv_serial: 116 | 117 | logger: 118 | 119 | debug: 120 | update_interval: 30s 121 | 122 | # Enable Home Assistant API 123 | api: 124 | # encryption: 125 | # key: "your-api-key" 126 | 127 | ota: 128 | - platform: esphome 129 | password: "your-ota-password" 130 | 131 | wifi: 132 | # output_power: 15dB 133 | power_save_mode: LIGHT 134 | # power_save_mode: NONE 135 | reboot_timeout: 10min 136 | ap: 137 | ssid: "HUMAN-SENSOR F2" 138 | 139 | captive_portal: 140 | 141 | web_server: 142 | port: 80 143 | 144 | text_sensor: 145 | - platform: template 146 | name: "SCREEK Version" 147 | id: screek_version 148 | icon: mdi:information-outline 149 | entity_category: "diagnostic" 150 | update_interval: never 151 | 152 | - platform: debug 153 | reset_reason: 154 | name: "ESP Reset Reason" 155 | icon: mdi:anchor 156 | disabled_by_default: True 157 | - platform: wifi_info 158 | ip_address: 159 | name: ESP IP Address 160 | entity_category: "diagnostic" 161 | disabled_by_default: True 162 | icon: mdi:ip-network 163 | mac_address: 164 | name: ESP MAC 165 | entity_category: "diagnostic" 166 | icon: mdi:ip-network 167 | disabled_by_default: True 168 | - platform: serial 169 | uart_id: LD1125F_UART_BUS 170 | name: ${upper_devicename} UART Text 171 | id: LD1125F_UART_Text 172 | icon: "mdi:format-text" 173 | entity_category: "diagnostic" 174 | internal: False #If Don't Want to See UART Receive Data, Set To True 175 | on_value: 176 | lambda: |- 177 | std::string uart_text = id(LD1125F_UART_Text).state; 178 | 179 | if (uart_text == "null"){ 180 | return; 181 | } 182 | 183 | float distance = -1; 184 | std::string uart_state = ""; 185 | if (uart_text.length() > 3){ 186 | uart_state = id(LD1125F_UART_Text).state.substr(0,3); 187 | if (uart_text.length() >= 9) { 188 | if (uart_state == "occ" || uart_state =="mov") { 189 | distance = std::stof(uart_text.substr(9)); 190 | } 191 | } 192 | } 193 | 194 | if (uart_state == "occ" && distance > 0) { 195 | id(LD1125F_Distance).publish_state(distance); 196 | if ((time(NULL)-id(LD1125F_Last_Mov_Time))>id(LD1125F_Mov_Time).state) { 197 | id(LD1125F_Occupancy).publish_state("Occupancy"); 198 | if (id(LD1125F_MovOcc_Binary).state == false) { 199 | id(LD1125F_MovOcc_Binary).publish_state(true); 200 | } 201 | if (id(LD1125F_Mov_Binary).state == true) { 202 | id(LD1125F_Mov_Binary).publish_state(false); 203 | } 204 | } 205 | if (id(LD1125F_MovOcc_Binary).state == false) { 206 | id(LD1125F_MovOcc_Binary).publish_state(true); 207 | } 208 | id(LD1125F_Last_Time) = time(NULL); 209 | if (id(LD1125F_Clearence_Status) == true) { 210 | id(LD1125F_Clearence_Status) = false; 211 | } 212 | } 213 | else if (uart_state == "mov" && distance > 0) { 214 | id(LD1125F_Distance).publish_state(distance); 215 | id(LD1125F_Occupancy).publish_state("Movement"); 216 | if (id(LD1125F_MovOcc_Binary).state == false) { 217 | id(LD1125F_MovOcc_Binary).publish_state(true); 218 | } 219 | if (id(LD1125F_Mov_Binary).state == false) { 220 | id(LD1125F_Mov_Binary).publish_state(true); 221 | } 222 | id(LD1125F_Last_Mov_Time) = time(NULL); 223 | id(LD1125F_Last_Time) = time(NULL); 224 | if (id(LD1125F_Clearence_Status) == true) { 225 | id(LD1125F_Clearence_Status) = false; 226 | } 227 | } 228 | - platform: template 229 | name: ${upper_devicename} Occupancy Status 230 | id: LD1125F_Occupancy 231 | icon: "mdi:motion-sensor" 232 | 233 | binary_sensor: 234 | - platform: status 235 | name: Online 236 | id: ink_ha_connected 237 | - platform: template 238 | name: ${upper_devicename} Occupancy or Movement 239 | id: LD1125F_MovOcc_Binary 240 | device_class: occupancy 241 | - platform: template 242 | name: ${upper_devicename} Movement 243 | id: LD1125F_Mov_Binary 244 | device_class: motion 245 | 246 | sensor: 247 | - platform: template 248 | name: "ESP CPU Speed" 249 | accuracy_decimals: 0 250 | icon: mdi:cpu-32-bit 251 | unit_of_measurement: Mhz 252 | disabled_by_default: True 253 | lambda: |- 254 | return (id(cpu_speed)); 255 | entity_category: "diagnostic" 256 | update_interval: 600s 257 | - platform: template 258 | id: sys_esp_temperature 259 | name: ESP Temperature 260 | lambda: return temperatureRead(); 261 | unit_of_measurement: °C 262 | device_class: TEMPERATURE 263 | update_interval: 45s 264 | entity_category: "diagnostic" 265 | - platform: uptime 266 | name: ESP Uptime 267 | id: sys_uptime 268 | update_interval: 60s 269 | - platform: wifi_signal 270 | name: RSSI 271 | id: wifi_signal_db 272 | update_interval: 60s 273 | entity_category: "diagnostic" 274 | - platform: template 275 | id: esp_memory 276 | icon: mdi:memory 277 | name: ESP Free Memory 278 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 279 | unit_of_measurement: 'kB' 280 | state_class: measurement 281 | entity_category: "diagnostic" 282 | update_interval: 60s 283 | - platform: template 284 | name: ${upper_devicename} Distance 285 | id: LD1125F_Distance 286 | icon: "mdi:signal-distance-variant" 287 | unit_of_measurement: "m" 288 | accuracy_decimals: 2 289 | # filters: # Use Fliter To Debounce 290 | # - sliding_window_moving_average: 291 | # window_size: 8 292 | # send_every: 2 293 | # - heartbeat: 0.2s 294 | - platform: bh1750 295 | name: "Illuminance" 296 | accuracy_decimals: 1 297 | id: bh1750_light 298 | update_interval: 1s 299 | filters: 300 | - delta: 0.1 301 | 302 | light: 303 | - platform: status_led 304 | name: sys_status 305 | pin: 306 | number: GPIO13 307 | ignore_pin_validation_error: true 308 | internal: True 309 | restore_mode: ALWAYS_OFF 310 | - platform: binary 311 | name: "Red Info Light" 312 | output: board_info_ed 313 | entity_category: "config" 314 | restore_mode: ALWAYS_OFF 315 | 316 | i2c: 317 | sda: GPIO7 318 | scl: GPIO11 319 | scan: true 320 | id: bus_a 321 | 322 | output: 323 | - platform: gpio 324 | id: board_info_ed 325 | pin: 326 | number: GPIO12 327 | ignore_pin_validation_error: true 328 | 329 | switch: 330 | - platform: factory_reset 331 | name: Factory Reset 332 | disabled_by_default: True 333 | icon: mdi:heart-broken 334 | 335 | button: 336 | - platform: restart 337 | icon: mdi:power-cycle 338 | name: "ESP Reboot" 339 | entity_category: diagnostic 340 | 341 | uart: 342 | id: LD1125F_UART_BUS 343 | rx_pin: GPIO5 344 | tx_pin: GPIO4 345 | baud_rate: 115200 346 | data_bits: 8 347 | stop_bits: 1 348 | parity: NONE 349 | 350 | interval: 351 | - interval: 1s #Clearance Scan Time 352 | setup_priority: -200 353 | then: 354 | lambda: |- 355 | if ((time(NULL)-id(LD1125F_Last_Time))>id(LD1125F_Clear_Time).state) { 356 | if (id(LD1125F_Distance).state != 0){ 357 | id(LD1125F_Distance).publish_state(0); 358 | } 359 | if ((id(LD1125F_Clearence_Status) == false) || (id(LD1125F_Occupancy).state != "Clearance")) { 360 | id(LD1125F_Occupancy).publish_state("Clearance"); 361 | id(LD1125F_Clearence_Status) = true; 362 | } 363 | if (id(LD1125F_MovOcc_Binary).state == true) { 364 | id(LD1125F_MovOcc_Binary).publish_state(false); 365 | } 366 | if (id(LD1125F_Mov_Binary).state == true) { 367 | id(LD1125F_Mov_Binary).publish_state(false); 368 | } 369 | } 370 | 371 | number: 372 | - platform: template 373 | name: ${upper_devicename} mth1 #mth1 is 0~2.8m Sensitivity. 374 | id: LD1125F_mth1 375 | icon: "mdi:cogs" 376 | optimistic: true 377 | entity_category: config 378 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 379 | initial_value: "60.0" #Default mth1 Setting 380 | min_value: 10.0 381 | max_value: 600.0 382 | step: 5.0 383 | set_action: 384 | then: 385 | - uart.write: 386 | id: LD1125F_UART_BUS 387 | data: !lambda |- 388 | std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n"; 389 | return std::vector(th1st.begin(), th1st.end()); 390 | - delay: 100ms 391 | - uart.write: # save 392 | id: LD1125F_UART_BUS 393 | data: "save\r\n" 394 | - platform: template 395 | name: ${upper_devicename} mth2 #mth2 is 2.8~8m Sensitivity. 396 | id: LD1125F_mth2 397 | icon: "mdi:cogs" 398 | optimistic: true 399 | entity_category: config 400 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 401 | initial_value: "30" #Default mth2 Setting 402 | min_value: 5 403 | max_value: 300 404 | step: 5 405 | set_action: 406 | then: 407 | - uart.write: 408 | id: LD1125F_UART_BUS 409 | data: !lambda |- 410 | std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n"; 411 | return std::vector(th2st.begin(), th2st.end()); 412 | - delay: 100ms 413 | - uart.write: # save 414 | id: LD1125F_UART_BUS 415 | data: "save\r\n" 416 | - platform: template 417 | name: ${upper_devicename} mth3 #mth3 is above 8m Sensitivity. 418 | id: LD1125F_mth3 419 | icon: "mdi:cogs" 420 | entity_category: config 421 | optimistic: true 422 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 423 | initial_value: "20" #Default mth3 Setting 424 | min_value: 5 425 | max_value: 200 426 | step: 5 427 | set_action: 428 | then: 429 | - uart.write: 430 | id: LD1125F_UART_BUS 431 | data: !lambda |- 432 | std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n"; 433 | return std::vector(th3st.begin(), th3st.end()); 434 | - delay: 100ms 435 | - uart.write: # save 436 | id: LD1125F_UART_BUS 437 | data: "save\r\n" 438 | - platform: template 439 | name: ${upper_devicename} Max Distance #rmax is max detection distance. 440 | id: LD1125F_rmax 441 | icon: "mdi:cogs" 442 | entity_category: config 443 | optimistic: true 444 | unit_of_measurement: m 445 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 446 | initial_value: "8" #Default rmax Setting 447 | min_value: 0.4 448 | max_value: 12 449 | step: 0.2 450 | set_action: 451 | then: 452 | - uart.write: 453 | id: LD1125F_UART_BUS 454 | data: !lambda |- 455 | std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; 456 | return std::vector(rmaxst.begin(), rmaxst.end()); 457 | - delay: 100ms 458 | - uart.write: # save 459 | id: LD1125F_UART_BUS 460 | data: "save\r\n" 461 | - platform: template 462 | name: ${upper_devicename} LD1125F Refresh Rate 463 | id: LD1125F_utons 464 | icon: "mdi:refresh" 465 | entity_category: config 466 | optimistic: true 467 | unit_of_measurement: ms 468 | restore_value: true 469 | initial_value: "100" 470 | min_value: 100 471 | max_value: 5000 472 | step: 50 473 | set_action: 474 | then: 475 | - uart.write: 476 | id: LD1125F_UART_BUS 477 | data: !lambda |- 478 | std::string utonsst = "utons=" + std::to_string(x) + "\r\n"; 479 | return std::vector(utonsst.begin(), utonsst.end()); 480 | - delay: 100ms 481 | - uart.write: # save 482 | id: LD1125F_UART_BUS 483 | data: "save\r\n" 484 | - platform: template 485 | name: ${upper_devicename} Clearence Time 486 | id: LD1125F_Clear_Time 487 | icon: "mdi:cogs" 488 | optimistic: true 489 | entity_category: config 490 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 491 | initial_value: "5" #LD1125F Mov/Occ > Clearence Time Here 492 | min_value: 0.5 493 | max_value: 20 494 | step: 0.5 495 | - platform: template 496 | name: ${upper_devicename} Movement Time 497 | id: LD1125F_Mov_Time 498 | icon: "mdi:cogs" 499 | optimistic: true 500 | entity_category: config 501 | restore_value: true #If you don't want to store the setting at ESP, set it to false. 502 | initial_value: "1" #LD1125F Mov > Occ Time Here 503 | min_value: 0.5 504 | max_value: 10 505 | step: 0.5 506 | 507 | -------------------------------------------------------------------------------- /l12/yaml/README.md: -------------------------------------------------------------------------------- 1 | sensor main page: https://docs.screek.io/l12 2 | 3 | The ld2412 library is heavily based on @sebcaps’ ld2410 library. Many thanks to him for his outstanding work. 4 | We would also like to express our gratitude to all the users who participated in the early testing of the L12 sensor. 5 | 6 | We are excited to have developed a new DIY sensor together. -------------------------------------------------------------------------------- /l12/yaml/human-sensor-l12-github.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: screek-human-sensor-l12 3 | comment: Screek Human Sensor L12 4 | friendly_name: Human Sensor L12 5 | name_add_mac_suffix: True 6 | platformio_options: 7 | board_build.flash_mode: dio 8 | project: 9 | name: Screek.Human_Presence_Sensor 10 | version: L12 11 | on_boot: 12 | - priority: 100 13 | then: 14 | lambda: |- 15 | id(cpu_speed) = ESP.getCpuFreqMHz(); 16 | - priority: 300 17 | then: 18 | lambda: |- 19 | id(screek_version).publish_state("BETA_V240712_2"); 20 | 21 | logger: 22 | # level: VERY_VERBOSE 23 | # level: DEBUG 24 | 25 | preferences: 26 | flash_write_interval: 5s 27 | 28 | external_components: 29 | - source: 30 | type: git 31 | url: https://github.com/screekworkshop/custom_components_support_for_screek_l12 32 | ref: main 33 | components: [uart, ld2412] 34 | 35 | esp32: 36 | board: lolin_c3_mini 37 | framework: 38 | type: arduino 39 | version: 2.0.9 40 | platform_version: 6.3.0 41 | 42 | globals: 43 | - id: cpu_speed 44 | type: int 45 | restore_value: no 46 | initial_value: '0' 47 | - id: last_update_ld2450 48 | type: unsigned long 49 | restore_value: no 50 | initial_value: '0' 51 | - id: init_zone_publish 52 | type: bool 53 | restore_value: no 54 | initial_value: "false" 55 | - id: last_illuminance 56 | type: float 57 | restore_value: no 58 | initial_value: "-1" 59 | 60 | improv_serial: 61 | 62 | debug: 63 | update_interval: 30s 64 | 65 | # Enable Home Assistant API 66 | api: 67 | # encryption: 68 | # use you own password 69 | # key: "your-api-key" 70 | 71 | ota: 72 | - platform: esphome 73 | password: "your-ota-password" 74 | 75 | safe_mode: 76 | disabled: true 77 | 78 | wifi: 79 | # output_power: 15dB 80 | power_save_mode: LIGHT 81 | # power_save_mode: NONE 82 | reboot_timeout: 10min 83 | ap: 84 | ssid: "HUMAN-SENSOR L12" 85 | 86 | captive_portal: 87 | 88 | web_server: 89 | port: 80 90 | 91 | text_sensor: 92 | - platform: template 93 | name: "SCREEK Version" 94 | id: screek_version 95 | icon: mdi:information-outline 96 | entity_category: "diagnostic" 97 | update_interval: never 98 | - platform: debug 99 | reset_reason: 100 | name: "ESP Reset Reason" 101 | icon: mdi:anchor 102 | disabled_by_default: True 103 | - platform: wifi_info 104 | ip_address: 105 | name: ESP IP Address 106 | entity_category: "diagnostic" 107 | disabled_by_default: True 108 | icon: mdi:ip-network 109 | mac_address: 110 | name: ESP MAC 111 | entity_category: "diagnostic" 112 | icon: mdi:ip-network 113 | disabled_by_default: True 114 | - platform: ld2412 115 | version: 116 | name: LD2412 FM Version 117 | id: ld2412_fm_version 118 | mac_address: 119 | name: LD2412 Mac 120 | id: ld2412_mac 121 | 122 | 123 | binary_sensor: 124 | - platform: status 125 | name: Online 126 | id: ink_ha_connected 127 | - platform: ld2412 128 | has_target: 129 | name: Presence 130 | has_moving_target: 131 | name: Moving Target 132 | has_still_target: 133 | name: Still Target 134 | 135 | sensor: 136 | - platform: template 137 | name: "ESP CPU Speed" 138 | accuracy_decimals: 0 139 | icon: mdi:cpu-32-bit 140 | unit_of_measurement: Mhz 141 | disabled_by_default: True 142 | lambda: |- 143 | return (id(cpu_speed)); 144 | entity_category: "diagnostic" 145 | update_interval: 600s 146 | - platform: template 147 | id: sys_esp_temperature 148 | name: ESP Temperature 149 | lambda: return temperatureRead(); 150 | unit_of_measurement: °C 151 | device_class: TEMPERATURE 152 | update_interval: 45s 153 | entity_category: "diagnostic" 154 | - platform: uptime 155 | name: ESP Uptime 156 | id: sys_uptime 157 | update_interval: 60s 158 | - platform: wifi_signal 159 | name: RSSI 160 | id: wifi_signal_db 161 | update_interval: 60s 162 | entity_category: "diagnostic" 163 | - platform: template 164 | id: esp_memory 165 | icon: mdi:memory 166 | name: ESP Free Memory 167 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 168 | unit_of_measurement: 'kB' 169 | state_class: measurement 170 | entity_category: "diagnostic" 171 | update_interval: 60s 172 | - platform: ld2412 173 | moving_distance: 174 | name : Moving Distance 175 | id: moving_distance 176 | still_distance: 177 | name: Still Distance 178 | id: still_distance 179 | moving_energy: 180 | name: Move Energy 181 | still_energy: 182 | name: Still Energy 183 | luminance: 184 | name: luminance 185 | 186 | light: 187 | - platform: status_led 188 | name: sys_status 189 | pin: 190 | number: GPIO13 191 | ignore_pin_validation_error: true 192 | internal: True 193 | restore_mode: ALWAYS_OFF 194 | - platform: binary 195 | name: "Red Info Light" 196 | output: board_info_ed 197 | entity_category: diagnostic 198 | restore_mode: ALWAYS_OFF 199 | 200 | time: 201 | - platform: sntp 202 | id: time_now 203 | 204 | output: 205 | - platform: gpio 206 | id: board_info_ed 207 | pin: 208 | number: GPIO12 209 | ignore_pin_validation_error: true 210 | 211 | switch: 212 | - platform: factory_reset 213 | name: "L12 Factory Reset" 214 | disabled_by_default: True 215 | icon: mdi:heart-broken 216 | entity_category: diagnostic 217 | 218 | button: 219 | - platform: restart 220 | icon: mdi:power-cycle 221 | name: "ESP Reboot" 222 | entity_category: diagnostic 223 | - platform: template 224 | name: "LD2412 BLE Enable" 225 | # disabled_by_default: True 226 | entity_category: "config" 227 | icon: mdi:bluetooth 228 | on_press: 229 | lambda: |- 230 | id(ld2412_radar) -> ble_control(true); 231 | - platform: template 232 | name: "LD2412 BLE Disable" 233 | # disabled_by_default: True 234 | entity_category: "config" 235 | icon: mdi:bluetooth-off 236 | on_press: 237 | lambda: |- 238 | id(ld2412_radar) -> ble_control(false); 239 | - platform: template 240 | name: "LD2412 Reboot" 241 | icon: mdi:radar 242 | entity_category: "config" 243 | on_press: 244 | lambda: |- 245 | id(ld2412_radar) -> reboot(); 246 | - platform: template 247 | name: "LD2412 Factory Reset" 248 | icon: mdi:restart 249 | entity_category: "config" 250 | on_press: 251 | - lambda: |- 252 | id(ld2412_radar) -> factoryReset(); 253 | 254 | uart: 255 | id: uart_bus 256 | tx_pin: 257 | number: GPIO11 258 | mode: 259 | input: true 260 | pullup: true 261 | rx_pin: 262 | number: GPIO7 263 | mode: 264 | input: true 265 | pullup: true 266 | baud_rate: 115200 267 | parity: NONE 268 | stop_bits: 1 269 | data_bits: 8 270 | 271 | ld2412: 272 | id: ld2412_radar -------------------------------------------------------------------------------- /l13/yaml/human-sensor-l13-github.yaml: -------------------------------------------------------------------------------- 1 | esphome: 2 | name: screek-human-sensor-l13 3 | comment: Screek Human Sensor L13 4 | friendly_name: Human Sensor L13 5 | name_add_mac_suffix: True 6 | platformio_options: 7 | board_build.flash_mode: dio 8 | # board_build.f_cpu: 80000000L 9 | project: 10 | name: Screek.Human_Presence_Sensor 11 | version: L13 12 | on_boot: 13 | - priority: 1000 14 | then: 15 | - lambda: |- 16 | pinMode(2, OUTPUT); 17 | digitalWrite(2, LOW); 18 | delay(100); 19 | - priority: 100 20 | then: 21 | lambda: |- 22 | id(cpu_speed) = ESP.getCpuFreqMHz(); 23 | 24 | logger: 25 | # level: VERY_VERBOSE 26 | # level: DEBUG 27 | 28 | preferences: 29 | flash_write_interval: 5s 30 | 31 | external_components: 32 | - source: 33 | type: git 34 | url: https://github.com/screekworkshop/custom_components_support_for_screek_l12 35 | ref: main 36 | components: [uart, ld2412] 37 | 38 | esp32: 39 | board: lolin_c3_mini 40 | framework: 41 | type: arduino 42 | version: 2.0.9 43 | platform_version: 6.3.0 44 | 45 | globals: 46 | - id: cpu_speed 47 | type: int 48 | restore_value: no 49 | initial_value: '0' 50 | - id: last_update_ld2450 51 | type: unsigned long 52 | restore_value: no 53 | initial_value: '0' 54 | - id: init_zone_publish 55 | type: bool 56 | restore_value: no 57 | initial_value: "false" 58 | - id: last_illuminance 59 | type: float 60 | restore_value: no 61 | initial_value: "-1" 62 | 63 | improv_serial: 64 | 65 | debug: 66 | update_interval: 30s 67 | 68 | # Enable Home Assistant API 69 | api: 70 | # encryption: 71 | # use you own password 72 | # key: "b1b1F1ArnSZmIvk7WLL9oG19gjPTCmBP1irQlSlSDGY=" 73 | 74 | ota: 75 | - platform: esphome 76 | password: "your-ota-password" 77 | 78 | safe_mode: 79 | disabled: true 80 | 81 | wifi: 82 | # output_power: 15dB 83 | power_save_mode: LIGHT 84 | # power_save_mode: NONE 85 | reboot_timeout: 10min 86 | ap: 87 | ssid: "HUMAN-SENSOR L13" 88 | 89 | captive_portal: 90 | 91 | web_server: 92 | port: 80 93 | 94 | text_sensor: 95 | - platform: debug 96 | reset_reason: 97 | name: "ESP Reset Reason" 98 | icon: mdi:anchor 99 | disabled_by_default: True 100 | - platform: wifi_info 101 | ip_address: 102 | name: ESP IP Address 103 | entity_category: "diagnostic" 104 | disabled_by_default: True 105 | icon: mdi:ip-network 106 | mac_address: 107 | name: ESP MAC 108 | entity_category: "diagnostic" 109 | icon: mdi:ip-network 110 | disabled_by_default: True 111 | - platform: ld2412 112 | version: 113 | name: LD2412S FM Version 114 | id: ld2412_fm_version 115 | mac_address: 116 | name: LD2412S Mac 117 | id: ld2412_mac 118 | 119 | 120 | binary_sensor: 121 | - platform: status 122 | name: Online 123 | id: ink_ha_connected 124 | - platform: ld2412 125 | has_target: 126 | name: Presence 127 | has_moving_target: 128 | name: Moving Target 129 | has_still_target: 130 | name: Still Target 131 | 132 | sensor: 133 | - platform: template 134 | name: "ESP CPU Speed" 135 | accuracy_decimals: 0 136 | icon: mdi:cpu-32-bit 137 | unit_of_measurement: Mhz 138 | disabled_by_default: True 139 | lambda: |- 140 | return (id(cpu_speed)); 141 | entity_category: "diagnostic" 142 | update_interval: 600s 143 | - platform: template 144 | id: sys_esp_temperature 145 | name: ESP Temperature 146 | lambda: return temperatureRead(); 147 | unit_of_measurement: °C 148 | device_class: TEMPERATURE 149 | update_interval: 45s 150 | entity_category: "diagnostic" 151 | - platform: uptime 152 | name: ESP Uptime 153 | id: sys_uptime 154 | update_interval: 60s 155 | - platform: wifi_signal 156 | name: RSSI 157 | id: wifi_signal_db 158 | update_interval: 60s 159 | entity_category: "diagnostic" 160 | - platform: template 161 | id: esp_memory 162 | icon: mdi:memory 163 | name: ESP Free Memory 164 | lambda: return heap_caps_get_free_size(MALLOC_CAP_INTERNAL) / 1024; 165 | unit_of_measurement: 'kB' 166 | state_class: measurement 167 | entity_category: "diagnostic" 168 | update_interval: 60s 169 | - platform: ld2412 170 | moving_distance: 171 | name : Moving Distance 172 | id: moving_distance 173 | still_distance: 174 | name: Still Distance 175 | id: still_distance 176 | moving_energy: 177 | name: Move Energy 178 | still_energy: 179 | name: Still Energy 180 | luminance: 181 | name: LD2412S luminance 182 | entity_category: diagnostic 183 | - platform: bh1750 184 | name: "BH1750 Illuminance" 185 | address: 0x23 186 | update_interval: 1s 187 | 188 | light: 189 | - platform: status_led 190 | name: sys_status 191 | pin: 192 | number: GPIO13 193 | ignore_pin_validation_error: True 194 | internal: True 195 | restore_mode: ALWAYS_OFF 196 | - platform: binary 197 | name: "Red Info Light" 198 | output: board_info_ed 199 | entity_category: diagnostic 200 | restore_mode: ALWAYS_OFF 201 | 202 | time: 203 | - platform: sntp 204 | id: time_now 205 | 206 | output: 207 | - platform: gpio 208 | id: board_info_ed 209 | pin: 210 | number: GPIO12 211 | ignore_pin_validation_error: True 212 | 213 | esp32_improv: 214 | authorizer: none 215 | on_start: 216 | then: 217 | - logger.log: "Improv awaiting authorization/authorized" 218 | on_provisioned: 219 | then: 220 | - logger.log: "Improv provisioned" 221 | on_provisioning: 222 | then: 223 | - logger.log: "Improv provisioning" 224 | on_stop: 225 | then: 226 | - logger.log: "Improv stopped" 227 | 228 | switch: 229 | - platform: factory_reset 230 | name: "L13 Factory Reset" # 或许最好把雷达模块也重新初始化 231 | disabled_by_default: True 232 | icon: mdi:heart-broken 233 | entity_category: diagnostic 234 | 235 | button: 236 | - platform: restart 237 | icon: mdi:power-cycle 238 | name: "ESP Reboot" 239 | entity_category: diagnostic 240 | - platform: template 241 | name: "LD2412S BLE Enable" 242 | # disabled_by_default: True 243 | entity_category: "config" 244 | icon: mdi:bluetooth 245 | on_press: 246 | lambda: |- 247 | id(ld2412s_radar) -> ble_control(true); 248 | - platform: template 249 | name: "LD2412S BLE Disable" 250 | # disabled_by_default: True 251 | entity_category: "config" 252 | icon: mdi:bluetooth-off 253 | on_press: 254 | lambda: |- 255 | id(ld2412s_radar) -> ble_control(false); 256 | - platform: template 257 | name: "LD2412S Reboot" 258 | icon: mdi:radar 259 | entity_category: "config" 260 | on_press: 261 | lambda: |- 262 | id(ld2412s_radar) -> reboot(); 263 | - platform: template 264 | name: "LD2412S Factory Reset" 265 | icon: mdi:restart 266 | entity_category: "config" 267 | on_press: 268 | - lambda: |- 269 | id(ld2412s_radar) -> factoryReset(); 270 | 271 | uart: 272 | id: uart_bus 273 | tx_pin: 274 | number: GPIO11 275 | mode: 276 | input: true 277 | pullup: true 278 | rx_pin: 279 | number: GPIO7 280 | mode: 281 | input: true 282 | pullup: true 283 | baud_rate: 115200 284 | parity: NONE 285 | stop_bits: 1 286 | data_bits: 8 287 | 288 | i2c: 289 | sda: 10 290 | scl: 3 291 | scan: True 292 | 293 | ld2412: 294 | id: ld2412s_radar --------------------------------------------------------------------------------