{"id":358785,"date":"2024-05-21T00:19:08","date_gmt":"2024-05-21T00:19:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=358785"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=358785","title":{"rendered":"<span>\u0420\u0430\u0441\u0441\u0442\u0430\u0435\u043c\u0441\u044f \u0441 \u043e\u0431\u043b\u0430\u043a\u0430\u043c\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 Sonoff<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/vw\/tz\/yh\/vwtzyhijxaerhgrtjf8iq2nm_94.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/vw\/tz\/yh\/vwtzyhijxaerhgrtjf8iq2nm_94.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c!<\/p>\n<p>  \u0412 \u0441\u0432\u043e\u0435\u043c \u00ab\u0443\u043c\u043d\u043e\u043c \u0434\u043e\u043c\u0435\u00bb \u044f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u044b \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0447\u0442\u043e\u0431\u044b \u0431\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u043e\u043d \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u0442\u044b\u043a\u0432\u0443.<\/p>\n<p>  \u041d\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0451 \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043e \u043a \u043e\u0431\u043b\u0430\u043a\u0443. \u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043e\u0442\u0432\u044f\u0437\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 Sonoff \u043e\u0442 \u043e\u0431\u043b\u0430\u043a\u043e\u0432.<\/p>\n<p>  \u0414\u0430, \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0438 \u0443\u0436\u0435 \u0432\u0441\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b\u0438, \u043a\u0430\u043a \u043f\u0440\u043e\u0448\u0438\u0442\u044c Sonoff. \u041d\u043e \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0432\u044f\u0437\u0430\u0442\u044c \u043e\u0442 \u043e\u0431\u043b\u0430\u043a\u0430 Sonoff DW2, \u043d\u0435 \u043f\u0440\u043e\u0448\u0438\u0432\u0430\u044f \u0435\u0433\u043e. \u041f\u0440\u043e\u0448\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0432\u0435\u0434\u044c \u0442\u0430\u043c \u043d\u0435 ESP8266, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0430.<\/p>\n<p>  \u0427\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0442 \u043e\u0431\u043b\u0430\u043a\u043e\u0432:  <\/p>\n<ul>\n<li>Sonoff Basic, Sonoff 4CH \u2014 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0430\u044f\u043b\u044c\u043d\u0438\u043a \u0438 USB-TTL \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c;<\/li>\n<li>Sonoff DW2 \u2014 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440.<\/li>\n<\/ul>\n<p>  \u0412 \u043f\u043e\u0441\u0442\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <b>ESPHome<\/b> + <b>Home Assistant<\/b> + <b>Docker<\/b> + <b>PHP<\/b>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 \u041f\u041e, \u0442\u0443\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e.<\/p>\n<h3>Sonoff Basic R2<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/fs\/7g\/jk\/fs7gjk_xkvbzjra54saamrnnpzc.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/fs\/7g\/jk\/fs7gjk_xkvbzjra54saamrnnpzc.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0438\u0433\u0440\u0443\u0448\u043a\u0430 \u0434\u043b\u044f \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0441\u0432\u0435\u0442\u0438\u043b\u044c\u043d\u0438\u043a\u043e\u043c \u0438 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044f\u0442\u044c \u0432\u0441\u044e \u043f\u0440\u043e\u0432\u043e\u0434\u043a\u0443<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433 \u043d\u0443\u0436\u043d\u043e\u0439 \u043d\u0430\u043c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 (\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/devices.esphome.io\/devices\/Sonoff-BASIC-R2-v1.4\" rel=\"nofollow noopener noreferrer\">\u0442\u0443\u0442<\/a>):  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u043d\u0444\u0438\u0433 ESPHome<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">Copy # Basic Config esphome:   name: sonoff_basic_r2   platform: ESP8266   board: esp8285  wifi:   ssid: !secret wifi_ssid   password: !secret wifi_password  logger: api: ota:  # Device Specific Config binary_sensor:   - platform: gpio     id: push_button     pin:       number: GPIO0       mode: INPUT_PULLUP       inverted: True     internal: true     on_press:       # Prevents unintended LED lit states.       if:         condition:           - switch.is_off: relay         then:           - switch.turn_on: blue_led           - switch.turn_on: relay         else:           - switch.turn_off: relay  switch:   # The relay switches on the red side of the LED when active.   - platform: gpio     name: \"Sonoff Basic Relay\"     pin: GPIO12     id: relay     on_turn_off:       if:         condition:           - switch.is_on: blue_led         then:           - switch.turn_off: blue_led   # With this we can control the blue side of the LED.   - platform: gpio     id: blue_led     pin:       number: GPIO13       inverted: True<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0436\u0435\u043b\u0435\u0437\u0443.<\/p>\n<p>  \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0440\u0438\u043f\u0430\u0438\u0432\u0430\u0435\u043c \u0433\u0440\u0435\u0431\u0435\u043d\u043a\u0443 \u0441 \u0448\u0430\u0433\u043e\u043c 2.54 \u043d\u0430 \u043f\u043b\u0430\u0442\u0443 \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f USB-TTL \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 CH340G, \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u044f \u043f\u0438\u043d\u044b:  <\/p>\n<ul>\n<li>GND \u2014 GND<\/li>\n<li>TX \u2014 TX (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e RX, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f)<\/li>\n<li>RX \u2014 RX (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e TX, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f)<\/li>\n<li>3.3V \u2014 3.3V<\/li>\n<\/ul>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c Sonoff \u043a \u041f\u041a \u0437\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 \u043d\u0430 \u043f\u043b\u0430\u0442\u0435, \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438. \u0411\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0435, \u0447\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 TX \u0438 RX \u043f\u0438\u043d\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u0430\u0448 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u0442\u043e\u0440 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/yj\/1x\/w6\/yj1xw6wttn9-sw4secsj2vgabj0.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/yj\/1x\/w6\/yj1xw6wttn9-sw4secsj2vgabj0.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u0421\u0430\u043c\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u043e \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0435, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u0430\u043c \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430, \u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u0432\u043f\u0435\u0440\u0432\u044b\u0435, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 <a href=\"https:\/\/esphome.io\/devices\/sonoff_basic.html\" rel=\"nofollow noopener noreferrer\">\u0441\u0430\u0439\u0442\u043e\u043c esphome.io<\/a><\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0448\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 R2 \u043e\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e ESPHome Sonoff R2.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0430\u0446\u0438\u0435\u043d\u0442\u0443.<\/p>\n<h3>Sonoff 4CH (Pro)<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/lq\/o7\/p8\/lqo7p84p6ul_mjukemicu8ravdc.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/lq\/o7\/p8\/lqo7p84p6ul_mjukemicu8ravdc.jpeg\" data-blurred=\"true\"\/><br \/>  <i>\u0426\u0438\u0444\u0440\u0430 5 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u044f\u0442\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432 \u043c\u043e\u0435\u043c \u0434\u043e\u043c\u0435.<\/i><\/p>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0430\u0432\u043a\u0430 PRO \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b 433 \u041c\u0413\u0446 \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0442\u0435\u043b\u0438, \u043d\u043e \u0441\u0430\u043c\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0430\u044f \u0437\u0430 433 \u041c\u0413\u0446 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u0440\u0430\u0441\u043f\u0430\u044f\u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0438 \u0435\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u043e\u043d\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435.<\/p>\n<p>  \u041f\u043e \u043c\u043e\u0438\u043c \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u044f\u043c 433 \u041c\u0413\u0446 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0441\u0442\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u0430\u0436\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0434\u043e \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438, \u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043b\u0430\u0446\u0435\u0431\u043e.<\/p>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u0435\u0442\u043e\u043c \u0432 \u043a\u043e\u043c\u043d\u0430\u0442\u0430\u0445. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e 3 \u0442\u0430\u043a\u0438\u0445 \u043d\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u0432\u0435\u0442\u043e\u043c \u0432\u043e \u0432\u0441\u0435\u043c \u0434\u043e\u043c\u0435 \u0438 1 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0441\u043e\u0441\u0430\u043c\u0438 \u043a\u043e\u0442\u043b\u0430 \u043e\u0442\u043e\u043f\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d Basic R2, \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043a\u043e\u043d\u0444\u0438\u0433 (\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/devices.esphome.io\/devices\/Sonoff-4CH-Pro-R2\" rel=\"nofollow noopener noreferrer\">\u0442\u0443\u0442<\/a>):  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u043d\u0444\u0438\u0433 ESPHome<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">Copy # Basic Config esphome:   name: sonoff_4chpror2   platform: ESP8266   board: esp01_1m  wifi:   ssid: !secret wifi_ssid   password: !secret wifi_password  logger: api: ota:  # Device Specific Config binary_sensor:   - platform: gpio     pin:       number: GPIO0       mode: INPUT_PULLUP       inverted: True     on_press:       - switch.toggle: \"relay_1\"   - platform: gpio     pin:       number: GPIO9       mode: INPUT_PULLUP       inverted: True     on_press:       - switch.toggle: \"relay_2\"   - platform: gpio     pin:       number: GPIO10       mode: INPUT_PULLUP       inverted: True     on_press:       - switch.toggle: \"relay_3\"   - platform: gpio     pin:       number: GPIO14       mode: INPUT_PULLUP       inverted: True     on_press:       - switch.toggle: \"relay_4\"    - platform: gpio     pin:       number: GPIO0       mode: INPUT_PULLUP       inverted: True     name: \"Sonoff 4CH Pro Button 1\"   - platform: gpio     pin:       number: GPIO9       mode: INPUT_PULLUP       inverted: True     name: \"Sonoff 4CH Pro Button 2\"   - platform: gpio     pin:       number: GPIO10       mode: INPUT_PULLUP       inverted: True     name: \"Sonoff 4CH Pro Button 3\"   - platform: gpio     pin:       number: GPIO14       mode: INPUT_PULLUP       inverted: True     name: \"Sonoff 4CH Pro Button 4\"    - platform: status     name: \"Sonoff 4CH Pro Status\"  switch:   - platform: gpio     name: \"Relay 1\"     pin: GPIO12     id: \"relay_1\"   - platform: gpio     name: \"Relay 2\"     pin: GPIO5     id: \"relay_2\"   - platform: gpio     name: \"Relay 3\"     pin: GPIO4     id: \"relay_3\"   - platform: gpio     name: \"Relay 4\"     pin: GPIO15     id: \"relay_4\"<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0417\u0430\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0443 \u0438 \u0440\u0430\u0434\u0443\u0435\u043c\u0441\u044f \u043e\u0442\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u043c\u0443 ESPHome Sonoff 4CH (Pro) <s>Max Super Digital<\/s>.<\/p>\n<p>  \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043f\u0430\u0446\u0438\u0435\u043d\u0442\u0430.<\/p>\n<h3>Sonoff DW2<\/h3>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/zq\/ut\/2a\/zqut2ajpummbcwodgyuyoroudfy.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/zq\/ut\/2a\/zqut2ajpummbcwodgyuyoroudfy.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u042d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u044b\u043b \u0434\u043e\u0441\u0442\u0443\u043f \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u0434\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0435\u0433\u043e \u0434\u043d\u044f, \u0443 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u00ab\u0443\u043c\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u00bb \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b, \u043a\u0430\u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u043c \u0434\u0432\u0435\u0440\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441\u0430\u043c\u043e\u043c\u0443.<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0440\u0430\u0431\u043e\u0442\u044b: DW2 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u043a \u0432\u0430\u0448\u0435\u0439 Wi-Fi \u0441\u0435\u0442\u0438 \u0438 \u0436\u0434\u0435\u0442 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u043e\u0442 \u00ab\u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f\u00bb \u0438\u043b\u0438 \u00ab\u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f\u00bb \u0434\u0432\u0435\u0440\u0438, \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 eu-api.coolkit.cc, \u0430 \u0443\u0436\u0435 \u0441 \u043d\u0435\u0433\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<p>  \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0434\u0430\u0442\u0447\u0438\u043a\u0430, \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u044f \u0438 \u043f\u043e\u043b\u0435\u0437 \u0432 Wireshark. \u041f\u043e\u0434\u043c\u0435\u043d\u0438\u0432 DNS \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043b\u044f \u0434\u043e\u043c\u0435\u043d\u0430 eu-api.coolkit.cc \u043d\u0430 \u0441\u0432\u043e\u0439 IP, \u044f \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 8080 \u043f\u043e\u0440\u0442, \u0443\u0440\u0430, \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 HTTP \u2014 \u0437\u043d\u0430\u0447\u0438\u0442, \u044d\u0442\u043e \u043f\u043e\u0431\u0435\u0434\u0430! <s>\u041d\u0435\u0442, \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 HTTPS<\/s><\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 nginx \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u043b\u043e\u0433\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041b\u043e\u0433\u0438 nginx<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">192.168.65.1 - - [29\/Oct\/2023:16:36:50 +0000] \"\\x16\\x03\\x01\\x02\\x00\\x01\\x00\\x01\\xFC\\x03\\x03i\\xB5\\x19G\\xB1\\xB2X}\\xA3L\\xCF\\x99\\x11\\x84 \\x00\\xCE\\x88\\xB2S\\xBC\\xFC$\\x86bp\\xDA\\xFA*\\xEFl\\xC8 \\xB5\\x12t\\xDC\\x13\\x80W\\x8E\\xB1\\xD5*\\x00\\x9E\\xAF\\xABzz\\xEFpx\\x92\\xFCmY0\\x03\\xB6a\\xE9\\xF1\\xC5\\xC5\\x00*\" 400 157 \"-\" \"-\" \"-\"  192.168.65.1 - - [29\/Oct\/2023:16:36:53 +0000] \"\\x16\\x03\\x01\\x02\\x00\\x01\\x00\\x01\\xFC\\x03\\x03\\x0B;'hR\\x90\\xAAY\\x06Z\\x82c6\\xEC\\x02p1\\xF0\\xEFF\\xF5\\xF3j\\x99\\x08r\\xC1\\xA2\\x0E\\xB6n\\xD4 \\xE5\\x90\\x1E\\xA7N\\xDC\\xF3\\xCA\\xEA\\x8C\\x8Af5\\xC4k\\x95\\x80W\\x8A{\\x90\\x83\\xCB\\xBDxR\\xB5\\xF7\\xFC\\xFF&lt;\\x85\\x00,\\x8A\\x8A\\x13\\x01\\x13\\x02\\x13\\x03\\xC0,\\xC0+\\xCC\\xA9\\xC00\\xC0\/\\xCC\\xA8\\xC0\" 400 157 \"-\" \"-\" \"-\"  192.168.65.1 - - [29\/Oct\/2023:16:36:53 +0000] \"\\x16\\x03\\x01\\x00\\x97\\x01\\x00\\x00\\x93\\x03\\x01y|q\\x17\\x1B\\xDD\\xDB\\xC3\\xD79\\x22\\x1C\\xA6nf\\x0B]\\xAC)^5\\xFA5p\\xF0\\x8DS\\x93\\xF3\\xED\\x8AJ\\x00\\x00\\x14\\xC0\" 400 157 \"-\" \"-\" \"-\"<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043d\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e.<\/p>\n<p>  \u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u043e HTTPS, \u0432\u0435\u0434\u044c \u043f\u0435\u0440\u0432\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u0443 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435? <\/p>\n<p>  \u0414\u0430, \u044d\u0442\u043e HTTPS, \u043d\u043e \u043d\u0430 8080 \u043f\u043e\u0440\u0442\u0443, \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043d\u043e \u043b\u0430\u0434\u043d\u043e.<\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044f \u0440\u0430\u0441\u0441\u0442\u0440\u043e\u0438\u043b\u0441\u044f, \u043e\u0436\u0438\u0434\u0430\u044f SSL Pinning \u0438\u043b\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043d\u043e \u043d\u0435\u0442, \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435\u0442 \u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 Sonoff DW2 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442.<\/p>\n<p>  \u0411\u0435\u0440\u0435\u043c \u043b\u044e\u0431\u043e\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u043f\u043e\u0434\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 nginx \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c php-fpm \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>  \u0418 \u0432\u043e\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 POST \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041b\u043e\u0433 nginx<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">192.168.65.1 - - [29\/Oct\/2023:19:39:55 +0000] \"POST \/api\/user\/device\/update  HTTP\/1.1\" 200 5 \"-\" \"-\" \"-\" <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Array (     [deviceid] => **********     [d_seq] => 1546272314     [params] => Array         (             [switch] => off             [battery] => 2.202             [fwVersion] => 1000.2.925             [type] => 3             [chipID] => **********             [mac] => **********             [rssi] => -83         )  )<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u0430. \u041f\u0438\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442-\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 DNS \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440. \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Adguard Home, \u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u043f\u0443\u043d\u043a\u0442 \u00ab\u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c DNS-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\u00bb, \u0432 \u043d\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043e\u043c\u0435\u043d eu-api.coolkit.cc \u0441 \u0432\u0430\u0448\u0438\u043c IP. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0432 DHCP \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u043c DNS \u0441\u0432\u043e\u0439 Adguard Home.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 Home Assistant, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">configuration.yaml<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">sensor:   - platform: template     sensors:       entry_door_battery_voltage:         unique_id: 5bc4eb632179f65962327215e2acf9e18d5a83f1         device_class: voltage         unit_of_measurement: 'V'         value_template: ''       entry_door_rssi:         unique_id: 053082ee1f19d9ca6a58a0cdb9061ffd87de2fc4         device_class: signal_strength         unit_of_measurement: 'dBm'         value_template: ''  binary_sensor:   - platform: template     sensors:       entry_door:         unique_id: 130e755dcb5dfa0696f0835fb73f1307c00e6c76         device_class: door         value_template: ''<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u043b\u0433\u043e\u0441\u0440\u043e\u0447\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0432 HA, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0438\u0437\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \/profile<\/p>\n<p>  \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Docker.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f nginx<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">upstream php-sonoff-handler {     server php:9000; }   server {         listen 8080 ssl;         server_name  eu-api.coolkit.cc;          ssl_certificate \/etc\/nginx\/ssl\/servercert.pem;         ssl_certificate_key \/etc\/nginx\/ssl\/serverkey.pem;          ssl_dhparam \/etc\/nginx\/ssl\/dhparams.pem;          location \/ {             include fastcgi_params;             fastcgi_param SCRIPT_FILENAME \/usr\/share\/nginx\/html\/project\/sonoff.php;              fastcgi_pass php-sonoff-handler;              fastcgi_intercept_errors on;             fastcgi_request_buffering off;              fastcgi_max_temp_file_size 0;         } }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Docker Compose<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"plaintext\">version: '3'  services:   php:     container_name: php     image: \"php:8.2-fpm\"     volumes:       - .\/php:\/usr\/share\/nginx\/html\/project     restart: unless-stopped   nginx:     container_name: nginx     image: \"nginx:latest\"     volumes:       - .\/nginx:\/etc\/nginx:ro     restart: unless-stopped     ports:       - \"8080:8080\"<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 \/php\/sonoff.php.<\/p>\n<p>  \u0421\u043a\u0440\u0438\u043f\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u0432\u043e\u0439 ID.<\/p>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e ******* \u0443\u043a\u0430\u0436\u0438\u0442\u0435 deviceid \u0441\u0432\u043e\u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u0415\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 ewelink, \u043f\u0443\u043d\u043a\u0442 \u00abID \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u00bb.<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">PHP \u0441\u043a\u0440\u0438\u043f\u0442<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php const HA_API_URL = \"http:\/\/homeassistant:8123\/api\/states\/\"; const HA_TOKEN = '\u0412\u0410\u0428 \u0422\u041e\u041a\u0415\u041d';  $listDevices = [     '**********' => [         'id'     => 'entry_door',         'name'   => '\u0412\u0445\u043e\u0434\u043d\u0430\u044f \u0434\u0432\u0435\u0440\u044c',         'v_name' => '\u0412\u0445\u043e\u0434\u043d\u0430\u044f \u0434\u0432\u0435\u0440\u044c (\u041d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435)',         's_name' => '\u0412\u0445\u043e\u0434\u043d\u0430\u044f \u0434\u0432\u0435\u0440\u044c (\u0421\u0438\u0433\u043d\u0430\u043b)',     ], ];  $data = json_decode(file_get_contents('php:\/\/input'), true);  $currentDevice = $listDevices[$data['deviceid']];  sendData(sprintf('binary_sensor.%s', $currentDevice['id']), [     'state'      => $data['params']['switch'],     'attributes' => [         'friendly_name' => $currentDevice['name'],         'device_class'  => 'door',     ], ]);  sendData(sprintf('sensor.%s_battery_voltage', $currentDevice['id']), [     'state'      => $data['params']['battery'],     'attributes' => [         'friendly_name'       => $currentDevice['v_name'],         'state_class'         => 'measurement',         'unit_of_measurement' => 'V',         'device_class'        => 'voltage',     ], ]);  sendData(sprintf('sensor.%s_rssi', $currentDevice['id']), [     'state'      => $data['params']['rssi'],     'attributes' => [         'friendly_name'       => $currentDevice['s_name'],         'state_class'         => 'measurement',         'unit_of_measurement' => 'dBm',         'device_class'        => 'signal_strength',     ], ]);   function sendData($sensor, $postData) {     $url = HA_API_URL . $sensor;      \/\/ for sending data as json type     $fields = json_encode($postData);      $ch = curl_init($url);     curl_setopt(         $ch,         CURLOPT_HTTPHEADER,         [             'Content-Type: application\/json', \/\/ if the content type is json             'Authorization: Bearer ' . HA_TOKEN, \/\/ if you need token in header         ]     );     curl_setopt($ch, CURLOPT_HEADER, false);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);     curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);      $result = curl_exec($ch);     curl_close($ch); }<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c docker \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u0430\u0442\u0447\u0438\u043a \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 HA, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438\/\u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0438 \u0434\u0432\u0435\u0440\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u0434\u0430 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u2014 <a href=\"https:\/\/github.com\/GenkaOk\/sonoff-dw2-gateway\/\" rel=\"nofollow noopener noreferrer\">GitHub<\/a><\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/770624\/\"> https:\/\/habr.com\/ru\/articles\/770624\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/vw\/tz\/yh\/vwtzyhijxaerhgrtjf8iq2nm_94.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/vw\/tz\/yh\/vwtzyhijxaerhgrtjf8iq2nm_94.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c!<\/p>\n<p>  \u0412 \u0441\u0432\u043e\u0435\u043c \u00ab\u0443\u043c\u043d\u043e\u043c \u0434\u043e\u043c\u0435\u00bb \u044f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u0432\u0441\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u044b \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0447\u0442\u043e\u0431\u044b \u0431\u0435\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u043e\u043d \u043d\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u0442\u044b\u043a\u0432\u0443.<\/p>\n<p>  \u041d\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0451 \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043e \u043a \u043e\u0431\u043b\u0430\u043a\u0443. \u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043e\u0442\u0432\u044f\u0437\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 Sonoff \u043e\u0442 \u043e\u0431\u043b\u0430\u043a\u043e\u0432.<\/p>\n<p>  \u0414\u0430, \u044f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0438 \u0443\u0436\u0435 \u0432\u0441\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b\u0438, \u043a\u0430\u043a \u043f\u0440\u043e\u0448\u0438\u0442\u044c Sonoff. \u041d\u043e \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0432\u044f\u0437\u0430\u0442\u044c \u043e\u0442 \u043e\u0431\u043b\u0430\u043a\u0430 Sonoff DW2, \u043d\u0435 \u043f\u0440\u043e\u0448\u0438\u0432\u0430\u044f \u0435\u0433\u043e. \u041f\u0440\u043e\u0448\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u0432\u0435\u0434\u044c \u0442\u0430\u043c \u043d\u0435 ESP8266, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0430.<\/p>\n<p>  \u0427\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0442 \u043e\u0431\u043b\u0430\u043a\u043e\u0432:  <\/p>\n<ul>\n<li>Sonoff Basic, Sonoff 4CH \u2014 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0430\u044f\u043b\u044c\u043d\u0438\u043a \u0438 USB-TTL \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c;<\/li>\n<li>Sonoff DW2 \u2014 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440.<\/li>\n<\/ul>\n<p>  \u0412 \u043f\u043e\u0441\u0442\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <b>ESPHome<\/b> + <b>Home Assistant<\/b> + <b>Docker<\/b> + <b>PHP<\/b>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 \u041f\u041e, \u0442\u0443\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-358785","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358785","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=358785"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358785\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=358785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=358785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}