{"id":299491,"date":"2020-03-01T03:00:10","date_gmt":"2020-03-01T03:00:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299491"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299491","title":{"rendered":"\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Google Assistant"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/490484\/\">\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0432 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Google Assistant \u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 mqtt \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043b\u0430\u0442\u044b ESP8266 \u0438 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430. \u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Assistant \u0441 \u0431\u043b\u044d\u043a\u0434\u0436\u0435\u043a\u043e\u043c \u0438 php \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438. \u0412\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 ESP8266, \u043b\u0438\u0431\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043a \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0443 \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 c \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c ssl \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u043c (\u0432\u043c\u0435\u0441\u0442\u043e \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e ssl \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 proxy \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f) \u0438 MQTT \u0441\u0435\u0440\u0432\u0435\u0440 (broker). <br \/>  \u0414\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 google assistant \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 Google Actions \u0438 Dialogflow. \u0418\u0442\u0430\u043a \u043d\u0430\u0447\u043d\u0435\u043c.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7n\/n4\/so\/7nn4sojacyuqznn0ngm2_az_tek.jpeg\" alt=\"image\"><\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>  <\/p>\n<h3>Google Action Console<\/h3>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 <a href=\"https:\/\/console.actions.google.com\/\" rel=\"nofollow\">\u0441\u0435\u0440\u0432\u0438\u0441\u0435<\/a> \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u044f\u0437\u044b\u043a \u0438 \u0440\u0435\u0433\u0438\u043e\u043d. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/3c\/8d\/8p\/3c8d8pr_uuzir7e6jizg3cx-xf4.png\" alt=\"image\"><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0441\u0444\u0435\u0440\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u042f \u0432\u044b\u0431\u0440\u0430\u043b Kids&amp;Family. \u0418\u0437 \u0447\u0443\u0436\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0449\u0430\u044f\u0441\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f Smart Home \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u043e\u0442 Google, \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044e.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qr\/jk\/-x\/qrjk-xl3cvbhcrpdocrfhyfiecm.png\" alt=\"image\"><\/p>\n<p>  \u0427\u0438\u0442\u0430\u0435\u043c \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f. \u0412 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 Quick setup \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u0443\u043d\u043a\u0442\u0443 Decide how your Action is invoked. \u041f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u043a \u0431\u0443\u0434\u0443\u0442 \u0437\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u0431\u043e\u0442\u0430 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0433\u043e\u043b\u043e\u0441 \u0438\u0437 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/w1\/oz\/ue\/w1ozueqhhrzh0y42i1xwfwk8330.png\" alt=\"image\"><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0432\u043a\u043b\u0430\u0434\u043a\u0443 Actions, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 Custom Intent<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/nt\/sg\/n4\/ntsgn4ps4curjg5c0ociivilfma.png\" alt=\"image\"><\/p>\n<h3>Dialogflow<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 Build \u043d\u0430\u0441 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441 Dialogflow, \u0442\u043e\u0436\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<br \/>  1.\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u044f\u0437\u044b\u043a \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441.<br \/>  2.\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0432\u043a\u043b\u0430\u0434\u043a\u0443 Fulfillment \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0443\u043d\u043a\u0442 <abbr title=\"\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438\">Webhook<\/abbr>. \u0417\u0434\u0435\u0441\u044c \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 (\u043e \u0442\u043e\u043c \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u0441\u043a\u0440\u0438\u043f\u0442, \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0434\u0430\u043b\u0435\u0435) \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 Dialogflow \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f POST \u0437\u0430\u043f\u0440\u043e\u0441.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/2e\/tu\/ij\/2etuijbmkox37tup8de8t8sq694.png\" alt=\"image\"><br \/>  3. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432<br \/>  \u0412\u043a\u043b\u0430\u0434\u043a\u0430 intets \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043d\u0430 \u043d\u0438\u0445. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u044c \u043d\u0430 + \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 Intents. \u041f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0438\u043c\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u043d\u0430\u0436\u0430\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ay\/d4\/zy\/ayd4zyszkzl59pzklkt8ps34sh4.png\" alt=\"image\"><br \/>  \u0421\u0430\u043c\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u0442\u0440\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438:<br \/>  <b>Training phrases<\/b> \u2014 \u044d\u0442\u043e \u0441\u043b\u043e\u0432\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 assistant \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439. \u041e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043b\u043e\u0432\u0430 \u043f\u043e\u0441\u0432\u0435\u0442\u0438, \u0432\u0440\u0443\u0431\u0438 \u0441\u0432\u0435\u0442, \u0432\u043a\u043b\u044e\u0447\u0438 \u043b\u0430\u043c\u043f\u0443 \u0438 \u0442. \u043f.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/du\/v8\/mm\/duv8mm1gpmvibh2w6fd0u7x777w.png\" alt=\"image\"><br \/>  <b>Action<\/b> \u2014 \u0441\u0430\u043c\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0438\u043b\u0438 \u0441\u043b\u043e\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u0430\u0442\u0447\u0438\u043a, \u043e\u043d\u043e \u043e\u0434\u043d\u043e \u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435.<br \/>  <b>Responses<\/b> \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0442\u044b assistant \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u0430. <br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yx\/vj\/hp\/yxvjhpwsqueymkbo-4llo9jfvh8.png\" alt=\"image\"><\/p>\n<h2> \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0430 <\/h2>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u043b \u0441\u0430\u043c\u044b\u0439 \u0434\u0435\u0448\u0435\u0432\u044b\u0439 (5$) \u0434\u0440\u043e\u043f\u043b\u0435\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u043d\u0430 \u043d\u0435\u0433\u043e Debian 10.2. \u041a\u0430\u043a\u043e\u0439 \u0432\u044b \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0432\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442. <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e proxy \u0438 DNS<\/h2>\n<p>  \u042d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0441 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u043c.<br \/>  \u0421\u0430\u043c \u0441\u0435\u0440\u0432\u0438\u0441 Cloudflare \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d \u043d\u0438\u0436\u043d\u0438\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0435\u0442\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0443\u043d\u043a\u0442\u0430 4, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0432 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 content \u0432\u043e\u0437\u043b\u0435 www***, https\/\/www*** \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0432\u043e\u0439 ip \u0432\u043c\u0435\u0441\u0442\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e (*** \u044d\u0442\u043e \u0432\u0430\u0448 \u0434\u043e\u043c\u0435\u043d).<\/p>\n<p>  \u0414\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 Dialogflow \u043d\u0443\u0436\u0435\u043d SSL \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442. \u042f \u043d\u0435 \u0441\u0442\u0430\u043b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b DNS proxy Cloudflare (\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u2014 basic). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 Cloudflare \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0441\u0432\u043e\u0435 \u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u043d\u043e\u0435 \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043a \u043d\u0435\u043c\u0443 ip \u0430\u0434\u0440\u0435\u0441 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (\u043a\u043e\u043b\u043e\u043d\u043a\u0430 Content). \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0434\u0432\u0435 A \u0437\u0430\u043f\u0438\u0441\u0438 (\u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u044d\u0442\u043e Value) \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438\u043c\u0435\u043d. \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u044d\u0442\u043e \u043d\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u043d\u043e\u0435 \u0434\u0435\u043b\u043e \u0438 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c \u0434\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0434\u043d\u0435\u0439.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yp\/gz\/qz\/ypgzqzczh7qgdveopje4to1dtp8.png\" alt=\"image\"><\/p>\n<h2>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c<\/h2>\n<p>  1.\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432  <\/p>\n<pre><code class=\"bash\">apt update<\/code><\/pre>\n<p>, \u0430 \u043f\u043e\u0442\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b <\/p>\n<pre><code class=\"bash\">apt upgrade<\/code><\/pre>\n<p>  2. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c LAMP<br \/>  Apache <\/p>\n<pre><code class=\"bash\">apt install apache2 <\/code><\/pre>\n<p>  PHP\/Mysql  <\/p>\n<pre><code class=\"bash\">apt-get install php libapache2-mod-php php-mcrypt php-mysql<\/code><\/pre>\n<p>.\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 apache2.conf. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 nano \/etc\/apache2\/apache2.conf \u0443\u043a\u0430\u0437\u0430\u0432 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0444\u0430\u0439\u043b\u0430 ServerName *** \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0433\u0434\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u0435\u043a \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c ip \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u043b\u0443\u0436\u0431\u0443 Apach \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/linux-apache-mysql-php-lamp-ubuntu-16-04-ru\" rel=\"nofollow\">\u0442\u0443\u0442<\/a>. <br \/>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438 \u0432\u0432\u043e\u0434\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f Apache2.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/wu\/3k\/uw\/wu3kuwqec_ykskpcqtqttzph6wm.png\" alt=\"image\"><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438\u0441\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0440\u0438 \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u043e\u043c http \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043b\u0443\u0448\u0430\u0435\u0442 80, \u0430 \u043d\u0435 443 \u043f\u043e\u0440\u0442. \u0418\u043b\u0438 \u043d\u0430 \u043d\u0435\u043c \u0443\u0436\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 \u043a\u0430\u043a\u0430\u044f \u0442\u043e \u0441\u043b\u0443\u0436\u0431\u0430. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"https:\/\/losst.ru\/pochemu-apache-ne-zapuskaetsya\" rel=\"nofollow\">\u0442\u0443\u0442<\/a>.<br \/>  4.\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Mosquitto \u0434\u043b\u044f PHP<br \/>  \u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0432\u0435\u0449\u0435\u0439 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u041e\u0434\u0438\u043d \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 MQTT (https:\/\/habr.com\/ru\/post\/463669\/), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044c-\u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0442 \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043d\u0443\u0436\u0435\u043d \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c (broker). \u043d\u0430 \u0412\u043e\u0442 \u0435\u0433\u043e \u043c\u044b \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c.<br \/>  5.\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d PECL, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e <\/p>\n<pre><code class=\"bash\">apt install pecl<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0431\u0440\u043e\u043a\u0435\u0440 <\/p>\n<pre><code class=\"bash\">pecl install Mosquitto-alpha<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 extension = mosquitto.so \u043a \u0432\u0430\u0448\u0435\u043c\u0443 php.ini. \u0418 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043a\u043b\u0438\u0435\u043d\u0442 <\/p>\n<pre><code class=\"bash\">apt install mosquitto mosquitto-clients <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"https:\/\/readthedocs.org\/projects\/mosquitto-php\/downloads\/pdf\/latest\/\" rel=\"nofollow\">\u0442\u0443\u0442<\/a>  <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 php \u0441\u043a\u0440\u0438\u043f\u0442\u0430, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u043d\u0430 topic<\/h2>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u0441\u043a\u0440\u0438\u043f\u0442. \u0415\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c post \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442 Dialogflow, \u0432\u044b\u0447\u043b\u0435\u043d\u044f\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e action \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u0431\u0440\u043e\u043a\u0435\u0440 \u0432 \u0442\u0435\u043c\u0443, \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u0430. \u041a\u0430\u043a \u0432\u044b \u043d\u0430\u0437\u043e\u0432\u0435\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442. \u041a\u0441\u0442\u0430\u0442\u0438 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432 \u0432\u043a\u043b\u0430\u0434\u043a\u0435 Fulfillment. \u041f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u0435 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \/var\/www\/html<\/p>\n<p>  \u0422\u043e\u043f\u0438\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430\u043c\u0438.\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u043e\u043f\u0438\u043a \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:  <\/p>\n<pre><code class=\"bash\">mosquitto_sub -h localhost - t \/test\/light<\/code><\/pre>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e localhost \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0430\u0434\u0440\u0435\u0441, \u0438\u043b\u0438 \u0434\u043e\u043c\u0435\u043d, \u0433\u0434\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f (pub)<br \/>  \u0412\u043c\u0435\u0441\u0442\u043e \/test\/light \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0442\u0435\u043c\u0443. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0435. <\/p>\n<p>  \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f\u043c\u0438. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439.   <\/p>\n<pre><code class=\"bash\">mosquitto_pub -h localhost - t \/test\/light -m \u201clight\u201d<\/code><\/pre>\n<p>  \u041d\u043e \u043e\u043d\u0430 \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0430\u0448\u0438\u043c \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u043c (pub) \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0421\u0445\u0435\u043c\u0430 \u0442\u0430\u043a\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443, \u043e\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043d\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442. \u0421\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u0431\u0440\u043e\u043a\u0435\u0440\u0430, \u0430 \u0431\u0440\u043e\u043a\u0435\u0440 \u043d\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430 (esp8266).<br \/>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0432\u043a\u043b\u0430\u0434\u043a\u0443 Test Action Console. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lj\/j0\/ff\/ljj0ffysayc5d3wfg8ui2rcc15w.png\" alt=\"image\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/j5\/tf\/xz\/j5tfxzjm9gbh7toxf9wi6zah2zw.png\" alt=\"image\"><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043f\u0442 php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php   \/\/Make sure that it is a POST request. if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){     throw new Exception('Request method must be POST!'); }  \/\/Make sure that the content type of the POST request has been set to application\/json $contentType = isset($_SERVER[&quot;CONTENT_TYPE&quot;]) ? trim($_SERVER[&quot;CONTENT_TYPE&quot;])                                                                                                              : ''; if(strcasecmp($contentType, 'application\/json') != 0){     throw new Exception('Content type must be: application\/json'); }  \/\/Receive the RAW post data. $content = trim(file_get_contents(&quot;php:\/\/input&quot;));  \/\/Attempt to decode the incoming RAW post data from JSON. $decoded = json_decode($content);  \/\/file_put_contents($filename, $data); var_dump($decoded);  echo $decoded-&gt;queryResult-&gt;action;    define('BROKER', 'localhost'); define('PORT', 1883); define('CLIENT_ID',  getmypid());  \u0438\u0442\u0438  $client = new Mosquitto\\Client(CLIENT_ID); $client-&gt;connect(BROKER, PORT, 60);          $message = $decoded-&gt;queryResult-&gt;action;         $client-&gt;publish('\/test\/light', $message, 0, false);         $client-&gt;loop();      ?&gt; <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u041f\u0440\u043e\u0448\u0438\u0432\u043a\u0430 ESP8266<\/h2>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Arduino IDE. \u0415\u0441\u043b\u0438 \u043a\u0442\u043e \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c IDE \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043f\u0440\u043e \u0434\u0440\u0430\u0439\u0432\u0435\u0440 ch340. \u041f\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u0443 \u0432 arduino \u0454\u0442\u043e\u0439 \u043f\u043b\u0430\u0442\u0456 \u043d\u0435\u0442. \u0412 \u0424\u0430\u0439\u043b&gt;&gt;\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0456\u0445 \u043f\u043b\u0430\u0442: arduino.esp8266.com\/stable\/package_esp8266com_index.json. \u0412 \u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b&gt;&gt;\u043f\u043b\u0430\u0442\u0430&gt;&gt;\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u043b\u0430\u0442 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442 esp8266.<br \/>  \u0412 \u0441\u043a\u0435\u0442\u0447\u0435 \u043f\u043e\u0441\u043b\u0435 const char* ssid \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0439 wi-fi \u0441\u0435\u0442\u0438. \u041f\u043e\u0441\u043b\u0435 const char* password \u0435\u0435 \u043f\u0430\u0440\u043e\u043b\u044c. \u041f\u043e\u0441\u043b\u0435 const char* mqtt_server \u0443\u043a\u0430\u0437\u0430\u0442\u044c ip \u0430\u0434\u0440\u0435\u0441 \u0441\u0432\u043e\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0435\u0442\u0447 Arduino IDE<\/b><\/p>\n<div class=\"spoiler_text\"><code>#include &lt;ESP8266WiFi.h&gt;<br \/>  #include &lt;PubSubClient.h&gt;<\/p>\n<p>  \/\/ Update these with values suitable for your network.<\/p>\n<p>  const char* ssid = &quot;***&quot;;<br \/>  const char* password = &quot;********&quot;;<br \/>  const char* mqtt_server = &quot;**.**.*.*&quot;;<\/p>\n<p>  WiFiClient espClient;<br \/>  PubSubClient client(espClient);<br \/>  long lastMsg = 0;<br \/>  char msg[50];<br \/>  int value = 0;<\/p>\n<p>  int led = D5;<\/p>\n<p>  void setup_wifi() {<\/p>\n<p>  delay(10);<br \/>   \/\/ We start by connecting to a WiFi network<br \/>   Serial.println();<br \/>   Serial.print(&quot;Connecting to &quot;);<br \/>   Serial.println(ssid);<\/p>\n<p>  WiFi.begin(ssid, password);<\/p>\n<p>  while (WiFi.status() != WL_CONNECTED) {<br \/>   delay(500);<br \/>   Serial.print(&quot;.&quot;);<br \/>   }<\/p>\n<p>  randomSeed(micros());<\/p>\n<p>  Serial.println(&quot;&quot;);<br \/>   Serial.println(&quot;WiFi connected&quot;);<br \/>   Serial.println(&quot;IP address: &quot;);<br \/>   Serial.println(WiFi.localIP());<br \/>  }<\/p>\n<p>  void callback(char* topic, byte* payload, unsigned int length) {<br \/>   String msg=&quot;&quot;;<br \/>   Serial.print(&quot;Message arrived [&quot;);<br \/>   Serial.print(topic);<br \/>   Serial.print(&quot;] &quot;);<br \/>   for (int i = 0; i &lt; length; i++) {<br \/>   Serial.print((char)payload[i]);<br \/>   msg+=(char)payload[i];<br \/>   }<br \/>   Serial.println();<\/p>\n<p>  \/\/ Switch on the LED if an 1 was received as first character<br \/>  \/\/ if ((char)payload[0] == '1') {<br \/>   if (msg == &quot;light&quot;) {<br \/>   digitalWrite(led, HIGH); \/\/ Turn the LED on <br \/>   } else {<br \/>   digitalWrite(led, LOW); \/\/ Turn the LED off <br \/>   }<\/p>\n<p>  }<\/p>\n<p>  void reconnect() {<br \/>   \/\/ Loop until we're reconnected<br \/>   while (!client.connected()) {<br \/>   Serial.print(&quot;Attempting MQTT connection...&quot;);<br \/>   \/\/ Create a random client ID<br \/>   String clientId = &quot;ESP8266Client-&quot;;<br \/>   clientId += String(random(0xffff), HEX);<br \/>   \/\/ Attempt to connect<br \/>   if (client.connect(clientId.c_str())) {<br \/>   Serial.println(&quot;connected&quot;);<br \/>   \/\/ ... and resubscribe<br \/>   client.subscribe(&quot;\/test\/light&quot;);<br \/>   } else {<br \/>   Serial.print(&quot;failed, rc=&quot;);<br \/>   Serial.print(client.state());<br \/>   Serial.println(&quot; try again in 5 seconds&quot;);<br \/>   \/\/ Wait 5 seconds before retrying<br \/>   delay(5000);<br \/>   }<br \/>   }<br \/>  }<\/p>\n<p>  void setup() {<br \/>   pinMode(led, OUTPUT); \/\/ Initialize the led pin as an output<br \/>   Serial.begin(115200);<br \/>   setup_wifi();<br \/>   client.setServer(mqtt_server, 1883);<br \/>   client.setCallback(callback);<br \/>  }<\/p>\n<p>  void loop() {<\/p>\n<p>  if (!client.connected()) {<br \/>   reconnect();<br \/>   }<br \/>   client.loop();<\/p>\n<p>  }<br \/>  <\/code>  <\/div>\n<\/div>\n<h2> \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h2>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441\u043a\u0435\u0442\u0447\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 google \u0430\u0441\u0438\u0441\u0442\u0435\u043d\u0442 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0430\u0442\u0447\u0438\u043a\u0430\u043c\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430 Android \u2014 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439. \u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0435 \u0441 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u0430 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c \u0441\u043a\u0430\u0437\u0430\u0442\u044c: \u201c\u0413\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c ***\u201d<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qf\/vh\/ug\/qfvhugumopat-isohcimmyujd08.jpeg\" alt=\"image\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/eh\/or\/mv\/ehormvyz41fgzhgogas1yrszpvs.jpeg\" alt=\"image\"><\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/g-S82CdMIrY?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\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\/post\/490484\/\"> https:\/\/habr.com\/ru\/post\/490484\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/490484\/\">\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0432 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Google Assistant \u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 mqtt \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0443\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043c\u0430, \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043b\u0430\u0442\u044b ESP8266 \u0438 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430. \u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Assistant \u0441 \u0431\u043b\u044d\u043a\u0434\u0436\u0435\u043a\u043e\u043c \u0438 php \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438. \u0412\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.  <\/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-299491","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299491","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=299491"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299491\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}