{"id":481728,"date":"2026-05-30T22:39:25","date_gmt":"2026-05-30T22:39:25","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=481728"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=481728","title":{"rendered":"\u041a\u0430\u043a \u044f \u043d\u0430\u0443\u0447\u0438\u043b Home Assistant \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043e\u0431 \u043e\u043f\u043b\u0430\u0442\u0435 \u0416\u041a\u0425"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<blockquote>\n<p><em>\u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0441\u044f\u0446 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0430:<\/em><\/p>\n<ul>\n<li>\n<p><em>\u0441\u043d\u044f\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u043e\u0434\u044b;<\/em><\/p>\n<\/li>\n<li>\n<p><em>\u0441\u043d\u044f\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u044d\u043d\u0435\u0440\u0433\u0438\u0438;<\/em><\/p>\n<\/li>\n<li>\n<p><em>\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f;<\/em><\/p>\n<\/li>\n<li>\n<p><em>\u043d\u0430\u0439\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443;<\/em><\/p>\n<\/li>\n<li>\n<p><em>\u043e\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0441\u0447\u0435\u0442\u0430.<\/em><\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n<p>\u0421\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043d\u0438\u043c\u0430\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u0421\u0442\u043e\u0438\u043b\u043e \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 21 \u0447\u0438\u0441\u043b\u043e, \u043a\u0430\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0438\u0441\u044c \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u0447\u0451\u0442\u044b, \u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u0443 \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u043a\u043e\u043c\u043c\u0443\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u0435\u0439\u0447\u0430\u0441:<\/p>\n<ul>\n<li>\n<p>Home Assistant \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0434\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u0442\u0441\u044f AI-\u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043d\u0430 ESP32-CAM;<\/p>\n<\/li>\n<li>\n<p>\u044d\u043b\u0435\u043a\u0442\u0440\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430\u043c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c \u0443\u0441\u043b\u0443\u0433;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f;<\/p>\n<\/li>\n<li>\n<p>Telegram \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043e\u0442\u0447\u0451\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0451 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043a \u043d\u0443\u043b\u044e.<\/p>\n<h3>\u042d\u043b\u0435\u043a\u0442\u0440\u043e\u0441\u0447\u0451\u0442\u0447\u0438\u043a<\/h3>\n<p>\u0421 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u043c \u0432\u0441\u0451 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0430 \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u0435\u0441\u0442\u044c \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043d\u044b\u0439 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 \u0441 \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439: 3200 \u0438\u043c\u043f\/\u043a\u0412\u0442\u00b7\u0447. \u041a\u0430\u0436\u0434\u0430\u044f \u0432\u0441\u043f\u044b\u0448\u043a\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0451\u043d\u043d\u043e\u0439 \u044d\u043d\u0435\u0440\u0433\u0438\u0438.<\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0437\u0442\u044c \u043f\u043e\u0434 \u043f\u043b\u043e\u043c\u0431\u044b \u043c\u043d\u0435 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0435\u0441\u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:<\/p>\n<ul>\n<li>\n<p>Wemos D1 Mini;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u0442\u0447\u0438\u043a \u043e\u0441\u0432\u0435\u0449\u0451\u043d\u043d\u043e\u0441\u0442\u0438 TEMT6000;<\/p>\n<\/li>\n<li>\n<p>ESPHome.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0442\u0447\u0438\u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u0441\u043f\u044b\u0448\u043a\u0443. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430 Home Assistant \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u043d\u0430: 1 \/ 3200 \u043a\u0412\u0442\u00b7\u0447. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043a\u0430\u043a \u0442\u043e \u0442\u0430\u043a, \u043f\u043b\u0430\u0442\u0443 Wemos d1 mini, \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u044d\u043b. \u0449\u0438\u0442\u043a\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u043c\u0435\u0442\u0430\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439.<\/p>\n<figure class=\"bordered full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/faf\/8b2\/d98\/faf8b2d98ff36746ce0a11c988ac3150.png\" alt=\"\u0424\u043e\u0442\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430\" title=\"\u0424\u043e\u0442\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430\" width=\"1197\" height=\"1315\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/faf\/8b2\/d98\/faf8b2d98ff36746ce0a11c988ac3150.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/faf\/8b2\/d98\/faf8b2d98ff36746ce0a11c988ac3150.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0424\u043e\u0442\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0434\u0451\u0442\u0441\u044f \u0443\u0447\u0451\u0442 \u0434\u043d\u0435\u0432\u043d\u043e\u0433\u043e \u0438 \u043d\u043e\u0447\u043d\u043e\u0433\u043e \u0442\u0430\u0440\u0438\u0444\u0430. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 Home Assistant \u0437\u043d\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0414\u0435\u043d\u044c;<\/p>\n<\/li>\n<li>\n<p>\u041d\u043e\u0447\u044c;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0449\u0438\u0439 \u0440\u0430\u0441\u0445\u043e\u0434;<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u0442\u043e\u0440\u0438\u044e \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043d\u0430 \u043b\u0435\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0434\u0435\u043d\u044c\\\u043d\u043e\u0447\u044c \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u0440\u0430\u0441\u0441\u0438\u043d\u0445\u0440\u043e\u043d<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 HA<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/341\/2cf\/fa5\/3412cffa56a15cc38aeb8f617eb6a5a3.png\" width=\"782\" height=\"329\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/341\/2cf\/fa5\/3412cffa56a15cc38aeb8f617eb6a5a3.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/341\/2cf\/fa5\/3412cffa56a15cc38aeb8f617eb6a5a3.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<details class=\"spoiler\">\n<summary>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/893\/1bd\/2c5\/8931bd2c563e75edbd0d120a8dfeafb5.png\" width=\"668\" height=\"1520\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/893\/1bd\/2c5\/8931bd2c563e75edbd0d120a8dfeafb5.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/893\/1bd\/2c5\/8931bd2c563e75edbd0d120a8dfeafb5.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0435\u0442\u0447 ESPHome<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"yaml\">esphome:  name: electricmeter  friendly_name: ElectricMeter  on_boot:    priority: -10    then:      - lambda: |-          id(flash_counter_day_sensor).publish_state((float) id(flash_day));          id(flash_counter_night_sensor).publish_state((float) id(flash_night));          id(energy_day_sensor).publish_state(id(energy_day_total));          id(energy_night_sensor).publish_state(id(energy_night_total));          id(energy_sensor).publish_state(id(energy_day_total) + id(energy_night_total));esp8266:  board: d1_mini  restore_from_flash: truepreferences:  flash_write_interval: 1min#logger:api:  encryption:    key: \"\"ota:  - platform: esphome    password: \"\"wifi:  ssid: !secret wifi_ssid  password: !secret wifi_password  ap:    ssid: \"\"    password: \"\"captive_portal:globals:  - id: flash_day    type: int    restore_value: yes    initial_value: '0'  - id: flash_night    type: int    restore_value: yes    initial_value: '0'  - id: energy_day_total    type: float    restore_value: yes    initial_value: '2893.30000'   # 9258560 \/ 3200  - id: energy_night_total    type: float    restore_value: yes    initial_value: '1094.30000'   # 3501760 \/ 3200time:  - platform: homeassistant    id: esptime    timezone: Europe\/Amsterdam    on_time:      - seconds: 0        minutes: 0        hours: 0        then:          - lambda: |-              id(flash_day) = 0;              id(flash_night) = 0;              id(flash_counter_day_sensor).publish_state(0);              id(flash_counter_night_sensor).publish_state(0);sensor:  - platform: adc    pin: A0    name: \"TEMT6000 raw\"    id: light_raw    update_interval: 10ms  - platform: template    name: \"\u041e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u043b\u044e\u043a\u0441\u0430\u0445\"    id: light_lux    unit_of_measurement: \"lx\"    accuracy_decimals: 1    lambda: |-      return id(light_raw).state * 1000.0f;    update_interval: 10ms  - platform: template    name: \"\u0418\u043c\u043f\u0443\u043b\u044c\u0441\u044b \u0434\u0435\u043d\u044c\"    id: flash_counter_day_sensor    unit_of_measurement: \"imp\"    accuracy_decimals: 0    lambda: |-      return (float) id(flash_day);  - platform: template    name: \"\u0418\u043c\u043f\u0443\u043b\u044c\u0441\u044b \u043d\u043e\u0447\u044c1\"    id: flash_counter_night_sensor    unit_of_measurement: \"imp\"    accuracy_decimals: 0    lambda: |-      return (float) id(flash_night);  - platform: template    name: \"\u042d\u043d\u0435\u0440\u0433\u0438\u044f \u0434\u0435\u043d\u044c\"    id: energy_day_sensor    unit_of_measurement: \"kWh\"    device_class: energy    state_class: total_increasing    accuracy_decimals: 5    lambda: |-      return id(energy_day_total);  - platform: template    name: \"\u042d\u043d\u0435\u0440\u0433\u0438\u044f \u043d\u043e\u0447\u044c1\"    id: energy_night_sensor    unit_of_measurement: \"kWh\"    device_class: energy    state_class: total_increasing    accuracy_decimals: 5    lambda: |-      return id(energy_night_total);  - platform: template    name: \"\u042d\u043d\u0435\u0440\u0433\u0438\u044f \u0432\u0441\u0435\u0433\u043e1 \"    id: energy_sensor    unit_of_measurement: \"kWh\"    device_class: energy    state_class: total_increasing    accuracy_decimals: 5    lambda: |-      return id(energy_day_total) + id(energy_night_total);number:  - platform: template    name: \"\u041f\u0440\u0430\u0432\u043a\u0430 \u044d\u043d\u0435\u0440\u0433\u0438\u044f \u0434\u0435\u043d\u044c\"    id: edit_energy_day    min_value: 0    max_value: 100000    step: 0.00001    mode: box    optimistic: false    lambda: |-      return id(energy_day_total);    set_action:      - lambda: |-          id(energy_day_total) = x;          id(energy_day_sensor).publish_state(id(energy_day_total));          id(energy_sensor).publish_state(id(energy_day_total) + id(energy_night_total));  - platform: template    name: \"\u041f\u0440\u0430\u0432\u043a\u0430 \u044d\u043d\u0435\u0440\u0433\u0438\u044f \u043d\u043e\u0447\u044c1\"    id: edit_energy_night    min_value: 0    max_value: 100000    step: 0.00001    mode: box    optimistic: false    lambda: |-      return id(energy_night_total);    set_action:      - lambda: |-          id(energy_night_total) = x;          id(energy_night_sensor).publish_state(id(energy_night_total));          id(energy_sensor).publish_state(id(energy_day_total) + id(energy_night_total));interval:  - interval: 10ms    then:      - lambda: |-          static float last_lux = 0.0f;          static uint32_t last_flash_time = 0;          float current_lux = id(light_lux).state;          uint32_t now_ms = millis();          if ((current_lux - last_lux) &gt; 150.0f &amp;&amp; (now_ms - last_flash_time &gt; 150)) {            last_flash_time = now_ms;            auto now_time = id(esptime).now();            bool is_day = true;            if (now_time.is_valid()) {              is_day = (now_time.hour &gt;= 7 &amp;&amp; now_time.hour &lt; 23);            }            if (is_day) {              id(flash_day)++;              id(energy_day_total) += 1.0f \/ 3200.0f;              id(flash_counter_day_sensor).publish_state(id(flash_day));              id(energy_day_sensor).publish_state(id(energy_day_total));            } else {              id(flash_night)++;              id(energy_night_total) += 1.0f \/ 3200.0f;              id(flash_counter_night_sensor).publish_state(id(flash_night));              id(energy_night_sensor).publish_state(id(energy_night_total));            }            id(energy_sensor).publish_state(id(energy_day_total) + id(energy_night_total));          }          last_lux = current_lux;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>BASH \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u044d\u043b. \u044d\u043d\u0435\u0440\u0433\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">#!\/usr\/bin\/env bashset -euo pipefail################################################### --- \u041d\u0410\u0421\u0422\u0420\u041e\u0419\u041a\u0418 ---##################################################RKS_EMAIL=\"\u041b\u043e\u0433\u0438\u043d\"RKS_PASSWORD=\"\u041f\u0430\u0440\u043e\u043b\u044c\"ACCOUNT_ID=\"\u0430\u0439\u0434\u0438 \u0430\u043a\u043a\u0430\u0443\u0442\u0430\"DEVICE_ID=\"\u0430\u0439\u0434\u0438 \u043f\u0440\u0438\u0431\u043e\u0440\u0430 \u0443\u0447\u0435\u0442\u0430\"HA_URL=\"http:\/\/127.0.0.1:8123\"HA_TOKEN=\"\"  # \u0442\u043e\u043a\u0435\u043d HATG_BOT=\"\u0442\u043e\u043a\u0435\u043d \u0431\u043e\u0442\u0430 \u0422\u0413\"TG_CHATS=(\"\u0430\u0439\u0434\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439\" \"\u0430\u0439\u0434\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439\")TARIFF_DAY=\"ab89b37f-94e4-11ea-960f-00155d016301\"TARIFF_NIGHT=\"ab89b380-94e4-11ea-960f-00155d016301\"################################################### --- \u0424\u0423\u041d\u041a\u0426\u0418\u0418 ---##################################################send_telegram() {  local TEXT=\"$1\"  for CHAT in \"${TG_CHATS[@]}\"; do    curl -s -X POST \"https:\/\/api.telegram.org\/bot${TG_BOT}\/sendMessage\" \\      -d chat_id=\"$CHAT\" \\      -d text=\"$TEXT\" &gt;\/dev\/null  done}fail() {  send_telegram \"\u274c \u041e\u0448\u0438\u0431\u043a\u0430 \u0420\u041a\u0421:\\n$1\"  exit 1}################################################### --- 1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d ---##################################################TOKEN=$(curl -k -s -X POST \"https:\/\/lk.rks-energo.ru\/api\/signin\" \\  -H \"Content-Type: application\/json\" \\  -H \"Accept: application\/json\" \\  -H \"User-Agent: Mozilla\/5.0\" \\  -H \"Origin: https:\/\/lk.rks-energo.ru\" \\  -H \"Referer: https:\/\/lk.rks-energo.ru\/\" \\  -d \"{\\\"email\\\":\\\"$RKS_EMAIL\\\",\\\"password\\\":\\\"$RKS_PASSWORD\\\"}\" \\  | jq -r '.token')[[ -z \"$TOKEN\" || \"$TOKEN\" == \"null\" ]] &amp;&amp; fail \"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d\"################################################### --- 2. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0431\u0430\u043b\u0430\u043d\u0441 ---##################################################RESPONSE=$(curl -k -s -X GET \"https:\/\/lk.rks-energo.ru\/api\/personalAccount\" \\  -H \"Authorization: Bearer $TOKEN\" \\  -H \"Accept: application\/json\")TOTAL=$(echo \"$RESPONSE\" | jq -r '.data[0].balance')VALUE_DAY=$(echo \"$RESPONSE\" | jq -r '.data[0].balance_details[\"1\"].Value \/\/ 0' | tr ',' '.')VALUE_NIGHT=$(echo \"$RESPONSE\" | jq -r '.data[0].balance_details[\"2\"].Value \/\/ 0' | tr ',' '.')################################################### --- 3. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443 ---##################################################AMOUNT=$(printf \"%.2f\" \"$TOTAL\")ORDER_RESPONSE=$(curl -k -s -X GET \\  \"https:\/\/lk.rks-energo.ru\/api\/acquiring\/registerOrder?personal_account_id=$ACCOUNT_ID&amp;amount=$AMOUNT\" \\  -H \"Authorization: Bearer $TOKEN\" \\  -H \"Accept: application\/json\")PAY_URL=$(echo \"$ORDER_RESPONSE\" | jq -r '.data.link \/\/ empty')################################################### --- 4. \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u0435\u043d\u0441\u043e\u0440\u044b HA ---##################################################ha_post() {  local ENTITY=\"$1\"  local STATE=\"$2\"  local NAME=\"$3\"  curl -s -X POST \"$HA_URL\/api\/states\/$ENTITY\" \\    -H \"Authorization: Bearer $HA_TOKEN\" \\    -H \"Content-Type: application\/json\" \\    -d \"{\\\"state\\\":\\\"$STATE\\\",\\\"attributes\\\":{\\\"unit_of_measurement\\\":\\\"\u20bd\\\",\\\"friendly_name\\\":\\\"$NAME\\\"}}\" &gt;\/dev\/null}ha_post \"sensor.rks_penia\" \"$VALUE_NIGHT\" \"\u0420\u041a\u0421 \u0411\u0430\u043b\u0430\u043d\u0441 \u041f\u0435\u043d\u044f\"ha_post \"sensor.rks_current\" \"$VALUE_DAY\" \"\u0420\u041a\u0421 \u0411\u0430\u043b\u0430\u043d\u0441 \u0422\u0435\u043a\u0443\u0449\u0438\u0439\"ha_post \"sensor.rks_total\" \"$TOTAL\" \"\u0420\u041a\u0421 \u0411\u0430\u043b\u0430\u043d\u0441 \u041e\u0431\u0449\u0438\u0439\"if [ -n \"$PAY_URL\" ]; then  ha_post \"sensor.rks_payment_url\" \"$PAY_URL\" \"\u0420\u041a\u0421 \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443\"fi################################################### --- 5. \u0411\u0435\u0440\u0451\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441 HA ---##################################################VALUE_DAY=$(curl -s -X GET \"$HA_URL\/api\/states\/sensor.electricmeter_energiia_den\" \\  -H \"Authorization: Bearer $HA_TOKEN\" | jq -r '.state')VALUE_DAY=$(printf \"%.2f\" \"$VALUE_DAY\")VALUE_NIGHT=$(curl -s -X GET \"$HA_URL\/api\/states\/sensor.electricmeter_energiia_noch1\" \\  -H \"Authorization: Bearer $HA_TOKEN\" | jq -r '.state')VALUE_NIGHT=$(printf \"%.2f\" \"$VALUE_NIGHT\")[[ ! \"$VALUE_DAY\" =~ ^[0-9]+([.][0-9]+)?$ ]] &amp;&amp; fail \"\u0414\u043d\u0435\u0432\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0447\u0438\u0441\u043b\u043e: $VALUE_DAY\"[[ ! \"$VALUE_NIGHT\" =~ ^[0-9]+([.][0-9]+)?$ ]] &amp;&amp; fail \"\u041d\u043e\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0447\u0438\u0441\u043b\u043e: $VALUE_NIGHT\"################################################### --- 6. \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c values \u0434\u043b\u044f POST ---##################################################VALUES=\"[{\\\"value\\\":$VALUE_DAY,\\\"tariff_zone_id\\\":\\\"$TARIFF_DAY\\\"},{\\\"value\\\":$VALUE_NIGHT,\\\"tariff_zone_id\\\":\\\"$TARIFF_NIGHT\\\"}]\"################################################### --- 7. \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 JSON ---##################################################SEND_RESPONSE=$(curl -s -k -X POST \\  \"https:\/\/lk.rks-energo.ru\/api\/personalAccount\/$ACCOUNT_ID\/devices\/$DEVICE_ID\/send\" \\  -H \"Authorization: Bearer $TOKEN\" \\  -F \"values=$VALUES\")# \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0435\u0440\u043d\u0443\u043b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 JSONif ! echo \"$SEND_RESPONSE\" | jq . &gt;\/dev\/null 2&gt;&amp;1; then  fail \"\u0421\u0435\u0440\u0432\u0435\u0440 \u0432\u0435\u0440\u043d\u0443\u043b \u043d\u0435 JSON:\\n$SEND_RESPONSE\"fiSTATUS=$(echo \"$SEND_RESPONSE\" | jq -r '.status \/\/ empty')################################################### --- 8. Telegram \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f ---##################################################if [[ \"$STATUS\" == \"1\" ]]; then  TEXT=$'\u2705 \u041f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b!\\n\\n\u2600\ufe0f \u0414\u0435\u043d\u044c: '\"$VALUE_DAY\"$'\\n\ud83c\udf19 \u041d\u043e\u0447\u044c: '\"$VALUE_NIGHT\"  send_telegram \"$TEXT\"else  ERROR_TEXT=$(echo \"$SEND_RESPONSE\" | jq -r '.data.message \/\/ \"\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430\"')  TEXT=$'\u274c \u041e\u0448\u0438\u0431\u043a\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0420\u041a\u0421!\\n\\n\u041e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430:\\n'\"$ERROR_TEXT\"$'\\n\\n\u2600\ufe0f \u0414\u0435\u043d\u044c: '\"$VALUE_DAY\"$'\\n\ud83c\udf19 \u041d\u043e\u0447\u044c: '\"$VALUE_NIGHT\"  send_telegram \"$TEXT\"fiexit 0<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<p>\u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430.<\/p>\n<h3>\u0412\u043e\u0434\u0430 \u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0435 \u0437\u0440\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0421 \u0432\u043e\u0434\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u043f\u0440\u043e\u0449\u0435. \u041c\u043e\u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0438 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043d\u044b\u0445 \u0432\u044b\u0445\u043e\u0434\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041c\u0435\u043d\u044f\u0442\u044c \u0438\u0441\u043f\u0440\u0430\u0432\u043d\u044b\u0435 \u043f\u0440\u0438\u0431\u043e\u0440\u044b \u0443\u0447\u0451\u0442\u0430 \u0440\u0430\u0434\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u043e\u0448\u0451\u043b \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0451\u043c.<\/p>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u043e\u0434\u043e\u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 ESP32-CAM.<\/p>\n<p>\u041d\u0430 \u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0446\u0438\u0444\u0440 \u043f\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0440\u0443\u0435\u0442 \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0441\u0430\u043c\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f \u044f \u043d\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b \u0441 \u043d\u0443\u043b\u044f.<\/p>\n<p>\u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0431\u044b\u043b \u0432\u0437\u044f\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 AI-on-the-edge-device, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u043f\u0440\u044f\u043c\u043e \u043d\u0430 ESP32-CAM. \u041e \u0441\u0430\u043c\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438 \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u041f\u0430\u0432\u0435\u043b \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u0441\u0430\u0439\u0442\u0435 \u00ab\u0423 \u041f\u0430\u0432\u043b\u0430!\u00bb. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/psenyukov.ru\/topics\/2135?utm_source=chatgpt.com\" rel=\"noopener noreferrer nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u041f\u0430\u0432\u043b\u0430 \u043f\u0440\u043e ESP32-CAM \u0438 AI-on-the-edge-device<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/jomjol\/AI-on-the-edge-device?utm_source=chatgpt.com\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u043e\u0435\u043a\u0442 AI-on-the-edge-device \u043d\u0430 GitHub<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043c\u043e\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u044b\u043b \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0432 Home Assistant \u0438 \u0441\u0442\u0430\u043b \u0447\u0430\u0441\u0442\u044c\u044e \u043e\u0431\u0449\u0435\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0416\u041a\u0425.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 Home Assistant \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0441\u0435\u043d\u0441\u043e\u0440\u044b.<\/p>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0434\u0435\u043b\u0430\u043b \u044f \u0441\u0430\u043c: \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0430 \u0446\u0438\u0444\u0440\u044b \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>\u0412 HA \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bf1\/28e\/8a0\/bf128e8a01d1a40ab88013563369bce9.png\" width=\"800\" height=\"334\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/bf1\/28e\/8a0\/bf128e8a01d1a40ab88013563369bce9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bf1\/28e\/8a0\/bf128e8a01d1a40ab88013563369bce9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>BASH \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0432\u043e\u0434\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"bash\">#!\/usr\/bin\/env bashset -euo pipefail############################### --- \u041d\u0410\u0421\u0422\u0420\u041e\u0419\u041a\u0418 ---##############################COOKIE_FILE=\"\/config\/scripts\/water_cookies.cookie\"   # Netscape cookie fileTOKENS_FILE=\"\/config\/scripts\/water_tokens.json\"     # \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 JSON \u0441 \u0442\u043e\u043a\u0435\u043d\u0430\u043c\u0438HOME_URL=\"\"LOGIN_URL=\"\"# \u0417\u0430\u0449\u0438\u0442\u0430 \u0444\u0430\u0439\u043b\u043e\u0432mkdir -p \"$(dirname \"$COOKIE_FILE\")\"touch \"$COOKIE_FILE\"chmod 600 \"$COOKIE_FILE\"touch \"$TOKENS_FILE\"chmod 600 \"$TOKENS_FILE\"#echo \"==&gt; 1) \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0435 cookies (GET $HOME_URL)\"curl -s -c \"$COOKIE_FILE\" -A \"Mozilla\/5.0\" \\  -H \"Accept: *\/*\" \\  -H \"Accept-Language: ru,en;q=0.9\" \\  \"$HOME_URL\" &gt; \/dev\/null || true#echo \"==&gt; 2) \u041b\u043e\u0433\u0438\u043d\u0438\u043c\u0441\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043a\u0443\u043a\u0438 \u0432 $COOKIE_FILE\"# \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c POST \u043d\u0430 \u043b\u043e\u0433\u0438\u043d; \u0442\u0435\u043b\u043e - JSON {username, password}''LOGIN_RESPONSE=$(curl -s -c \"$COOKIE_FILE\" -b \"$COOKIE_FILE\" -X POST \"$LOGIN_URL\" \\  -H \"Content-Type: application\/json;charset=utf-8\" \\  -H \"Accept: application\/json, text\/plain, *\/*\" \\  -H \"Origin: https:\/\/xn----7sbdqbfldlsq5dd8p.xn--p1ai\" \\  -H \"Referer: https:\/\/xn----7sbdqbfldlsq5dd8p.xn--p1ai\/\" \\  -H \"User-Agent: Mozilla\/5.0\" \\  -d '{\"username\":\"\u041b\u043e\u0433\u0438\u043d\",\"password\":\"\u041f\u0430\u043e\u043b\u044c\"}')# \u0422\u0435\u043b\u043e \u043e\u0442\u0432\u0435\u0442\u0430 (\u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438)#echo \"Login response body:\"#if echo \"$LOGIN_RESPONSE\" | jq . &gt;\/dev\/null 2&gt;&amp;1; then#  echo \"$LOGIN_RESPONSE\" | jq .#else#  echo \"$LOGIN_RESPONSE\"#fi#echo####################################################### --- 3) \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d\u044b \u0438\u0437 cookie-\u0444\u0430\u0439\u043b\u0430 ---####################################################### \u0424\u043e\u0440\u043c\u0430\u0442 Netscape cookie: domain [tab] flag [tab] path [tab] secure [tab] expiry [tab] name [tab] value# \u0418\u043c\u044f \u043a\u0443\u043a\u0438 \u2014 \u0432 6-\u043c \u043f\u043e\u043b\u0435, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u2014 \u0432 7-\u043c \u043f\u043e\u043b\u0435 (awk \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u0435\u043b\u044b\/\u0442\u0430\u0431\u044b)COOKIE_FILE=\"\/config\/scripts\/water_cookies.cookie\"TOKENS_FILE=\"\/config\/scripts\/water_tokens.json\"# \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u043c unix-\u0444\u043e\u0440\u043c\u0430\u0442 (\u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 CR)# (\u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u2014 \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0435\u0441\u043b\u0438 \u043a\u0443\u043a\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0441 CRLF)sed -i 's\/\\r$\/\/' \"$COOKIE_FILE\" || trueget_cookie_value() {  local name=\"$1\"  awk -v name=\"$name\" -F $'\\t' '$6==name{print $7}' \"$COOKIE_FILE\" 2&gt;\/dev\/null | tail -n1 || true}CSRFTOKEN=$(get_cookie_value \"csrftoken\")ACCESS_TOKEN=$(get_cookie_value \"access_token\")REFRESH_TOKEN=$(get_cookie_value \"refresh_token\")#echo \"Parsed cookie values:\"#echo \" CSRFTOKEN: ${CSRFTOKEN:-&lt;none&gt;}\"#echo \" ACCESS_TOKEN: ${ACCESS_TOKEN:-&lt;none&gt;}\"#echo \" REFRESH_TOKEN: ${REFRESH_TOKEN:-&lt;none&gt;}\"jq -n \\  --arg at \"$ACCESS_TOKEN\" \\  --arg rt \"$REFRESH_TOKEN\" \\  --arg ct \"$CSRFTOKEN\" \\  '{     access_token: (if $at == \"\" then null else $at end),     refresh_token: (if $rt == \"\" then null else $rt end),     csrftoken: (if $ct == \"\" then null else $ct end)   }' &gt; \"$TOKENS_FILE\"chmod 600 \"$TOKENS_FILE\"#echo \"Wrote tokens to $TOKENS_FILE\"cat \"$TOKENS_FILE\"VALUE_COLD=$(curl -s -X GET \"http:\/\/127.0.0.1:8123\/api\/states\/sensor.khololdnaia_voda\" \\  -H \"Authorization: Bearer \u0442\u043e\u043a\u0435\u043d HA\" \\  -H \"Content-Type: application\/json\" | jq -r '.state'| awk '{printf(\"%d\\n\",$1)}')VALUE_HOT=$(curl -s -X GET \"http:\/\/127.0.0.1:8123\/api\/states\/sensor.goriachaia_voda\" \\  -H \"Authorization: Bearer \u0442\u043e\u043a\u0435\u043d HA\" \\  -H \"Content-Type: application\/json\" | jq -r '.state'| awk '{printf(\"%d\\n\",$1)}')####################################################### --- 4) \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f  ---######################################################SEND_URL=\"\"# \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c JSON \u0442\u0435\u043b\u043ePAYLOAD=$(jq -n \\  --argjson cold \"$VALUE_COLD\" \\  --argjson hot \"$VALUE_HOT\" \\  '{    meters: [      {meter_id: \"\", values: [$cold]},      {meter_id: \"\", values: [$hot]}    ]  }')#echo \"==&gt; \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f: cold=$VALUE_COLD, hot=$VALUE_HOT\"RESPONSE=$(curl -s -X POST \"$SEND_URL\" \\  -H \"Content-Type: application\/json;charset=utf-8\" \\  -H \"X-CSRFToken: $CSRFTOKEN\" \\  -b \"$COOKIE_FILE\" \\  -d \"$PAYLOAD\")#echo \"\u041e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430:\"#echo \"$RESPONSE\" | jq . || echo \"$RESPONSE\"####################################################### --- 6. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438 Telegram \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 ---######################################################STATUS=$(echo \"$RESPONSE\" | jq -r '.status_code')if echo \"$RESPONSE\" | jq -e '.errors? | length &gt; 0' &gt;\/dev\/null; then PARSED_ERRORS=$(echo \"$RESPONSE\" | jq -r '.errors[]' \\        | sed 's\/\u0421\u0447\u0451\u0442\u0447\u0438\u043a \u211601896 68\/\u0425\u043e\u043b\u043e\u0434\u043d\u0430\u044f \u0432\u043e\u0434\u0430\/g' \\        | sed 's\/\u0421\u0447\u0451\u0442\u0447\u0438\u043a \u211601896 74\/\u0413\u043e\u0440\u044f\u0447\u0430\u044f \u0432\u043e\u0434\u0430\/g') TEXT=$'\u274c \u041e\u0448\u0438\u0431\u043a\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439!\\n\u041e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430:\\n'\"$PARSED_ERRORS\"  curl -s -X POST \"https:\/\/api.telegram.org\/\u0442\u043e\u043a\u0435\u043d\/sendMessage\" \\    -d chat_id= \\    -d text=\"$TEXT\"  curl -s -X POST \"https:\/\/api.telegram.org\/\u0442\u043e\u043a\u0435\u043d\/sendMessage\" \\    -d chat_id= \\    -d text=\"$TEXT\"else    curl -s -X POST \"https:\/\/api.telegram.org\/\u0442\u043e\u043a\u0435\u043d\/sendMessage\" \\    -d chat_id= \\    -d text=\"\u2705 \u041f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u043e\u0434\u0438\u0447\u043a\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b:\u2744\ufe0f \u0425\u043e\u043b\u043e\u0434\u043d\u044f - $VALUE_COLD m\u00b3\ud83d\udd25 \u0413\u043e\u0440\u044f\u0447\u0430\u044f - $VALUE_HOT m\u00b3\"    curl -s -X POST \"https:\/\/api.telegram.org\/\u0442\u043e\u043a\u0435\u043d\/sendMessage\" \\    -d chat_id= \\    -d text=\"\u2705 \u041f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u043e\u0434\u0438\u0447\u043a\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b:\u2744\ufe0f \u0425\u043e\u043b\u043e\u0434\u043d\u044f - $VALUE_COLD m\u00b3\ud83d\udd25 \u0413\u043e\u0440\u044f\u0447\u0430\u044f - $VALUE_HOT m\u00b3\"fi<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<h3>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439<\/h3>\n<p>\u041a\u0430\u0436\u0434\u043e\u0435 21 \u0447\u0438\u0441\u043b\u043e Home Assistant \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432.<\/p>\n<p>\u0414\u043b\u044f \u0432\u043e\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f:<\/p>\n<ol>\n<li>\n<p>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 cookies \u0438 CSRF-\u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0438\u0437 Home Assistant.<\/p>\n<\/li>\n<li>\n<p>\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 JSON-\u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a \u0443\u0441\u043b\u0443\u0433 \u043e\u0442\u043a\u043b\u043e\u043d\u0438\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f, \u0432 Telegram \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438. \u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u2014 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435.<\/p>\n<figure class=\"bordered full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b59\/914\/257\/b59914257ce7cd0952b5e45b9fa0bdfe.png\" width=\"908\" height=\"259\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b59\/914\/257\/b59914257ce7cd0952b5e45b9fa0bdfe.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b59\/914\/257\/b59914257ce7cd0952b5e45b9fa0bdfe.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u044d\u043d\u0435\u0440\u0433\u0438\u0438.<\/p>\n<figure class=\"bordered full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c76\/6b9\/e77\/c766b9e77733443d958a9b8ccfd600b4.png\" width=\"917\" height=\"329\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/c76\/6b9\/e77\/c766b9e77733443d958a9b8ccfd600b4.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c76\/6b9\/e77\/c766b9e77733443d958a9b8ccfd600b4.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0435 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0445\u043e\u0434\u044f\u0442 \u0432 \u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u043e\u0432 \u0443\u0441\u043b\u0443\u0433 \u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442:<\/p>\n<ul>\n<li>\n<p>\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0434\u043e\u043b\u0433;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u043d\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u0441\u0443\u043c\u043c\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f:<\/p>\n<ul>\n<li>\n<p>\u0432\u043e\u0434\u0430;<\/p>\n<\/li>\n<li>\n<p>\u044d\u043b\u0435\u043a\u0442\u0440\u043e\u044d\u043d\u0435\u0440\u0433\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043e\u043f\u043b\u0435\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u043f\u0438\u0442\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u043c\u043e\u043d\u0442.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043e\u0442\u043e\u043f\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443.<\/p>\n<h3>Telegram \u0432\u043c\u0435\u0441\u0442\u043e \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u043e\u0432<\/h3>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0441\u044f\u0446 \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0435\u0434\u0438\u043d\u044b\u0439 \u043e\u0442\u0447\u0451\u0442.<\/p>\n<ul>\n<li>\n<p>\u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0434\u043e\u043b\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443.<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c<\/summary>\n<div class=\"spoiler__content\">\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c41\/a9c\/a2e\/c41a9ca2eadd53c0e4ec18bb5f53c3a9.png\" width=\"913\" height=\"1440\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/c41\/a9c\/a2e\/c41a9ca2eadd53c0e4ec18bb5f53c3a9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c41\/a9c\/a2e\/c41a9ca2eadd53c0e4ec18bb5f53c3a9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<\/div>\n<\/details>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u0430\u0439\u0442\u043e\u0432, \u043b\u043e\u0433\u0438\u043d\u044b \u0438 \u043f\u0430\u0440\u043e\u043b\u0438 \u0438\u043b\u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u0432 \u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435. \u0412\u0441\u0451 \u0443\u0436\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0438. \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u0444\u043e\u0440\u043c\u0443 \u043e\u043f\u043b\u0430\u0442\u044b \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u043b\u0430\u0442\u044b. <\/p>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>\u041f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u043e\u0434\u044b.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 Home Assistant \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043c\u0443\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u043b\u0443\u0433\u0430\u043c\u0438.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u0430:<\/p>\n<ul>\n<li>\n<p>\u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0435\u0442 \u043e \u0437\u0430\u0434\u043e\u043b\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u043c\u043d\u0435 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c Telegram \u0438 \u043d\u0430\u0436\u0430\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u041e\u043f\u043b\u0430\u0442\u0438\u0442\u044c\u00bb. \u0422\u0430\u043a \u0436\u0435 \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u0432\u0438\u0442\u0430\u043d\u0446\u0438\u0438 \u0441\u0440\u0430\u0437\u0443 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442, \u043d\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u0447\u0442\u043e \u044d\u0442\u043e \u043b\u0438\u0448\u043d\u044f\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0431\u043e\u0442\u0435 \u0438 IMAP \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f HA \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0439<\/p>\n<p>PS: \u0422\u0430\u043a\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0441 \u0431\u043e\u0442\u0430\u043c\u0438 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1041648\/\">https:\/\/habr.com\/ru\/articles\/1041648\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0441\u044f\u0446 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0430:\u0441\u043d\u044f\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u043e\u0434\u044b;\u0441\u043d\u044f\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u044d\u043d\u0435\u0440\u0433\u0438\u0438;\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f;\u043d\u0430\u0439\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443;\u043e\u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0441\u0447\u0435\u0442\u0430.\u0421\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043d\u0438\u043c\u0430\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u0421\u0442\u043e\u0438\u043b\u043e \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0435 21 \u0447\u0438\u0441\u043b\u043e, \u043a\u0430\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u043b\u0438\u0441\u044c \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u0447\u0451\u0442\u044b, \u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u0443 \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u043a\u043e\u043c\u043c\u0443\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u0435\u0439\u0447\u0430\u0441:Home Assistant \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432;\u0432\u043e\u0434\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0451\u0442\u0441\u044f AI-\u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043d\u0430 ESP32-CAM;\u044d\u043b\u0435\u043a\u0442\u0440\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430\u043c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430;\u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c \u0443\u0441\u043b\u0443\u0433;\u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442\u0441\u044f;\u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f;Telegram \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043e\u0442\u0447\u0451\u0442.\u041c\u043e\u0451 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043a \u043d\u0443\u043b\u044e.\u042d\u043b\u0435\u043a\u0442\u0440\u043e\u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0421 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u043c \u0432\u0441\u0451 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0430 \u043a\u043e\u0440\u043f\u0443\u0441\u0435 \u0435\u0441\u0442\u044c \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u043d\u044b\u0439 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 \u0441 \u043c\u0430\u0440\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439: 3200 \u0438\u043c\u043f\/\u043a\u0412\u0442\u00b7\u0447. \u041a\u0430\u0436\u0434\u0430\u044f \u0432\u0441\u043f\u044b\u0448\u043a\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0451\u043d\u043d\u043e\u0439 \u044d\u043d\u0435\u0440\u0433\u0438\u0438.\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043a \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0437\u0442\u044c \u043f\u043e\u0434 \u043f\u043b\u043e\u043c\u0431\u044b \u043c\u043d\u0435 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0435\u0441\u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:Wemos D1 Mini;\u0434\u0430\u0442\u0447\u0438\u043a \u043e\u0441\u0432\u0435\u0449\u0451\u043d\u043d\u043e\u0441\u0442\u0438 TEMT6000;ESPHome.\u0414\u0430\u0442\u0447\u0438\u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043a\u0430\u0436\u0434\u0443\u044e \u0432\u0441\u043f\u044b\u0448\u043a\u0443. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430 Home Assistant \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u043d\u0430: 1 \/ 3200 \u043a\u0412\u0442\u00b7\u0447. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u043a\u0430\u043a \u0442\u043e \u0442\u0430\u043a, \u043f\u043b\u0430\u0442\u0443 Wemos d1 mini, \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u044d\u043b. \u0449\u0438\u0442\u043a\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u043c\u0435\u0442\u0430\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0439.\u0424\u043e\u0442\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0434\u0451\u0442\u0441\u044f \u0443\u0447\u0451\u0442 \u0434\u043d\u0435\u0432\u043d\u043e\u0433\u043e \u0438 \u043d\u043e\u0447\u043d\u043e\u0433\u043e \u0442\u0430\u0440\u0438\u0444\u0430. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 Home Assistant \u0437\u043d\u0430\u0435\u0442:\u0414\u0435\u043d\u044c;\u041d\u043e\u0447\u044c;\u041e\u0431\u0449\u0438\u0439 \u0440\u0430\u0441\u0445\u043e\u0434;\u0418\u0441\u0442\u043e\u0440\u0438\u044e \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f.\u0422\u0430\u043a \u0436\u0435 \u043d\u0430 \u043b\u0435\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0434\u0435\u043d\u044c\\\u043d\u043e\u0447\u044c \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u043b \u0440\u0430\u0441\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0422\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 HA\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438\u0421\u043a\u0435\u0442\u0447 ESPHomeesphome:  name: electricmeter  friendly_name: ElectricMeter  on_boot:    priority: -10    then:      &#8212; lambda: |-          id(flash_counter_day_sensor).publish_state((float) id(flash_day));          id(flash_counter_night_sensor).publish_state((float) id(flash_night));          id(energy_day_sensor).publish_state(id(energy_day_total));          id(energy_night_sensor).publish_state(id(energy_night_total));          id(energy_sensor).publish_state(id(energy_day_total) + id(energy_night_total));esp8266:  board: d1_mini  restore_from_flash: truepreferences:  flash_write_interval: 1min#logger:api:  encryption:    key: &#171;&#187;ota:  &#8212; platform: esphome    password: &#171;&#187;wifi:  ssid: !secret wifi_ssid  password: !secret wifi_password  ap:    ssid: &#171;&#187;    password: &#171;&#187;captive_portal:globals:  &#8212; id: flash_day    type: int    restore_value: yes    initial_value: &#8216;0&#8217;  &#8212; id: flash_night    type: int    restore_value: yes    initial_value: &#8216;0&#8217;  &#8212; id: energy_day_total    type: float    restore_value: yes    initial_value: &#8216;2893.30000&#8217;   # 9258560 \/ 3200  &#8212; id: energy_night_total    type: float    restore_value: yes    initial_value: &#8216;1094.30000&#8217;   # 3501760 \/ 3200time:  &#8212; platform: homeassistant    id: esptime    timezone: Europe\/Amsterdam    on_time:      &#8212; seconds: 0        minutes: 0        hours: 0        then:          &#8212; lambda: |-              id(flash_day) = 0;              id(flash_night) = 0;              id(flash_counter_day_sensor).publish_state(0);              id(flash_counter_night_sensor).publish_state(0);sensor:  &#8212; platform: adc    pin: A0    name: &#171;TEMT6000 raw&#187;    id: light_raw    update_interval: 10ms  &#8212; platform: template    name: &#171;\u041e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u043b\u044e\u043a\u0441\u0430\u0445&#187;    id: light_lux    unit_of_measurement: &#171;lx&#187;    accuracy_decimals: 1    lambda: |-      return id(light_raw).state * 1000.0f;    update_interval: 10ms  &#8212; platform: template    name: &#171;\u0418\u043c\u043f\u0443\u043b\u044c\u0441\u044b \u0434\u0435\u043d\u044c&#187;    id: flash_counter_day_sensor    unit_of_measurement: &#171;imp&#187;    accuracy_decimals: 0    lambda: |-      return (float) id(flash_day);  &#8212; platform: template    name: &#171;\u0418\u043c\u043f\u0443\u043b\u044c\u0441\u044b \u043d\u043e\u0447\u044c1&#187;    id: flash_counter_night_sensor    unit_of_measurement: &#171;imp&#187;    accuracy_decimals: 0    lambda: |-      return (float) id(flash_night);  &#8212; platform: template    name: &#171;\u042d\u043d\u0435\u0440\u0433\u0438\u044f \u0434\u0435\u043d\u044c&#187;    id: energy_day_sensor    unit_of_measurement: &#171;kWh&#187;    device_class: energy    state_class: total_increasing    accuracy_decimals: 5    lambda: |-      return id(energy_day_total);  &#8212; platform: template    name: &#171;\u042d\u043d\u0435\u0440\u0433\u0438\u044f \u043d\u043e\u0447\u044c1&#187;    id: energy_night_sensor    unit_of_measurement: &#171;kWh&#187;    device_class: energy    state_class: total_increasing    accuracy_decimals: 5    lambda: |-      return id(energy_night_total);  &#8212; platform: template    name: &#171;\u042d\u043d\u0435\u0440\u0433\u0438\u044f \u0432\u0441\u0435\u0433\u043e1 &#187;    id: energy_sensor    unit_of_measurement: &#171;kWh&#187;    device_class: energy    state_class: total_increasing    accuracy_decimals: 5    lambda: |-      return id(energy_day_total) + id(energy_night_total);number:  &#8212; platform: template    name: &#171;\u041f\u0440\u0430\u0432\u043a\u0430 \u044d\u043d\u0435\u0440\u0433\u0438\u044f \u0434\u0435\u043d\u044c&#187;    id: edit_energy_day    min_value: 0    max_value: 100000    step: 0.00001    mode: box    optimistic: false    lambda: |-      return id(energy_day_total);    set_action:      &#8212; lambda: |-          id(energy_day_total) = x;          id(energy_day_sensor).publish_state(id(energy_day_total));          id(energy_sensor).publish_state(id(energy_day_total) + id(energy_night_total));  &#8212; platform: template    name: &#171;\u041f\u0440\u0430\u0432\u043a\u0430 \u044d\u043d\u0435\u0440\u0433\u0438\u044f \u043d\u043e\u0447\u044c1&#8243;    id: edit_energy_night    min_value: 0    max_value: 100000    step: 0.00001    mode: box    optimistic: false    lambda: |-      return id(energy_night_total);    set_action:      &#8212; lambda: |-          id(energy_night_total) = x;          id(energy_night_sensor).publish_state(id(energy_night_total));          id(energy_sensor).publish_state(id(energy_day_total) + id(energy_night_total));interval:  &#8212; interval: 10ms    then:      &#8212; lambda: |-          static float last_lux = 0.0f;          static uint32_t last_flash_time = 0;          float current_lux = id(light_lux).state;          uint32_t now_ms = millis();          if ((current_lux &#8212; last_lux) &gt; 150.0f &amp;&amp; (now_ms &#8212; last_flash_time &gt; 150)) {            last_flash_time = now_ms;            auto now_time = id(esptime).now();            bool is_day = true;            if (now_time.is_valid()) {              is_day = (now_time.hour &gt;= 7 &amp;&amp; now_time.hour &lt; 23);            }            if (is_day) {              id(flash_day)++;              id(energy_day_total) += 1.0f \/ 3200.0f;              id(flash_counter_day_sensor).publish_state(id(flash_day));              id(energy_day_sensor).publish_state(id(energy_day_total));            } else {              id(flash_night)++;              id(energy_night_total) += 1.0f \/ 3200.0f;              id(flash_counter_night_sensor).publish_state(id(flash_night));              id(energy_night_sensor).publish_state(id(energy_night_total));            }            id(energy_sensor).publish_state(id(energy_day_total) + id(energy_night_total));          }          last_lux = current_lux;BASH \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u044d\u043b. \u044d\u043d\u0435\u0440\u0433\u0438\u0438#!\/usr\/bin\/env bashset -euo pipefail################################################### &#8212; \u041d\u0410\u0421\u0422\u0420\u041e\u0419\u041a\u0418 &#8212;##################################################RKS_EMAIL=&#187;\u041b\u043e\u0433\u0438\u043d&#187;RKS_PASSWORD=&#187;\u041f\u0430\u0440\u043e\u043b\u044c&#187;ACCOUNT_ID=&#187;\u0430\u0439\u0434\u0438 \u0430\u043a\u043a\u0430\u0443\u0442\u0430&#187;DEVICE_ID=&#187;\u0430\u0439\u0434\u0438 \u043f\u0440\u0438\u0431\u043e\u0440\u0430 \u0443\u0447\u0435\u0442\u0430&#187;HA_URL=&#187;http:\/\/127.0.0.1:8123&#8243;HA_TOKEN=&#187;&#187;  # \u0442\u043e\u043a\u0435\u043d HATG_BOT=&#187;\u0442\u043e\u043a\u0435\u043d \u0431\u043e\u0442\u0430 \u0422\u0413&#187;TG_CHATS=(&#171;\u0430\u0439\u0434\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439&#187; &#171;\u0430\u0439\u0434\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439&#187;)TARIFF_DAY=&#187;ab89b37f-94e4-11ea-960f-00155d016301&#8243;TARIFF_NIGHT=&#187;ab89b380-94e4-11ea-960f-00155d016301&#8243;################################################### &#8212; \u0424\u0423\u041d\u041a\u0426\u0418\u0418 &#8212;##################################################send_telegram() {  local TEXT=&#187;$1&#8243;  for CHAT in &#171;${TG_CHATS[@]}&#187;; do    curl -s -X POST &#171;https:\/\/api.telegram.org\/bot${TG_BOT}\/sendMessage&#187; \\      -d chat_id=&#187;$CHAT&#187; \\      -d text=&#187;$TEXT&#187; &gt;\/dev\/null  done}fail() {  send_telegram &#171;\u274c \u041e\u0448\u0438\u0431\u043a\u0430 \u0420\u041a\u0421:\\n$1&#187;  exit 1}################################################### &#8212; 1. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d &#8212;##################################################TOKEN=$(curl -k -s -X POST &#171;https:\/\/lk.rks-energo.ru\/api\/signin&#187; \\  -H &#171;Content-Type: application\/json&#187; \\  -H &#171;Accept: application\/json&#187; \\  -H &#171;User-Agent: Mozilla\/5.0&#187; \\  -H &#171;Origin: https:\/\/lk.rks-energo.ru&#187; \\  -H &#171;Referer: https:\/\/lk.rks-energo.ru\/&#187; \\  -d &#171;{\\&#187;email\\&#187;:\\&#187;$RKS_EMAIL\\&#187;,\\&#187;password\\&#187;:\\&#187;$RKS_PASSWORD\\&#187;}&#187; \\  | jq -r &#8216;.token&#8217;)[[ -z &#171;$TOKEN&#187; || &#171;$TOKEN&#187; == &#171;null&#187; ]] &amp;&amp; fail &#171;\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u043a\u0435\u043d&#187;################################################### &#8212; 2. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0431\u0430\u043b\u0430\u043d\u0441 &#8212;##################################################RESPONSE=$(curl -k -s -X GET &#171;https:\/\/lk.rks-energo.ru\/api\/personalAccount&#187; \\  -H &#171;Authorization: Bearer $TOKEN&#187; \\  -H &#171;Accept: application\/json&#187;)TOTAL=$(echo &#171;$RESPONSE&#187; | jq -r &#8216;.data[0].balance&#8217;)VALUE_DAY=$(echo &#171;$RESPONSE&#187; | jq -r &#8216;.data[0].balance_details[&#171;1&#187;].Value \/\/ 0&#8217; | tr &#8216;,&#8217; &#8216;.&#8217;)VALUE_NIGHT=$(echo &#171;$RESPONSE&#187; | jq -r &#8216;.data[0].balance_details[&#171;2&#187;].Value \/\/ 0&#8217; | tr &#8216;,&#8217; &#8216;.&#8217;)################################################### &#8212; 3. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443 &#8212;##################################################AMOUNT=$(printf &#171;%.2f&#187; &#171;$TOTAL&#187;)ORDER_RESPONSE=$(curl -k -s -X GET \\  &#171;https:\/\/lk.rks-energo.ru\/api\/acquiring\/registerOrder?personal_account_id=$ACCOUNT_ID&amp;amount=$AMOUNT&#187; \\  -H &#171;Authorization: Bearer $TOKEN&#187; \\  -H &#171;Accept: application\/json&#187;)PAY_URL=$(echo &#171;$ORDER_RESPONSE&#187; | jq -r &#8216;.data.link \/\/ empty&#8217;)################################################### &#8212; 4. \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u0435\u043d\u0441\u043e\u0440\u044b HA &#8212;##################################################ha_post() {  local ENTITY=&#187;$1&#8243;  local STATE=&#187;$2&#8243;  local NAME=&#187;$3&#8243;  curl -s -X POST &#171;$HA_URL\/api\/states\/$ENTITY&#187; \\    -H &#171;Authorization: Bearer $HA_TOKEN&#187; \\    -H &#171;Content-Type: application\/json&#187; \\    -d &#171;{\\&#187;state\\&#187;:\\&#187;$STATE\\&#187;,\\&#187;attributes\\&#187;:{\\&#187;unit_of_measurement\\&#187;:\\&#187;\u20bd\\&#187;,\\&#187;friendly_name\\&#187;:\\&#187;$NAME\\&#187;}}&#187; &gt;\/dev\/null}ha_post &#171;sensor.rks_penia&#187; &#171;$VALUE_NIGHT&#187; &#171;\u0420\u041a\u0421 \u0411\u0430\u043b\u0430\u043d\u0441 \u041f\u0435\u043d\u044f&#187;ha_post &#171;sensor.rks_current&#187; &#171;$VALUE_DAY&#187; &#171;\u0420\u041a\u0421 \u0411\u0430\u043b\u0430\u043d\u0441 \u0422\u0435\u043a\u0443\u0449\u0438\u0439&#187;ha_post &#171;sensor.rks_total&#187; &#171;$TOTAL&#187; &#171;\u0420\u041a\u0421 \u0411\u0430\u043b\u0430\u043d\u0441 \u041e\u0431\u0449\u0438\u0439&#187;if [ -n &#171;$PAY_URL&#187; ]; then  ha_post &#171;sensor.rks_payment_url&#187; &#171;$PAY_URL&#187; &#171;\u0420\u041a\u0421 \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443&#187;fi################################################### &#8212; 5&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-481728","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=481728"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481728\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}