Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Русский
    3. ioBroker
    4. ioBroker драйвера
    5. Драйвер Mega-ESP

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Драйвер Mega-ESP

    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Haus last edited by

      Драйвер Mega-ESP для проекта http://ab-log.ru/forum/viewtopic.php?f=1&t=1130 переделал из драйвера MegaD-328.

      cd /opt/iobroker
      npm install https://github.com/ausHaus/ioBroker.megaesp/tarball/master/
      iobroker add megaesp
      
      

      На данный момент сделал только стандартные 9 портов.

      WS281x - пока что не делал, заказал жду

      I2C - пока что не делал

      MCP23017, PCA9685 - заказал жду

      Драйвер считывает настройки с ESP, вписывает настройки в ESP, меняет ip ESP(пароль sec не трогайте и не меняйте),прописывает инстанцию драйвера "0/".

      Всё остальное аналогично MegaD

      Соответствия портов:

      P0 - GPIO5

      P1 - GPIO4

      P2 - GPIO15 - не может быть DSen, либо входом с внешним резистором подтяжки,

      P3 - GPIO13

      P4 - GPIO12

      P5 - GPIO14

      P6 - GPIO16 - не может быть DSen ???

      P7 - GPIO0 - не может быть прямым выходом, (нельзя подключать прямую нагрузку),

      P8 - GPIO2 - не может быть прямым выходом, (нельзя подключать прямую нагрузку),

      P9 - ADC

      Пробуем, отписываемся о результатах.

      1 Reply Last reply Reply Quote 0
      • E
        electric last edited by

        @Haus:

        Драйвер Mega-ESP для проекта http://ab-log.ru/forum/viewtopic.php?f=1&t=1130 переделал из драйвера MegaD-328. `
        Молодец! Спасибо!

        Постараюсь попробовать…

        1 Reply Last reply Reply Quote 0
        • Alex1808
          Alex1808 last edited by

          @Haus:

          Драйвер Mega-ESP `

          Драйвер установился без проблем.

          Нажимаю на "Auto_Detekt", визуально ничего не происходит, только в логе видно что что-то читает

          В логе:

          ! ````
          megaesp-0 2016-08-17 09:12:52.343 info read config from port: http://192.168.2.60/sec/cfg/?cn=1
          megaesp-0 2016-08-17 09:12:52.341 error socket hang up
          megaesp-0 2016-08-17 09:12:50.334 info read config from port: http://192.168.2.60/sec/?pt=26
          megaesp-0 2016-08-17 09:12:50.332 error socket hang up
          megaesp-0 2016-08-17 09:12:48.326 info read config from port: http://192.168.2.60/sec/?pt=25
          megaesp-0 2016-08-17 09:12:48.324 error socket hang up
          megaesp-0 2016-08-17 09:12:46.317 info read config from port: http://192.168.2.60/sec/?pt=24
          megaesp-0 2016-08-17 09:12:46.316 error socket hang up
          megaesp-0 2016-08-17 09:12:44.308 info read config from port: http://192.168.2.60/sec/?pt=23
          megaesp-0 2016-08-17 09:12:44.307 error socket hang up
          megaesp-0 2016-08-17 09:12:42.299 info read config from port: http://192.168.2.60/sec/?pt=22
          megaesp-0 2016-08-17 09:12:42.298 error socket hang up
          megaesp-0 2016-08-17 09:12:40.282 info read config from port: http://192.168.2.60/sec/?pt=21
          megaesp-0 2016-08-17 09:12:40.281 error socket hang up
          megaesp-0 2016-08-17 09:12:38.269 info read config from port: http://192.168.2.60/sec/?pt=20
          megaesp-0 2016-08-17 09:12:38.268 error socket hang up
          megaesp-0 2016-08-17 09:12:36.251 info read config from port: http://192.168.2.60/sec/?pt=19
          megaesp-0 2016-08-17 09:12:36.244 error socket hang up
          megaesp-0 2016-08-17 09:12:34.231 info read config from port: http://192.168.2.60/sec/?pt=18
          megaesp-0 2016-08-17 09:12:34.230 error socket hang up
          megaesp-0 2016-08-17 09:12:32.221 info read config from port: http://192.168.2.60/sec/?pt=17
          megaesp-0 2016-08-17 09:12:32.219 error socket hang up
          megaesp-0 2016-08-17 09:12:30.204 info read config from port: http://192.168.2.60/sec/?pt=16
          megaesp-0 2016-08-17 09:12:30.203 error socket hang up
          megaesp-0 2016-08-17 09:12:28.165 info read config from port: http://192.168.2.60/sec/?pt=15
          megaesp-0 2016-08-17 09:12:28.164 error socket hang up
          megaesp-0 2016-08-17 09:12:26.147 info read config from port: http://192.168.2.60/sec/?pt=14
          megaesp-0 2016-08-17 09:12:26.146 error socket hang up
          megaesp-0 2016-08-17 09:12:24.134 info read config from port: http://192.168.2.60/sec/?pt=13
          megaesp-0 2016-08-17 09:12:24.134 error socket hang up
          megaesp-0 2016-08-17 09:12:22.113 info read config from port: http://192.168.2.60/sec/?pt=12
          megaesp-0 2016-08-17 09:12:22.110 error socket hang up
          megaesp-0 2016-08-17 09:12:20.096 info read config from port: http://192.168.2.60/sec/?pt=11
          megaesp-0 2016-08-17 09:12:20.095 error socket hang up
          megaesp-0 2016-08-17 09:12:18.082 info read config from port: http://192.168.2.60/sec/?pt=10
          megaesp-0 2016-08-17 09:12:18.071 info read config from port: http://192.168.2.60/sec/?pt=9
          megaesp-0 2016-08-17 09:12:18.061 info read config from port: http://192.168.2.60/sec/?pt=8
          megaesp-0 2016-08-17 09:12:18.052 info read config from port: http://192.168.2.60/sec/?pt=7
          megaesp-0 2016-08-17 09:12:18.042 info read config from port: http://192.168.2.60/sec/?pt=6
          megaesp-0 2016-08-17 09:12:18.032 info read config from port: http://192.168.2.60/sec/?pt=5
          megaesp-0 2016-08-17 09:12:18.021 info read config from port: http://192.168.2.60/sec/?pt=4
          megaesp-0 2016-08-17 09:12:18.012 info read config from port: http://192.168.2.60/sec/?pt=3
          megaesp-0 2016-08-17 09:12:18.003 info read config from port: http://192.168.2.60/sec/?pt=2
          megaesp-0 2016-08-17 09:12:17.993 info read config from port: http://192.168.2.60/sec/?pt=1
          megaesp-0 2016-08-17 09:12:17.979 info read config from port: http://192.168.2.60/sec/?pt=0
          megaesp-0 2016-08-17 09:10:51.219 info Device "192.168.2.60" is connected
          megaesp-0 2016-08-17 09:10:51.104 info http server listening on port 89
          megaesp-0 2016-08-17 09:10:51.072 info starting. Version 0.0.1 in /opt/iobroker/node_modules/iobroker.megaesp

          
          При добавлении портов не всё прописалось правильно, все прописались как вход. Но были и вход и выход и деактивированные. На аналоговом порту Р9 (у меня там висит датчик освещённости), в поле ****Typ**** не даёт ничего выбрать, это так и должно? Сам датчик работает и параметры в ioB отображает.
          1 Reply Last reply Reply Quote 0
          • H
            Haus last edited by

            @Alex1808:

            @Haus:

            Драйвер Mega-ESP `

            Драйвер установился без проблем.

            Нажимаю на "Auto_Detekt", визуально ничего не происходит, только в логе видно что что-то читает `
            Alex па пробуйте без MCP23017 и PCA9685 только сама ESP, какая ESP у вас и прошивка?
            @Alex1808:

            @Haus:

            Драйвер Mega-ESP При добавлении портов не всё прописалось правильно, все прописались как вход. Но были и вход и выход и деактивированные.

            При добавлении портов в ручную настройки надо выбирать в ручную
            @Alex1808:

            @Haus:

            Драйвер Mega-ESP На аналоговом порту Р9 (у меня там висит датчик освещённости), в поле ****Typ**** не даёт ничего выбрать, это так и должно? Сам датчик работает и параметры в ioB отображает.
            Порт P9 может быть только ADC

            P.S. Скинь скриншот с подключённым MCP23017 и какие настройки в порте P10…

            1 Reply Last reply Reply Quote 0
            • Alex1808
              Alex1808 last edited by

              @Haus:

              Alex па пробуйте без MCP23017 и PCA9685 только сама ESP, какая ESP у вас и прошивка? `

              Тест проводил на ESP8266 ESP-12E (Wemos D1), прошивка последняя (fw: 0.33b2).

              Без MCP23017 попробую сегодня вечером.

              > При добавлении портов в ручную настройки надо выбирать в ручную
              ясно. значит порты должны были добавится при сканировании в авто-режиме?

              > Порт P9 может быть только ADC
              Ну я так и понял, сам порт работает и шлёт данные.

              > P.S. Скинь скриншот с подключённым MCP23017 и какие настройки в порте P10…
              Здесь

              ! ![](</s><URL url=)<link_text text="http://image.prntscr.com/image/da081e63 ... 28f581.png">http://image.prntscr.com/image/da081e63795747c8bb9234aee628f581.png</link_text>" />
              !
              ![](</s><URL url=)<link_text text="http://image.prntscr.com/image/e5ef3864 ... 2d0afd.png">http://image.prntscr.com/image/e5ef3864335947febc2124e05e2d0afd.png</link_text>" />
              ! ![](</s><URL url=)<link_text text="http://image.prntscr.com/image/327bace1 ... 28a3ec.png">http://image.prntscr.com/image/327bace1ce1d4c208e1fb1d5ff28a3ec.png</link_text>" />~~~~ ~~~~~~Upd.

              Проверил без МСР23017, порты прописались автоматом

              ! ![](</s><URL url=)<link_text text="http://image.prntscr.com/image/68dbf234 ... f3a9f0.png">http://image.prntscr.com/image/68dbf23476014b96a667b42727f3a9f0.png</link_text>" />~~~~~~

              1 Reply Last reply Reply Quote 0
              • H
                Haus last edited by

                @Alex1808:

                @Haus:

                > P.S. Скинь скриншот с подключённым MCP23017 и какие настройки в порте P10…
                Здесь

                ! ![](</s><URL url=)<link_text text="http://image.prntscr.com/image/da081e63 ... 28f581.png">http://image.prntscr.com/image/da081e63795747c8bb9234aee628f581.png</link_text>" />
                !
                ![](</s><URL url=)<link_text text="http://image.prntscr.com/image/e5ef3864 ... 2d0afd.png">http://image.prntscr.com/image/e5ef3864335947febc2124e05e2d0afd.png</link_text>" />
                ! ![](</s><URL url=)<link_text text="http://image.prntscr.com/image/327bace1 ... 28a3ec.png">http://image.prntscr.com/image/327bace1ce1d4c208e1fb1d5ff28a3ec.png</link_text>" />~~~~ ~~~~~~Извини мне бы html 🙂

                В принципе МСР23017 не должен мешать.~~~~~~

                1 Reply Last reply Reply Quote 0
                • Alex1808
                  Alex1808 last edited by

                  @Haus:

                  Извини мне бы html 🙂

                  В принципе МСР23017 не должен мешать. `

                  так?

                  <title>MegaESP</title>[Back](/sec/)
                  -- Ports --
                  [P10 - IN](/sec/?mc=10)
                  [P11 - IN](/sec/?mc=11)
                  [P12 - IN](/sec/?mc=12)
                  [P13 - IN](/sec/?mc=13)
                  [P14 - IN](/sec/?mc=14)
                  [P15 - IN](/sec/?mc=15)
                  [P16 - IN](/sec/?mc=16)
                  [P17 - IN](/sec/?mc=17)
                  [P18 - OUT](/sec/?mc=18)
                  [P19 - OUT](/sec/?mc=19)
                  [P20 - OUT](/sec/?mc=20)
                  [P21 - OUT](/sec/?mc=21)
                  [P22 - OUT](/sec/?mc=22)
                  [P23 - OUT](/sec/?mc=23)
                  [P24 - OUT](/sec/?mc=24)
                  [P25 - OUT](/sec/?mc=25)
                  
                  
                  <title>MegaESP</title>[Back](/sec/?mc=1)
                  (pin A0)
                  P10/OFF
                  
                  <form action="/sec/">Type: <select name="in"><option value="0">OUT</option><option value="1" selected="">IN</option></select>
                  mod <select name="pm"><option value="0">P</option><option value="1">P&R</option><option value="2" selected="">R</option></select> | <select name="rm"><option value="0" selected="">Default</option><option value="1">Act</option></select>
                  Act: 
                  </form>
                  
                  
                  1 Reply Last reply Reply Quote 0
                  • H
                    Haus last edited by

                    @Alex1808:

                    @Haus:

                    Извини мне бы html 🙂

                    В принципе МСР23017 не должен мешать. `

                    так?

                    <title>MegaESP</title>[Back](/sec/)
                    -- Ports --
                    [P10 - IN](/sec/?mc=10)
                    [P11 - IN](/sec/?mc=11)
                    [P12 - IN](/sec/?mc=12)
                    [P13 - IN](/sec/?mc=13)
                    [P14 - IN](/sec/?mc=14)
                    [P15 - IN](/sec/?mc=15)
                    [P16 - IN](/sec/?mc=16)
                    [P17 - IN](/sec/?mc=17)
                    [P18 - OUT](/sec/?mc=18)
                    [P19 - OUT](/sec/?mc=19)
                    [P20 - OUT](/sec/?mc=20)
                    [P21 - OUT](/sec/?mc=21)
                    [P22 - OUT](/sec/?mc=22)
                    [P23 - OUT](/sec/?mc=23)
                    [P24 - OUT](/sec/?mc=24)
                    [P25 - OUT](/sec/?mc=25)
                    
                    
                    <title>MegaESP</title>[Back](/sec/?mc=1)
                    (pin A0)
                    P10/OFF
                    
                    <form action="/sec/">Type: <select name="in"><option value="0">OUT</option><option value="1" selected="">IN</option></select>
                    mod <select name="pm"><option value="0">P</option><option value="1">P&R</option><option value="2" selected="">R</option></select> | <select name="rm"><option value="0" selected="">Default</option><option value="1">Act</option></select>
                    Act: 
                    </form>
                    
                    ```` `  
                    

                    Да спасибо?

                    1 Reply Last reply Reply Quote 0
                    • H
                      Haus last edited by

                      @Alex1808:

                      @Haus:

                      Извини мне бы html 🙂

                      В принципе МСР23017 не должен мешать. `

                      так?

                      <title>MegaESP</title>[Back](/sec/)
                      -- Ports --
                      [P10 - IN](/sec/?mc=10)
                      [P11 - IN](/sec/?mc=11)
                      [P12 - IN](/sec/?mc=12)
                      [P13 - IN](/sec/?mc=13)
                      [P14 - IN](/sec/?mc=14)
                      [P15 - IN](/sec/?mc=15)
                      [P16 - IN](/sec/?mc=16)
                      [P17 - IN](/sec/?mc=17)
                      [P18 - OUT](/sec/?mc=18)
                      [P19 - OUT](/sec/?mc=19)
                      [P20 - OUT](/sec/?mc=20)
                      [P21 - OUT](/sec/?mc=21)
                      [P22 - OUT](/sec/?mc=22)
                      [P23 - OUT](/sec/?mc=23)
                      [P24 - OUT](/sec/?mc=24)
                      [P25 - OUT](/sec/?mc=25)
                      
                      
                      <title>MegaESP</title>[Back](/sec/?mc=1)
                      (pin A0)
                      P10/OFF
                      
                      <form action="/sec/">Type: <select name="in"><option value="0">OUT</option><option value="1" selected="">IN</option></select>
                      mod <select name="pm"><option value="0">P</option><option value="1">P&R</option><option value="2" selected="">R</option></select> | <select name="rm"><option value="0" selected="">Default</option><option value="1">Act</option></select>
                      Act: 
                      </form>
                      
                      ```` `  
                      

                      OUT html скинь.

                      1 Reply Last reply Reply Quote 0
                      • Alex1808
                        Alex1808 last edited by

                        @Haus:

                        OUT html скинь. `

                        <title>MegaESP</title>[Back](/sec/?mc=1)
                        (pin B0)
                        P18/OFF
                        [ON](/sec/?mc=18&cmd=18:1)
                        
                        <form action="/sec/">Type: <select name="in"><option value="0" selected="">OUT</option><option value="1">IN</option></select> | <select name="dm"><option value="0" selected="">OFF</option><option value="1">ON</option></select>
                        </form>
                        
                        
                        1 Reply Last reply Reply Quote 0
                        • M
                          MSapogov last edited by

                          Спасибо за драйвер.

                          Никак не пойму что я делаю не так…

                          Мучая RGB

                          В объектах значение у порта PWM - true.

                          Когда меняю значение, то оно практически мгновенно возвращается снова в true.

                          В конфиге драйвера РОЛЬ указывал и value и level и пусто, все равно или true или false вместо значений от 0 до 255.

                          P9 с ADC выдает всегда как и нужно цифры.

                          PS: С MQTT работало хорошо.

                          1 Reply Last reply Reply Quote 0
                          • H
                            Haus last edited by

                            @MSapogov:

                            Спасибо за драйвер.

                            Никак не пойму что я делаю не так…

                            Мучая RGB

                            В объектах значение у порта PWM - true.

                            Когда меняю значение, то оно практически мгновенно возвращается снова в true.

                            В конфиге драйвера РОЛЬ указывал и value и level и пусто, все равно или true или false вместо значений от 0 до 255.

                            P9 с ADC выдает всегда как и нужно цифры.

                            PS: С MQTT работало хорошо. `
                            Обновись на 0.0.2 но ещё пока не работает RGB сейчас как рас делаю, не выходит :x

                            cd /opt/iobroker
                            npm install https://github.com/ausHaus/ioBroker.megaesp/tarball/master/
                            iobroker upload megaesp
                            iobroker restart megaesp
                            
                            
                            1 Reply Last reply Reply Quote 0
                            • H
                              Haus last edited by

                              Bluefox помоги, ни как команду с 'http://espIP/sec/?pt=3&r=25&g=180&b=164' вывести не могу в main.js sendCommandToRGB, то всё одного цвета то Send command "pt=2&r=undefined&g=undefined&b=128" to 192.168.1.20 :x

                              main.js "function sendCommandToRGB"

                              function sendCommandToRGB(port, value) {
                                  //'http://espIP/sec/?pt=3&r=25&g=25&b=25'       //////////////////////////////
                                  var data = 'pt=' + port + (value || 0);                   //////////////////////////////
                              
                                  var parts = adapter.config.ip.split(':');
                              
                                  var options = {
                                      host: parts[0],
                                      port: parts[1] || 80,
                                      path: '/' + adapter.config.password + '/?' + data
                                  };
                                  adapter.log.debug('Send command "' + data + '" to ' + adapter.config.ip);
                                  // Set up the request
                                  http.get(options, function (res) {
                                      var xmldata = '';
                                      res.setEncoding('utf8');
                                      res.on('error', function (e) {
                                          adapter.log.warn(e.toString());
                                      });
                                      res.on('data', function (chunk) {
                                          xmldata += chunk;
                                      });
                                      res.on('end', function () {
                                          adapter.log.debug('Response "' + xmldata + '"');
                                      });
                                  }).on('error', function (e) {
                                      adapter.log.warn('Got error by post request ' + e.toString());
                                  });
                              }
                              
                              

                              main.js "sendCommandToRGB"

                              adapter.on('stateChange', function (id, state) {
                                  if (id && state && !state.ack) {
                                      if (!ports[id]) {
                                          adapter.log.error('Unknown port ID ' + id);
                                          return;
                                      ........
                                      ........
                                      if (parseFloat(state.val) == state.val) {
                                          // If number => set position
                                          state.val = parseFloat(state.val);
                                          if (state.val < 0) {
                                              adapter.log.warn(': invalid control value ' + state.val + '. Value must be positive');
                                              state.val = 0;
                                          }
                                          ........
                                          ........
                                          if (ports[id].common.type == 'string') {   ////////////////////////////////////////////////////
                              
                                          } else if (id.indexOf('_red') !== -1) {
                                              var red = (ports[id].native.red, state.val);
                                              adapter.log.debug('R: ' + red);
                              
                                          } else if (id.indexOf('_green') !== -1) {
                                              var green = (ports[id].native.green, state.val);
                                              adapter.log.debug('G: ' + green);
                              
                                          } else if (id.indexOf('_blue') !== -1) {
                                              var blue = (ports[id].native.blue, state.val);
                                              adapter.log.debug('B: ' + blue);
                              
                                              adapter.log.debug('RGB: ' + red + green + blue);
                                              state.val = ('&r=' + red + '&g=' + green + '&b=' + blue);
                                              sendCommandToRGB(ports[id].native.port, state.val);      //////////////////////////////////////////
                              
                                          } else {
                                              ports[id].native.offset = parseFloat(ports[id].native.offset || 0) || 0;
                                              ports[id].native.factor = parseFloat(ports[id].native.factor || 1) || 1;
                              
                                              state.val = (state.val - ports[id].native.offset) / ports[id].native.factor;
                                              state.val = Math.round(state.val);
                              
                                              sendCommand(ports[id].native.port, state.val);
                                          }
                                      }
                                  }
                              });
                              

                              log

                              megaesp.0	2016-08-23 02:27:58.730	debug	megaesp.0 Response "Back
                              P2
                              val. 0-255
                              megaesp.0	2016-08-23 02:27:58.730	debug	megaesp.0 Send command "pt=2&r=undefined&g=undefined&b=128" to 192.168.1.20
                              megaesp.0	2016-08-23 02:27:58.729	debug	megaesp.0 RGB: undefinedundefined128
                              megaesp.0	2016-08-23 02:27:58.729	debug	megaesp.0 B: 128
                              megaesp.0	2016-08-23 02:27:58.729	info	megaesp.0 try to control megaesp.0.p2_P2_blue with 128
                              megaesp.0	2016-08-23 02:27:58.729	debug	megaesp.0 G: 130
                              megaesp.0	2016-08-23 02:27:58.729	info	megaesp.0 try to control megaesp.0.p2_P2_green with 130
                              megaesp.0	2016-08-23 02:27:58.728	debug	inMem message megaesp.0.* megaesp.0.p2_P2_blue
                              megaesp.0	2016-08-23 02:27:58.728	debug	inMem message megaesp.0.* megaesp.0.p2_P2_green
                              megaesp.0	2016-08-23 02:27:58.686	debug	megaesp.0 R: 185
                              megaesp.0	2016-08-23 02:27:58.686	info	megaesp.0 try to control megaesp.0.p2_P2_red with 185
                              megaesp.0	2016-08-23 02:27:58.684	debug	inMem message megaesp.0.* megaesp.0.p2_P2_red
                              
                              1 Reply Last reply Reply Quote 0
                              • M
                                MSapogov last edited by

                                @Haus:

                                Обновись на 0.0.2 но ещё пока не работает RGB сейчас как рас делаю, не выходит :x

                                cd /opt/iobroker
                                npm install https://github.com/ausHaus/ioBroker.megaesp/tarball/master/
                                iobroker upload megaesp
                                iobroker restart megaesp
                                
                                ```` `  
                                

                                Да у меня и так 0.0.2 версия.

                                Я использую три выхода как PWM, а не WS2811… Или можно RGB подключить по другому?

                                Что заметил, если использую Philips HUE и RGB color, то цвета регулируются... А если farbtastic то нет. А значения если смотреть - то true!!!

                                Объекты цветов прописываю во вкладке R.G.B.

                                1 Reply Last reply Reply Quote 0
                                • Bluefox
                                  Bluefox last edited by

                                  @Haus:

                                  Bluefox помоги, ни как команду с 'http://espIP/sec/?pt=3&r=25&g=180&b=164' вывести не могу в main.js sendCommandToRGB, то всё одного цвета то Send command "pt=2&r=undefined&g=undefined&b=128" to 192.168.1.20 :x

                                  main.js "function sendCommandToRGB" `
                                  Мне было бы проще, если бы код был на гите.

                                  ! ```
                                  `var rgbs = {};
                                  ! ....
                                  ! function sendCommandToRGB(rgbId) {
                                  rgbs[rgbId].timer = null;
                                  var port = ports[rgbId + '_blue'].native.port;

                                  //'http://espIP/sec/?pt=3&r=25&g=25&b=25'
                                  var data = 'pt=' + port + '&r=' + (rgbs[rgbId].red || 0) + '&g=' + (rgbs[rgbId].green || 0) + '&b=' + (rgbs[rgbId].blue || 0);
                                  

                                  ! var parts = adapter.config.ip.split(':');
                                  ! var options = {
                                  host: parts[0],
                                  port: parts[1] || 80,
                                  path: '/' + adapter.config.password + '/?' + data
                                  };
                                  adapter.log.debug('Send command "' + data + '" to ' + adapter.config.ip);
                                  // Set up the request
                                  http.get(options, function (res) {
                                  var xmldata = '';
                                  res.setEncoding('utf8');
                                  res.on('error', function (e) {
                                  adapter.log.warn(e.toString());
                                  });
                                  res.on('data', function (chunk) {
                                  xmldata += chunk;
                                  });
                                  res.on('end', function () {
                                  adapter.log.debug('Response "' + xmldata + '"');
                                  });
                                  }).on('error', function (e) {
                                  adapter.log.warn('Got error by post request ' + e.toString());
                                  });
                                  }
                                  ! .....
                                  ! adapter.on('stateChange', function (id, state) {
                                  ....
                                  if (ports[id].common.type === 'string') { ////////////////////////////////////////////////////
                                  ! } else if (id.match(/_red|_blue|green^/)) {
                                  var pos = id.lastIndexOf('
                                  ');
                                  var rgbId = id.substring(0, pos);
                                  var color = id.substring(pos + 1);

                                  	rgbs[rgbId] = rgbs[rgbId] || {};
                                  	rgbs[rgbId][color] = state.val;
                                  	// stop timer if running
                                  	if (rgbs[rgbId].timer) clearTimeout(rgbs[rgbId].timer);
                                  	// if no more changes in 100 ms, send command to device
                                  	rgbs[rgbId].timer = setTimeout(sendCommandToRGB, 100, rgbId);	
                                  } else {
                                  	...
                                  }`[/color]
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Haus last edited by

                                    @Bluefox:

                                    @Haus:

                                    Bluefox помоги, ни как команду с 'http://espIP/sec/?pt=3&r=25&g=180&b=164' вывести не могу в main.js sendCommandToRGB, то всё одного цвета то Send command "pt=2&r=undefined&g=undefined&b=128" to 192.168.1.20 :x

                                    main.js "function sendCommandToRGB" `
                                    Мне было бы проще, если бы код был на гите.

                                    ! ```
                                    `var rgbs = {};
                                    ! ....
                                    ! function sendCommandToRGB(rgbId) {
                                    rgbs[rgbId].timer = null;
                                    var port = ports[rgbId + '_blue'].native.port;

                                    //'http://espIP/sec/?pt=3&r=25&g=25&b=25'
                                    var data = 'pt=' + port + '&r=' + (rgbs[rgbId].red || 0) + '&g=' + (rgbs[rgbId].green || 0) + '&b=' + (rgbs[rgbId].blue || 0);

                                    ! var parts = adapter.config.ip.split(':');
                                    ! var options = {
                                    host: parts[0],
                                    port: parts[1] || 80,
                                    path: '/' + adapter.config.password + '/?' + data
                                    };
                                    adapter.log.debug('Send command "' + data + '" to ' + adapter.config.ip);
                                    // Set up the request
                                    http.get(options, function (res) {
                                    var xmldata = '';
                                    res.setEncoding('utf8');
                                    res.on('error', function (e) {
                                    adapter.log.warn(e.toString());
                                    });
                                    res.on('data', function (chunk) {
                                    xmldata += chunk;
                                    });
                                    res.on('end', function () {
                                    adapter.log.debug('Response "' + xmldata + '"');
                                    });
                                    }).on('error', function (e) {
                                    adapter.log.warn('Got error by post request ' + e.toString());
                                    });
                                    }
                                    ! .....
                                    ! adapter.on('stateChange', function (id, state) {
                                    ....
                                    if (ports[id].common.type === 'string') { ////////////////////////////////////////////////////
                                    ! } else if (id.match(/_red|_blue|green^/)) {
                                    var pos = id.lastIndexOf('
                                    ');
                                    var rgbId = id.substring(0, pos);
                                    var color = id.substring(pos + 1);

                                      rgbs[rgbId] = rgbs[rgbId] || {};
                                      rgbs[rgbId][color] = state.val;
                                      // stop timer if running
                                      if (rgbs[rgbId].timer) clearTimeout(rgbs[rgbId].timer);
                                      // if no more changes in 100 ms, send command to device
                                      rgbs[rgbId].timer = setTimeout(sendCommandToRGB, 100, rgbId);	
                                    

                                    } else {
                                    ...
                                    }`
                                    Спасибо, сейчас буду про бывать 🙂

                                    ! Уже две недели там :roll: https://github.com/ausHaus/ioBroker.megaesp
                                    ! P.S. Всё вроде неплохо но один цвет отправляет на "cmd"
                                    ~~[code]~~megaesp-0 2016-08-23 17:52:39.516 debug Response for 192.168.1.20[all]: 155;255;80;temp:20.00/hum:79.60;temp:19.50;ON;RGB;NC;NC;33 megaesp-0 2016-08-23 17:52:39.420 debug getPortState http://192.168.1.20/sec/?cmd=all megaesp-0 2016-08-23 17:52:35.634 debug Response "Back P6 val. 0-255 megaesp-0 2016-08-23 17:52:35.615 debug Send command "pt=6&r=255&g=209&b=0" to 192.168.1.20 inMem 2016-08-23 17:52:35.591 debug message megaesp.0.* megaesp.0.p6_P6 val=null, ack=true, ts=1471963955585, q=0, from=system.adapter.megaesp.0, lc=1471961464774 megaesp-0 2016-08-23 17:52:35.568 debug Response "Done" megaesp-0 2016-08-23 17:52:35.547 debug Send command "cmd=6:43" to 192.168.1.20 megaesp-0 2016-08-23 17:52:35.546 info try to control megaesp.0.p6_P6_blue with 43 inMem 2016-08-23 17:52:35.541 debug message megaesp.0.* megaesp.0.p6_P6_blue val=43, ack=false, ts=1471963955507, q=0, from=system.adapter.socketio.0, lc=1471963954498 megaesp-0 2016-08-23 17:52:35.514 info try to control megaesp.0.p6_P6_green with 209 inMem 2016-08-23 17:52:35.511 debug message megaesp.0.* megaesp.0.p6_P6_green val=209, ack=false, ts=1471963955497, q=0, from=system.adapter.socketio.0, lc=1471963954490 megaesp-0 2016-08-23 17:52:35.486 info try to control megaesp.0.p6_P6_red with 255 inMem 2016-08-23 17:52:35.479 debug message megaesp.0.* megaesp.0.p6_P6_red val=255, ack=false, ts=1471963955466, q=0, from=system.adapter.socketio.0, lc=1471963952798[/code]
                                    ! P.S.2 Добавил "....|blue|^..."
                                    ~~[code]~~} else if (id.match(/_red|_green|_blue|_^/)) {[/code] работает нормально
                                    443_rgb.png [/color]
                                    ``` `

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      Haus last edited by

                                      @MSapogov:

                                      @Haus:

                                      Что заметил, если использую Philips HUE и RGB color, то цвета регулируются… А если farbtastic то нет. А значения если смотреть - то true!!!

                                      Объекты цветов прописываю во вкладке R.G.B.
                                      Подправил, пробуй 0.0.3

                                      cd /opt/iobroker
                                      npm install https://github.com/ausHaus/ioBroker.megaesp/tarball/master/
                                      iobroker upload megaesp
                                      iobroker restart megaesp
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • M
                                        MSapogov last edited by

                                        @Haus:

                                        @MSapogov:

                                        @Haus:

                                        Что заметил, если использую Philips HUE и RGB color, то цвета регулируются… А если farbtastic то нет. А значения если смотреть - то true!!!

                                        Объекты цветов прописываю во вкладке R.G.B.
                                        Подправил, пробуй 0.0.3

                                        cd /opt/iobroker
                                        npm install https://github.com/ausHaus/ioBroker.megaesp/tarball/master/
                                        iobroker upload megaesp
                                        iobroker restart megaesp
                                        ```` `  
                                        

                                        Спасибо!

                                        Теперь норм.

                                        PS: А у Вас P6 как сконфигурирован? Вопрос снят… понял что WS2811.

                                        А кто встречал в продаже и где WS2811 в DIP корпусе, чтобы отдельно к нему усилители подключить можно было.

                                        1 Reply Last reply Reply Quote 0
                                        • Bluefox
                                          Bluefox last edited by

                                          @Haus:

                                          @Bluefox:

                                          @Haus:

                                          Bluefox помоги, ни как команду с 'http://espIP/sec/?pt=3&r=25&g=180&b=164' вывести не могу в main.js sendCommandToRGB, то всё одного цвета то Send command "pt=2&r=undefined&g=undefined&b=128" to 192.168.1.20 :x

                                          main.js "function sendCommandToRGB" `
                                          Мне было бы проще, если бы код был на гите.

                                          ! ```
                                          `var rgbs = {};
                                          ! ....
                                          ! function sendCommandToRGB(rgbId) {
                                          rgbs[rgbId].timer = null;
                                          var port = ports[rgbId + '_blue'].native.port;

                                          //'http://espIP/sec/?pt=3&r=25&g=25&b=25'
                                          var data = 'pt=' + port + '&r=' + (rgbs[rgbId].red || 0) + '&g=' + (rgbs[rgbId].green || 0) + '&b=' + (rgbs[rgbId].blue || 0);
                                          

                                          ! var parts = adapter.config.ip.split(':');
                                          ! var options = {
                                          host: parts[0],
                                          port: parts[1] || 80,
                                          path: '/' + adapter.config.password + '/?' + data
                                          };
                                          adapter.log.debug('Send command "' + data + '" to ' + adapter.config.ip);
                                          // Set up the request
                                          http.get(options, function (res) {
                                          var xmldata = '';
                                          res.setEncoding('utf8');
                                          res.on('error', function (e) {
                                          adapter.log.warn(e.toString());
                                          });
                                          res.on('data', function (chunk) {
                                          xmldata += chunk;
                                          });
                                          res.on('end', function () {
                                          adapter.log.debug('Response "' + xmldata + '"');
                                          });
                                          }).on('error', function (e) {
                                          adapter.log.warn('Got error by post request ' + e.toString());
                                          });
                                          }
                                          ! .....
                                          ! adapter.on('stateChange', function (id, state) {
                                          ....
                                          if (ports[id].common.type === 'string') { ////////////////////////////////////////////////////
                                          ! } else if (id.match(/_red|_blue|green^/)) {
                                          var pos = id.lastIndexOf('
                                          ');
                                          var rgbId = id.substring(0, pos);
                                          var color = id.substring(pos + 1);

                                            rgbs[rgbId] = rgbs[rgbId] || {};
                                            rgbs[rgbId][color] = state.val;
                                            // stop timer if running
                                            if (rgbs[rgbId].timer) clearTimeout(rgbs[rgbId].timer);
                                            // if no more changes in 100 ms, send command to device
                                            rgbs[rgbId].timer = setTimeout(sendCommandToRGB, 100, rgbId);	
                                          } else {
                                            ...
                                          }`
                                          

                                          Спасибо, сейчас буду про бывать 🙂

                                          ! Уже две недели там :roll: https://github.com/ausHaus/ioBroker.megaesp
                                          ! P.S. Всё вроде неплохо но один цвет отправляет на "cmd"
                                          ~~[code]~~megaesp-0 2016-08-23 17:52:39.516 debug Response for 192.168.1.20[all]: 155;255;80;temp:20.00/hum:79.60;temp:19.50;ON;RGB;NC;NC;33 megaesp-0 2016-08-23 17:52:39.420 debug getPortState http://192.168.1.20/sec/?cmd=all megaesp-0 2016-08-23 17:52:35.634 debug Response "Back P6 val. 0-255 megaesp-0 2016-08-23 17:52:35.615 debug Send command "pt=6&r=255&g=209&b=0" to 192.168.1.20 inMem 2016-08-23 17:52:35.591 debug message megaesp.0.* megaesp.0.p6_P6 val=null, ack=true, ts=1471963955585, q=0, from=system.adapter.megaesp.0, lc=1471961464774 megaesp-0 2016-08-23 17:52:35.568 debug Response "Done" megaesp-0 2016-08-23 17:52:35.547 debug Send command "cmd=6:43" to 192.168.1.20 megaesp-0 2016-08-23 17:52:35.546 info try to control megaesp.0.p6_P6_blue with 43 inMem 2016-08-23 17:52:35.541 debug message megaesp.0.* megaesp.0.p6_P6_blue val=43, ack=false, ts=1471963955507, q=0, from=system.adapter.socketio.0, lc=1471963954498 megaesp-0 2016-08-23 17:52:35.514 info try to control megaesp.0.p6_P6_green with 209 inMem 2016-08-23 17:52:35.511 debug message megaesp.0.* megaesp.0.p6_P6_green val=209, ack=false, ts=1471963955497, q=0, from=system.adapter.socketio.0, lc=1471963954490 megaesp-0 2016-08-23 17:52:35.486 info try to control megaesp.0.p6_P6_red with 255 inMem 2016-08-23 17:52:35.479 debug message megaesp.0.* megaesp.0.p6_P6_red val=255, ack=false, ts=1471963955466, q=0, from=system.adapter.socketio.0, lc=1471963952798[/code]
                                          ! P.S.2 Добавил "....|blue|^..."
                                          ~~[code]~~} else if (id.match(/_red|_green|_blue|_^/)) {[/code] работает нормально
                                          filename="RGB.png" index="0">~~
                                          Там ошибка была в regexp. Я тебе pull request отправил.[/color]
                                          ```

                                          1 Reply Last reply Reply Quote 0
                                          • H
                                            Haus last edited by

                                            @Bluefox:

                                            @Haus:

                                            @Bluefox: Там ошибка была в regexp. Я тебе pull request отправил. `
                                            Спасибо, всё работает

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            634
                                            Online

                                            31.7k
                                            Users

                                            79.8k
                                            Topics

                                            1.3m
                                            Posts

                                            7
                                            37
                                            9098
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo