Skip to content
  • Home
  • Aktuell
  • Tags
  • 0 Ungelesen 0
  • Kategorien
  • Unreplied
  • Beliebt
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Tester
  4. Shelly >= 6.6.0 mit BLU-Geräten (Bluetooth Low Energy)

NEWS

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    11
    1
    475

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    24
    1
    1.6k

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    9.5k

Shelly >= 6.6.0 mit BLU-Geräten (Bluetooth Low Energy)

Geplant Angeheftet Gesperrt Verschoben Tester
157 Beiträge 36 Kommentatoren 35.5k Aufrufe 34 Watching
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • HumidorH Humidor

    @jey-cee das Script läuft auf einem 1 PM, der Übermittelt mir Daten, das Gateway ist deaktiviert.
    allerdings sehe ich gerade, dass am 0-10V Dimmer das Gateway aktiviert ist, wo die 3 neuen BLE hängen und diese funktionieren.
    Script läuft natürlich.

    HumidorH Offline
    HumidorH Offline
    Humidor
    schrieb am zuletzt editiert von
    #90

    @humidor die 2 ersten BL‘s kommen nicht mehr rein, die neuen 3 fkt einwandfrei?

    BG

    1 Antwort Letzte Antwort
    0
    • A Offline
      A Offline
      Apfelwurm
      schrieb am zuletzt editiert von
      #91

      Ich hab mal das Script angepasst.
      MAC Adresse in Namen übersetzen und die Zeile ersetzt damit ein BLU H&T die Werte richtig überträgt. Vielleicht hilft es ja dem ein oder anderen.

      // v0.2 custom 
      let SCRIPT_VERSION = '0.2';
      let BTHOME_SVC_ID_STR = 'fcd2';
      
      let uint8 = 0;
      let int8 = 1;
      let uint16 = 2;
      let int16 = 3;
      let uint24 = 4;
      let int24 = 5;
      
      let BTH = {};
      let SHELLY_ID = undefined;
      
      const BTH = {
          0x00: { n: 'pid', t: uint8 },
          0x01: { n: 'battery', t: uint8, u: '%' },
          0x02: { n: 'temperature', t: int16, f: 0.01, u: 'tC' },
          0x45: { n: 'temperature', t: int16, f: 0.1, u: 'tC' },
          0x03: { n: 'humidity', t: uint16, f: 0.01, u: '%' },
          0x2e: { n: 'humidity', t: uint8, u: '%' },
          0x05: { n: 'illuminance', t: uint24, f: 0.01 },
          0x1a: { n: 'door', t: uint8 },
          0x20: { n: 'moisture', t: uint8 },
          0x21: { n: 'motion', t: uint8 },
          0x2d: { n: 'window', t: uint8 },
          0x3a: { n: 'button', t: uint8 },
          0x3f: { n: 'rotation', t: int16, f: 0.1 }
      };
      
      // Mapping of MAC addresses to individual names
      let macToName = {
          'aa:bb:cc:dd:ee:ff': 'Device1',
          '11:22:33:44:55:66': 'Device2'
      };
      
      function getByteSize(type) {
          if (type === uint8 || type === int8) return 1;
          if (type === uint16 || type === int16) return 2;
          if (type === uint24 || type === int24) return 3;
          // impossible as advertisements are much smaller
          return 255;
      }
      
      let BTHomeDecoder = {
          utoi: function (num, bitsz) {
              let mask = 1 << (bitsz - 1);
              return num & mask ? num - (1 << bitsz) : num;
          },
          getUInt8: function (buffer) {
              return buffer.at(0);
          },
          getInt8: function (buffer) {
              return this.utoi(this.getUInt8(buffer), 8);
          },
          getUInt16LE: function (buffer) {
              return 0xffff & ((buffer.at(1) << 8) | buffer.at(0));
          },
          getInt16LE: function (buffer) {
              return this.utoi(this.getUInt16LE(buffer), 16);
          },
          getUInt24LE: function (buffer) {
              return (
                  0x00ffffff & ((buffer.at(2) << 16) | (buffer.at(1) << 8) | buffer.at(0))
              );
          },
          getInt24LE: function (buffer) {
              return this.utoi(this.getUInt24LE(buffer), 24);
          },
          getBufValue: function (type, buffer) {
              if (buffer.length < getByteSize(type)) return null;
              let res = null;
              if (type === uint8) res = this.getUInt8(buffer);
              if (type === int8) res = this.getInt8(buffer);
              if (type === uint16) res = this.getUInt16LE(buffer);
              if (type === int16) res = this.getInt16LE(buffer);
              if (type === uint24) res = this.getUInt24LE(buffer);
              if (type === int24) res = this.getInt24LE(buffer);
              return res;
          },
          unpack: function (buffer) {
              // beacons might not provide BTH service data
              if (typeof buffer !== 'string' || buffer.length === 0) return null;
              let result = {};
              let _dib = buffer.at(0);
              result['encryption'] = _dib & 0x1 ? true : false;
              result['BTHome_version'] = _dib >> 5;
              if (result['BTHome_version'] !== 2) return null;
              // can not handle encrypted data
              if (result['encryption']) return result;
              buffer = buffer.slice(1);
      
              let _bth;
              let _value;
              while (buffer.length > 0) {
                  _bth = BTH[buffer.at(0)];
                  if (typeof _bth === 'undefined') {
                      console.log('Error: unknown type ' + buffer.at(0));
                      break;
                  }
                  buffer = buffer.slice(1);
                  _value = this.getBufValue(_bth.t, buffer);
                  if (_value === null) break;
                  if (typeof _bth.f !== 'undefined') _value = _value * _bth.f;
                  result[_bth.n] = _value;
                  buffer = buffer.slice(getByteSize(_bth.t));
              }
              return result;
          }
      };
      
      let lastPacketId = 0x100;
      
      // Callback for the BLE scanner object
      function bleScanCallback(event, result) {
          // exit if not a result of a scan
          if (event !== BLE.Scanner.SCAN_RESULT) {
              return;
          }
      
          // exit if service_data member is missing
          if (
              typeof result.service_data === 'undefined' ||
              typeof result.service_data[BTHOME_SVC_ID_STR] === 'undefined'
          ) {
              // console.log('Error: Missing service_data member');
              return;
          }
      
          let unpackedData = BTHomeDecoder.unpack(
              result.service_data[BTHOME_SVC_ID_STR]
          );
      
          // exit if unpacked data is null or the device is encrypted
          if (
              unpackedData === null ||
              typeof unpackedData === "undefined" ||
              unpackedData["encryption"]
          ) {
              console.log('Error: Encrypted devices are not supported');
              return;
          }
      
          // exit if the event is duplicated
          if (lastPacketId === unpackedData.pid) {
              return;
          }
      
          lastPacketId = unpackedData.pid;
      
          unpackedData.rssi = result.rssi;
          unpackedData.address = result.addr;
      
          // Convert MAC address to lowercase for case insensitive matching
          let macLower = result.addr.toLowerCase();
          let deviceName = macToName[macLower] || result.addr;
      
          // create MQTT-Payload
          let message = {
              scriptVersion: SCRIPT_VERSION,
              src: SHELLY_ID,
              srcBle: {
                  type: result.local_name,
                  mac: deviceName
              },
              payload: unpackedData
          };
      
          console.log('Received ' + JSON.stringify(unpackedData));
      
          if (MQTT.isConnected()) {
              MQTT.publish(SHELLY_ID + '/events/ble', JSON.stringify(message));
          }
      }
      
      // Initializes the script and performs the necessary checks and configurations
      function init() {
          // get the config of ble component
          let bleConfig = Shelly.getComponentConfig('ble');
      
          // exit if the BLE isn't enabled
          if (!bleConfig.enable) {
              console.log('Error: The Bluetooth is not enabled, please enable it in the settings');
              return;
          }
      
          // check if the scanner is already running
          if (BLE.Scanner.isRunning()) {
              console.log('Info: The BLE gateway is running, the BLE scan configuration is managed by the device');
          } else {
              // start the scanner
              let bleScanner = BLE.Scanner.Start({
                  duration_ms: BLE.Scanner.INFINITE_SCAN,
                  active: true
              });
      
              if (!bleScanner) {
                  console.log('Error: Can not start new scanner');
              }
          }
      
          BLE.Scanner.Subscribe(bleScanCallback);
      }
      
      Shelly.call('Mqtt.GetConfig', '', function (res, err_code, err_msg, ud) {
          SHELLY_ID = res['topic_prefix'];
      
          init();
      });
      
      HumidorH 1 Antwort Letzte Antwort
      1
      • K Offline
        K Offline
        kg36304
        schrieb am zuletzt editiert von kg36304
        #92

        Hallo, ich habe aktuell ein Problem.

        Ich habe den Shelly blu Motion soweit ins Syytem bekommen.
        Wenn ich den Raum betrete schalten die Lichter auch an und im Iobroker steht detection (1).
        Nach einiger Zeit steht Clear(0) und er springt nach der Blindzeit wieder auf Detection(1).
        Das macht er 5-6 mal und immer geht das Licht an und aus. Nach einiger Zeit. hört es auf und er bleibt auf clear(0).

        Woran liegt das???

        Was mache ich falsch???

        Hier das script dazu

        on({ id: [].concat(['shelly.1.ble.e8:e0:7e:bf:46:63.motion']), change: 'ne' }, async (obj) => {
          let value = obj.state.val;
          let oldValue = obj.oldState.val;
          if (getState('shelly.1.ble.e8:e0:7e:bf:46:63.motion').val == true && getState('shelly.1.ble.e8:e0:7e:bf:46:63.illuminance').val < 10) {
            // Licht Vorraum
            setState('shelly.1.shelly1minig3#84fce63a1670#1.Relay0.Switch' /* Schalter */, true);
            // Licht Stufe
            setState('shelly.0.SHDM-2#C8C9A33BF8AF#1.lights.Switch' /* Schalter */, true);
          } else if (getState('shelly.1.ble.e8:e0:7e:bf:46:63.motion').val == false) {
            // Licht Vorraum
            setStateDelayed('shelly.1.shelly1minig3#84fce63a1670#1.Relay0.Switch' /* Schalter */, false, 1800000, false);
            // Licht Tablet
            setStateDelayed('shelly.1.shelly1minig3#84fce638dec0#1.Relay0.Switch' /* Schalter */, false, 1800000, false);
            // Stufe
            setStateDelayed('shelly.0.SHDM-2#C8C9A33BF8AF#1.lights.Switch' /* Schalter */, false, 1800000, false);
          }
        });
        on({ id: [].concat(['shelly.1.ble.e8:e0:7e:bf:46:63.motion']), change: 'ne' }, async (obj) => {
          let value = obj.state.val;
          let oldValue = obj.oldState.val;
          if (getState('shelly.1.ble.e8:e0:7e:bf:46:63.motion').val == true) {
            // Licht Tablet
            setState('shelly.1.shelly1minig3#84fce638dec0#1.Relay0.Switch' /* Schalter */, true);
          }
        });
        
        //JTNDeG1sJTIweG1sbnMlM0QlMjJodHRwcyUzQSUyRiUyRmRldmVsb3BlcnMuZ29vZ2xlLmNvbSUyRmJsb2NrbHklMkZ4bWwlMjIlM0UlM0NibG9jayUyMHR5cGUlM0QlMj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TNFTGljaHQlMjBUYWJsZXQlM0MlMkZmaWVsZCUzRSUzQ25leHQlM0UlM0NibG9jayUyMHR5cGUlM0QlMjJjb250cm9sJTIyJTIwaWQlM0QlMjJQJTdCdnVlQyUyM1UlMjRnQiU1RG9pMXlKT1VZJTIyJTNFJTNDbXV0YXRpb24lMjB4bWxucyUzRCUyMmh0dHAlM0ElMkYlMkZ3d3cudzMub3JnJTJGMTk5OSUyRnhodG1sJTIyJTIwZGVsYXlfaW5wdXQlM0QlMjJmYWxzZSUyMiUzRSUzQyUyRm11dGF0aW9uJTNFJTNDZmllbGQlMjBuYW1lJTNEJTIyT0lEJTIyJTNFc2hlbGx5LjEuc2hlbGx5MW1pbmlnMyUyMzg0ZmNlNjM4ZGVjMCUyMzEuUmVsYXkwLlN3aXRjaCUzQyUyRmZpZWxkJTNFJTNDZmllbGQlMjBuYW1lJTNEJTIyV0lUSF9ERUxBWSUyMiUzRUZBTFNFJTNDJTJGZmllbGQlM0UlM0N2YWx1ZSUyMG5hbWUlM0QlMjJWQUxVRSUyMiUzRSUzQ2Jsb2NrJTIwdHlwZSUzRCUyMmxvZ2ljX2Jvb2xlYW4lMjIlMjBpZCUzRCUyMiUyQ0RZZ3olNDBNVSU2MGY2a1dPbXVubE95JTIyJTNFJTNDZmllbGQlMjBuYW1lJTNEJTIyQk9PTCUyMiUzRVRSVUUlM0MlMkZmaWVsZCUzRSUzQyUyRmJsb2NrJTNFJTNDJTJGdmFsdWUlM0UlM0MlMkZibG9jayUzRSUzQyUyRm5leHQlM0UlM0MlMkZibG9jayUzRSUzQyUyRnN0YXRlbWVudCUzRSUzQyUyRmJsb2NrJTNFJTNDJTJGc3RhdGVtZW50JTNFJTNDJTJGYmxvY2slM0UlM0MlMkZuZXh0JTNFJTNDJTJGYmxvY2slM0UlM0MlMkZ4bWwlM0U=
        
        
        1 Antwort Letzte Antwort
        0
        • K Offline
          K Offline
          kg36304
          schrieb am zuletzt editiert von
          #93

          Hier noch ein Bild vom Blockly:

          Bildschirmfoto 2024-06-17 um 22.02.16.png

          A 1 Antwort Letzte Antwort
          0
          • K kg36304

            Hier noch ein Bild vom Blockly:

            Bildschirmfoto 2024-06-17 um 22.02.16.png

            A Offline
            A Offline
            Apfelwurm
            schrieb am zuletzt editiert von
            #94

            @kg36304

            Wenn ich es richtig verstehe willst du wenn Bewegung erkannt das Licht für Zeit x an ist.

            Dann müsst ja noch einen Timer einbauen der immer von vorne beginnt wenn eine neue Bewegung erkannt wird.

            Aber so macht er es ja richtig Bewegung an keine Bewegung aus dann wieder Bewegung an.

            1 Antwort Letzte Antwort
            0
            • A Apfelwurm

              Ich hab mal das Script angepasst.
              MAC Adresse in Namen übersetzen und die Zeile ersetzt damit ein BLU H&T die Werte richtig überträgt. Vielleicht hilft es ja dem ein oder anderen.

              // v0.2 custom 
              let SCRIPT_VERSION = '0.2';
              let BTHOME_SVC_ID_STR = 'fcd2';
              
              let uint8 = 0;
              let int8 = 1;
              let uint16 = 2;
              let int16 = 3;
              let uint24 = 4;
              let int24 = 5;
              
              let BTH = {};
              let SHELLY_ID = undefined;
              
              const BTH = {
                  0x00: { n: 'pid', t: uint8 },
                  0x01: { n: 'battery', t: uint8, u: '%' },
                  0x02: { n: 'temperature', t: int16, f: 0.01, u: 'tC' },
                  0x45: { n: 'temperature', t: int16, f: 0.1, u: 'tC' },
                  0x03: { n: 'humidity', t: uint16, f: 0.01, u: '%' },
                  0x2e: { n: 'humidity', t: uint8, u: '%' },
                  0x05: { n: 'illuminance', t: uint24, f: 0.01 },
                  0x1a: { n: 'door', t: uint8 },
                  0x20: { n: 'moisture', t: uint8 },
                  0x21: { n: 'motion', t: uint8 },
                  0x2d: { n: 'window', t: uint8 },
                  0x3a: { n: 'button', t: uint8 },
                  0x3f: { n: 'rotation', t: int16, f: 0.1 }
              };
              
              // Mapping of MAC addresses to individual names
              let macToName = {
                  'aa:bb:cc:dd:ee:ff': 'Device1',
                  '11:22:33:44:55:66': 'Device2'
              };
              
              function getByteSize(type) {
                  if (type === uint8 || type === int8) return 1;
                  if (type === uint16 || type === int16) return 2;
                  if (type === uint24 || type === int24) return 3;
                  // impossible as advertisements are much smaller
                  return 255;
              }
              
              let BTHomeDecoder = {
                  utoi: function (num, bitsz) {
                      let mask = 1 << (bitsz - 1);
                      return num & mask ? num - (1 << bitsz) : num;
                  },
                  getUInt8: function (buffer) {
                      return buffer.at(0);
                  },
                  getInt8: function (buffer) {
                      return this.utoi(this.getUInt8(buffer), 8);
                  },
                  getUInt16LE: function (buffer) {
                      return 0xffff & ((buffer.at(1) << 8) | buffer.at(0));
                  },
                  getInt16LE: function (buffer) {
                      return this.utoi(this.getUInt16LE(buffer), 16);
                  },
                  getUInt24LE: function (buffer) {
                      return (
                          0x00ffffff & ((buffer.at(2) << 16) | (buffer.at(1) << 8) | buffer.at(0))
                      );
                  },
                  getInt24LE: function (buffer) {
                      return this.utoi(this.getUInt24LE(buffer), 24);
                  },
                  getBufValue: function (type, buffer) {
                      if (buffer.length < getByteSize(type)) return null;
                      let res = null;
                      if (type === uint8) res = this.getUInt8(buffer);
                      if (type === int8) res = this.getInt8(buffer);
                      if (type === uint16) res = this.getUInt16LE(buffer);
                      if (type === int16) res = this.getInt16LE(buffer);
                      if (type === uint24) res = this.getUInt24LE(buffer);
                      if (type === int24) res = this.getInt24LE(buffer);
                      return res;
                  },
                  unpack: function (buffer) {
                      // beacons might not provide BTH service data
                      if (typeof buffer !== 'string' || buffer.length === 0) return null;
                      let result = {};
                      let _dib = buffer.at(0);
                      result['encryption'] = _dib & 0x1 ? true : false;
                      result['BTHome_version'] = _dib >> 5;
                      if (result['BTHome_version'] !== 2) return null;
                      // can not handle encrypted data
                      if (result['encryption']) return result;
                      buffer = buffer.slice(1);
              
                      let _bth;
                      let _value;
                      while (buffer.length > 0) {
                          _bth = BTH[buffer.at(0)];
                          if (typeof _bth === 'undefined') {
                              console.log('Error: unknown type ' + buffer.at(0));
                              break;
                          }
                          buffer = buffer.slice(1);
                          _value = this.getBufValue(_bth.t, buffer);
                          if (_value === null) break;
                          if (typeof _bth.f !== 'undefined') _value = _value * _bth.f;
                          result[_bth.n] = _value;
                          buffer = buffer.slice(getByteSize(_bth.t));
                      }
                      return result;
                  }
              };
              
              let lastPacketId = 0x100;
              
              // Callback for the BLE scanner object
              function bleScanCallback(event, result) {
                  // exit if not a result of a scan
                  if (event !== BLE.Scanner.SCAN_RESULT) {
                      return;
                  }
              
                  // exit if service_data member is missing
                  if (
                      typeof result.service_data === 'undefined' ||
                      typeof result.service_data[BTHOME_SVC_ID_STR] === 'undefined'
                  ) {
                      // console.log('Error: Missing service_data member');
                      return;
                  }
              
                  let unpackedData = BTHomeDecoder.unpack(
                      result.service_data[BTHOME_SVC_ID_STR]
                  );
              
                  // exit if unpacked data is null or the device is encrypted
                  if (
                      unpackedData === null ||
                      typeof unpackedData === "undefined" ||
                      unpackedData["encryption"]
                  ) {
                      console.log('Error: Encrypted devices are not supported');
                      return;
                  }
              
                  // exit if the event is duplicated
                  if (lastPacketId === unpackedData.pid) {
                      return;
                  }
              
                  lastPacketId = unpackedData.pid;
              
                  unpackedData.rssi = result.rssi;
                  unpackedData.address = result.addr;
              
                  // Convert MAC address to lowercase for case insensitive matching
                  let macLower = result.addr.toLowerCase();
                  let deviceName = macToName[macLower] || result.addr;
              
                  // create MQTT-Payload
                  let message = {
                      scriptVersion: SCRIPT_VERSION,
                      src: SHELLY_ID,
                      srcBle: {
                          type: result.local_name,
                          mac: deviceName
                      },
                      payload: unpackedData
                  };
              
                  console.log('Received ' + JSON.stringify(unpackedData));
              
                  if (MQTT.isConnected()) {
                      MQTT.publish(SHELLY_ID + '/events/ble', JSON.stringify(message));
                  }
              }
              
              // Initializes the script and performs the necessary checks and configurations
              function init() {
                  // get the config of ble component
                  let bleConfig = Shelly.getComponentConfig('ble');
              
                  // exit if the BLE isn't enabled
                  if (!bleConfig.enable) {
                      console.log('Error: The Bluetooth is not enabled, please enable it in the settings');
                      return;
                  }
              
                  // check if the scanner is already running
                  if (BLE.Scanner.isRunning()) {
                      console.log('Info: The BLE gateway is running, the BLE scan configuration is managed by the device');
                  } else {
                      // start the scanner
                      let bleScanner = BLE.Scanner.Start({
                          duration_ms: BLE.Scanner.INFINITE_SCAN,
                          active: true
                      });
              
                      if (!bleScanner) {
                          console.log('Error: Can not start new scanner');
                      }
                  }
              
                  BLE.Scanner.Subscribe(bleScanCallback);
              }
              
              Shelly.call('Mqtt.GetConfig', '', function (res, err_code, err_msg, ud) {
                  SHELLY_ID = res['topic_prefix'];
              
                  init();
              });
              
              HumidorH Offline
              HumidorH Offline
              Humidor
              schrieb am zuletzt editiert von
              #95

              @apfelwurm leider, auch dieses Script bringt mir kein Event in den ioBroker

              BG

              1 Antwort Letzte Antwort
              0
              • K Offline
                K Offline
                kg36304
                schrieb am zuletzt editiert von
                #96

                Hallo,

                danke für die Antworten. Funktioniert jetzt.

                1 Antwort Letzte Antwort
                0
                • spinottiS Offline
                  spinottiS Offline
                  spinotti
                  schrieb am zuletzt editiert von
                  #97

                  Hi zusammen

                  ich hätte mal eine Frage zu diesem Thema.
                  Ich habe jetzt ein neues Shelly Gateway und darauf ein das neue Shelly BLU TRV verbunden.

                  Ich schaffe es leider nicht per MQTT die Daten in den iobroker zu bringen. Hab schon mehrere Anpassungen am Script versucht.
                  Das ist der Script den ich drin hab im BLU Gateway Gen.3

                  Ich habe alles nach der Anleitung hier gemacht:
                  https://github.com/iobroker-community-adapters/ioBroker.shelly/blob/master/docs/en/ble-devices.md

                  Das neueste Script ist drin.

                  // v0.4
                  const SCRIPT_VERSION = '0.4';
                  const BTHOME_SVC_ID_STR = 'fcd2';
                  
                  const uint8 = 0;
                  const int8 = 1;
                  const uint16 = 2;
                  const int16 = 3;
                  const uint24 = 4;
                  const int24 = 5;
                  const uint32 = 6;
                  const int32 = 7;
                  
                  let SHELLY_ID = undefined;
                  
                  const BTH = {
                      // Misc
                      0x00: { n: 'pid', t: uint8 },
                      0xf0: { n: 'device_type', t: uint16 },
                      0xf1: { n: 'firmware_version', t: uint32 },
                      0xf2: { n: 'firmware_version', t: uint24 },
                      // Sensor data
                      0x51: { n: 'acceleration', t: uint16, f: 0.001, u: 'm/s²' },
                      0x01: { n: 'battery', t: uint8, u: '%' },
                      0x12: { n: 'co2', t: uint16, u: 'ppm' },
                      0x09: { n: 'count', t: uint8 },
                      0x3d: { n: 'count', t: uint8 },
                      0x3e: { n: 'count', t: uint8 },
                      0x43: { n: 'current', t: uint16, f: 0.001, u: 'A' },
                      0x08: { n: 'dewpoint', t: int16, f: 0.01, u: '°C' },
                      0x40: { n: 'distance_mm', t: uint16, u: 'mm' },
                      0x41: { n: 'distance_m', t: uint16, f: 0.1, u: 'm' },
                      0x42: { n: 'duration', t: uint24, f: 0.001, u: 's' },
                      0x4d: { n: 'energy', t: uint32, f: 0.001, u: 'kWh' },
                      0x0a: { n: 'energy', t: uint24, f: 0.001, u: 'kWh' },
                      0x4b: { n: 'gas', t: uint24, f: 0.001, u: 'm3' },
                      0x4c: { n: 'gas', t: uint32, f: 0.001, u: 'm3' },
                      0x52: { n: 'gyroscope', t: uint16, f: 0.001, u: '°/s' },
                      0x03: { n: 'humidity', t: uint16, f: 0.01, u: '%' },
                      0x2e: { n: 'humidity', t: uint8, u: '%' },
                      0x05: { n: 'illuminance', t: uint24, f: 0.01, u: 'lux' },
                      0x06: { n: 'mass_kg', t: uint16, f: 0.01, u: 'kg' },
                      0x07: { n: 'mass_lb', t: uint16, f: 0.01, u: 'lb' },
                      0x14: { n: 'moisture', t: uint16, f: 0.01, u: '%' },
                      0x2f: { n: 'moisture', t: uint8, u: '%' },
                      0x0d: { n: 'pm2_5', t: uint16, u: 'ug/m3' },
                      0x0e: { n: 'pm10', t: uint16, u: 'ug/m3' },
                      0x0b: { n: 'power', t: uint24, f: 0.01, u: 'W' },
                      0x04: { n: 'pressure', t: uint24, f: 0.01, u: 'hPa' },
                      0x3f: { n: 'rotation', t: int16, f: 0.1, u: '°' },
                      0x44: { n: 'speed', t: uint16, f: 0.01, u: 'm/s' },
                      0x45: { n: 'temperature', t: int16, f: 0.1, u: '°C' },
                      0x02: { n: 'temperature', t: int16, f: 0.01, u: '°C' },
                      0x13: { n: 'tvoc', t: uint16, u: 'ug/m3' },
                      0x0c: { n: 'voltage', t: uint16, f: 0.001, u: 'V' },
                      0x4a: { n: 'voltage', t: uint16, f: 0.1, u: 'V' },
                      0x4e: { n: 'volume', t: uint32, f: 0.001, u: 'l' },
                      0x47: { n: 'volume', t: uint16, f: 0.1, u: 'l' },
                      0x48: { n: 'volume', t: uint16, u: 'ml' },
                      0x55: { n: 'volume', t: uint32, f: 0.001, u: 'l' },
                      0x49: { n: 'volume', t: uint16, f: 0.001, u: 'm3/h' },
                      0x46: { n: 'uv_index', t: uint8, f: 0.1 },
                      0x4f: { n: 'water', t: uint32, f: 0.001, u: 'l' },
                      // Binary Sensor data
                      0x15: { n: 'battery', t: uint8 },
                      0x16: { n: 'battery_charging', t: uint8 },
                      0x17: { n: 'carbon_monoxide', t: uint8 },
                      0x18: { n: 'cold', t: uint8 },
                      0x19: { n: 'connectivity', t: uint8 },
                      0x1a: { n: 'door', t: uint8 },
                      0x1b: { n: 'garage_door', t: uint8 },
                      0x1c: { n: 'gas', t: uint8 },
                      0x0f: { n: 'generic_boolean', t: uint8 },
                      0x1d: { n: 'heat', t: uint8 },
                      0x1e: { n: 'light', t: uint8 },
                      0x1f: { n: 'lock', t: uint8 },
                      0x20: { n: 'moisture', t: uint8 },
                      0x21: { n: 'motion', t: uint8 },
                      0x22: { n: 'moving', t: uint8 },
                      0x23: { n: 'occupancy', t: uint8 },
                      0x11: { n: 'opening', t: uint8 },
                      0x24: { n: 'plug', t: uint8 },
                      0x10: { n: 'power', t: uint8 },
                      0x25: { n: 'presence', t: uint8 },
                      0x26: { n: 'problem', t: uint8 },
                      0x27: { n: 'running', t: uint8 },
                      0x28: { n: 'safety', t: uint8 },
                      0x29: { n: 'smoke', t: uint8 },
                      0x2a: { n: 'sound', t: uint8 },
                      0x2b: { n: 'tamper', t: uint8 },
                      0x2c: { n: 'vibration', t: uint8 },
                      0x2d: { n: 'window', t: uint8 },
                      // Events
                      0x3a: { n: 'button', t: uint8, b: 1 },
                      0x3c: { n: 'dimmer', t: uint8 }
                  };
                  
                  function getByteSize(type) {
                      if (type === uint8 || type === int8) return 1;
                      if (type === uint16 || type === int16) return 2;
                      if (type === uint24 || type === int24) return 3;
                      // impossible as advertisements are much smaller
                      return 255;
                  }
                  
                  let BTHomeDecoder = {
                      utoi: function (num, bitsz) {
                          let mask = 1 << (bitsz - 1);
                          return num & mask ? num - (1 << bitsz) : num;
                      },
                      getUInt8: function (buffer) {
                          return buffer.at(0);
                      },
                      getInt8: function (buffer) {
                          return this.utoi(this.getUInt8(buffer), 8);
                      },
                      getUInt16LE: function (buffer) {
                          return 0xffff & ((buffer.at(1) << 8) | buffer.at(0));
                      },
                      getInt16LE: function (buffer) {
                          return this.utoi(this.getUInt16LE(buffer), 16);
                      },
                      getUInt24LE: function (buffer) {
                          return (
                              0x00ffffff & ((buffer.at(2) << 16) | (buffer.at(1) << 8) | buffer.at(0))
                          );
                      },
                      getInt24LE: function (buffer) {
                          return this.utoi(this.getUInt24LE(buffer), 24);
                      },
                      getUInt32LE: function (buffer) {
                          return (
                              0x00ffffffff & ((buffer.at(3) << 24) | (buffer.at(2) << 16) | (buffer.at(1) << 8) | buffer.at(0))
                          );
                      },
                      getInt32LE: function (buffer) {
                          return this.utoi(this.getUInt32LE(buffer), 32);
                      },
                      getBufValue: function (type, buffer) {
                          if (buffer.length < getByteSize(type)) return null;
                          let res = null;
                          if (type === uint8) res = this.getUInt8(buffer);
                          if (type === int8) res = this.getInt8(buffer);
                          if (type === uint16) res = this.getUInt16LE(buffer);
                          if (type === int16) res = this.getInt16LE(buffer);
                          if (type === uint24) res = this.getUInt24LE(buffer);
                          if (type === int24) res = this.getInt24LE(buffer);
                          if (type === uint32) res = this.getUInt32LE(buffer);
                          if (type === int32) res = this.getInt32LE(buffer);
                          return res;
                      },
                      unpack: function (buffer) {
                          // beacons might not provide BTH service data
                          if (typeof buffer !== 'string' || buffer.length === 0) return null;
                          let result = {};
                          let _dib = buffer.at(0);
                          result['encryption'] = _dib & 0x1 ? true : false;
                          result['BTHome_version'] = _dib >> 5;
                          if (result['BTHome_version'] !== 2) return null;
                          // can not handle encrypted data
                          if (result['encryption']) return result;
                          buffer = buffer.slice(1);
                  
                          let _bth;
                          let _value;
                          let _name;
                          let _btnNum = 1;
                          while (buffer.length > 0) {
                              _bth = BTH[buffer.at(0)];
                              if (typeof _bth === 'undefined') {
                                  console.log('Error: unknown type ' + buffer.at(0));
                                  break;
                              }
                              buffer = buffer.slice(1);
                              _value = this.getBufValue(_bth.t, buffer);
                              if (_value === null) break;
                              if (typeof _bth.f !== 'undefined') _value = _value * _bth.f;
                  
                              _name = _bth.n;
                              if (typeof _bth.b !== "undefined") {
                                  _name = _name + '_' + _btnNum.toString();
                                  _btnNum++;
                              }
                  
                              result[_name] = _value;
                              buffer = buffer.slice(getByteSize(_bth.t));
                          }
                          return result;
                      }
                  };
                  
                  let lastPacketId = 0x100;
                  
                  // Callback for the BLE scanner object
                  function bleScanCallback(event, result) {
                      // exit if not a result of a scan
                      if (event !== BLE.Scanner.SCAN_RESULT) {
                          return;
                      }
                  
                      // exit if service_data member is missing
                      if (
                          typeof result.service_data === 'undefined' ||
                          typeof result.service_data[BTHOME_SVC_ID_STR] === 'undefined'
                      ) {
                          // console.log('Error: Missing service_data member');
                          return;
                      }
                  
                      let unpackedData = BTHomeDecoder.unpack(
                          result.service_data[BTHOME_SVC_ID_STR]
                      );
                  
                      // exit if unpacked data is null or the device is encrypted
                      if (
                          unpackedData === null ||
                          typeof unpackedData === 'undefined' ||
                          unpackedData['encryption']
                      ) {
                          console.log('Error: Encrypted devices are not supported');
                          return;
                      }
                  
                      // exit if the event is duplicated
                      if (lastPacketId === unpackedData.pid) {
                          return;
                      }
                  
                      lastPacketId = unpackedData.pid;
                  
                      unpackedData.rssi = result.rssi;
                      unpackedData.address = result.addr;
                  
                      // create MQTT-Payload
                      let message = {
                          scriptVersion: SCRIPT_VERSION,
                          src: SHELLY_ID,
                          srcBle: {
                              type: result.local_name,
                              mac: result.addr
                          },
                          payload: unpackedData
                      };
                  
                      console.log('Received ' + JSON.stringify(unpackedData));
                  
                      if (MQTT.isConnected()) {
                          MQTT.publish(SHELLY_ID + '/events/ble', JSON.stringify(message));
                      }
                  }
                  
                  // Initializes the script and performs the necessary checks and configurations
                  function init() {
                      // get the config of ble component
                      let bleConfig = Shelly.getComponentConfig('ble');
                  
                      // exit if the BLE isn't enabled
                      if (!bleConfig.enable) {
                          console.log('Error: The Bluetooth is not enabled, please enable it in the settings');
                          return;
                      }
                  
                      // check if the scanner is already running
                      if (BLE.Scanner.isRunning()) {
                          console.log('Info: The BLE gateway is running, the BLE scan configuration is managed by the device');
                      } else {
                          // start the scanner
                          let bleScanner = BLE.Scanner.Start({
                              duration_ms: BLE.Scanner.INFINITE_SCAN,
                              active: true
                          });
                  
                          if (!bleScanner) {
                              console.log('Error: Can not start new scanner');
                          }
                      }
                  
                      BLE.Scanner.Subscribe(bleScanCallback);
                  }
                  
                  Shelly.call('Mqtt.GetConfig', '', function (res, err_code, err_msg, ud) {
                      SHELLY_ID = res['topic_prefix'];
                  
                      init();
                  });
                  

                  alle Adapter sind aktualisiert
                  Shelly Geräte auch alle,
                  JS Controller upgedatet.
                  Shelly Adapter ist auf : V8.2.1

                  Ich bekomme vom Script immer die Meldung 84 zurück, weiß vielleicht jemand von euch woran das liegen könnte?
                  2024-11-01 12_55_02-Shelly BLU Gateway Gen3.png

                  Dadurch hab ich auch bei den Objekten unter BLE nichts drin
                  2024-11-01 12_53_18-objects - glt.png

                  Für einen Tipp wäre ich sehr dankbar.

                  Vielen Dank
                  LG Mathias

                  haus-automatisierungH 1 Antwort Letzte Antwort
                  0
                  • spinottiS spinotti

                    Hi zusammen

                    ich hätte mal eine Frage zu diesem Thema.
                    Ich habe jetzt ein neues Shelly Gateway und darauf ein das neue Shelly BLU TRV verbunden.

                    Ich schaffe es leider nicht per MQTT die Daten in den iobroker zu bringen. Hab schon mehrere Anpassungen am Script versucht.
                    Das ist der Script den ich drin hab im BLU Gateway Gen.3

                    Ich habe alles nach der Anleitung hier gemacht:
                    https://github.com/iobroker-community-adapters/ioBroker.shelly/blob/master/docs/en/ble-devices.md

                    Das neueste Script ist drin.

                    // v0.4
                    const SCRIPT_VERSION = '0.4';
                    const BTHOME_SVC_ID_STR = 'fcd2';
                    
                    const uint8 = 0;
                    const int8 = 1;
                    const uint16 = 2;
                    const int16 = 3;
                    const uint24 = 4;
                    const int24 = 5;
                    const uint32 = 6;
                    const int32 = 7;
                    
                    let SHELLY_ID = undefined;
                    
                    const BTH = {
                        // Misc
                        0x00: { n: 'pid', t: uint8 },
                        0xf0: { n: 'device_type', t: uint16 },
                        0xf1: { n: 'firmware_version', t: uint32 },
                        0xf2: { n: 'firmware_version', t: uint24 },
                        // Sensor data
                        0x51: { n: 'acceleration', t: uint16, f: 0.001, u: 'm/s²' },
                        0x01: { n: 'battery', t: uint8, u: '%' },
                        0x12: { n: 'co2', t: uint16, u: 'ppm' },
                        0x09: { n: 'count', t: uint8 },
                        0x3d: { n: 'count', t: uint8 },
                        0x3e: { n: 'count', t: uint8 },
                        0x43: { n: 'current', t: uint16, f: 0.001, u: 'A' },
                        0x08: { n: 'dewpoint', t: int16, f: 0.01, u: '°C' },
                        0x40: { n: 'distance_mm', t: uint16, u: 'mm' },
                        0x41: { n: 'distance_m', t: uint16, f: 0.1, u: 'm' },
                        0x42: { n: 'duration', t: uint24, f: 0.001, u: 's' },
                        0x4d: { n: 'energy', t: uint32, f: 0.001, u: 'kWh' },
                        0x0a: { n: 'energy', t: uint24, f: 0.001, u: 'kWh' },
                        0x4b: { n: 'gas', t: uint24, f: 0.001, u: 'm3' },
                        0x4c: { n: 'gas', t: uint32, f: 0.001, u: 'm3' },
                        0x52: { n: 'gyroscope', t: uint16, f: 0.001, u: '°/s' },
                        0x03: { n: 'humidity', t: uint16, f: 0.01, u: '%' },
                        0x2e: { n: 'humidity', t: uint8, u: '%' },
                        0x05: { n: 'illuminance', t: uint24, f: 0.01, u: 'lux' },
                        0x06: { n: 'mass_kg', t: uint16, f: 0.01, u: 'kg' },
                        0x07: { n: 'mass_lb', t: uint16, f: 0.01, u: 'lb' },
                        0x14: { n: 'moisture', t: uint16, f: 0.01, u: '%' },
                        0x2f: { n: 'moisture', t: uint8, u: '%' },
                        0x0d: { n: 'pm2_5', t: uint16, u: 'ug/m3' },
                        0x0e: { n: 'pm10', t: uint16, u: 'ug/m3' },
                        0x0b: { n: 'power', t: uint24, f: 0.01, u: 'W' },
                        0x04: { n: 'pressure', t: uint24, f: 0.01, u: 'hPa' },
                        0x3f: { n: 'rotation', t: int16, f: 0.1, u: '°' },
                        0x44: { n: 'speed', t: uint16, f: 0.01, u: 'm/s' },
                        0x45: { n: 'temperature', t: int16, f: 0.1, u: '°C' },
                        0x02: { n: 'temperature', t: int16, f: 0.01, u: '°C' },
                        0x13: { n: 'tvoc', t: uint16, u: 'ug/m3' },
                        0x0c: { n: 'voltage', t: uint16, f: 0.001, u: 'V' },
                        0x4a: { n: 'voltage', t: uint16, f: 0.1, u: 'V' },
                        0x4e: { n: 'volume', t: uint32, f: 0.001, u: 'l' },
                        0x47: { n: 'volume', t: uint16, f: 0.1, u: 'l' },
                        0x48: { n: 'volume', t: uint16, u: 'ml' },
                        0x55: { n: 'volume', t: uint32, f: 0.001, u: 'l' },
                        0x49: { n: 'volume', t: uint16, f: 0.001, u: 'm3/h' },
                        0x46: { n: 'uv_index', t: uint8, f: 0.1 },
                        0x4f: { n: 'water', t: uint32, f: 0.001, u: 'l' },
                        // Binary Sensor data
                        0x15: { n: 'battery', t: uint8 },
                        0x16: { n: 'battery_charging', t: uint8 },
                        0x17: { n: 'carbon_monoxide', t: uint8 },
                        0x18: { n: 'cold', t: uint8 },
                        0x19: { n: 'connectivity', t: uint8 },
                        0x1a: { n: 'door', t: uint8 },
                        0x1b: { n: 'garage_door', t: uint8 },
                        0x1c: { n: 'gas', t: uint8 },
                        0x0f: { n: 'generic_boolean', t: uint8 },
                        0x1d: { n: 'heat', t: uint8 },
                        0x1e: { n: 'light', t: uint8 },
                        0x1f: { n: 'lock', t: uint8 },
                        0x20: { n: 'moisture', t: uint8 },
                        0x21: { n: 'motion', t: uint8 },
                        0x22: { n: 'moving', t: uint8 },
                        0x23: { n: 'occupancy', t: uint8 },
                        0x11: { n: 'opening', t: uint8 },
                        0x24: { n: 'plug', t: uint8 },
                        0x10: { n: 'power', t: uint8 },
                        0x25: { n: 'presence', t: uint8 },
                        0x26: { n: 'problem', t: uint8 },
                        0x27: { n: 'running', t: uint8 },
                        0x28: { n: 'safety', t: uint8 },
                        0x29: { n: 'smoke', t: uint8 },
                        0x2a: { n: 'sound', t: uint8 },
                        0x2b: { n: 'tamper', t: uint8 },
                        0x2c: { n: 'vibration', t: uint8 },
                        0x2d: { n: 'window', t: uint8 },
                        // Events
                        0x3a: { n: 'button', t: uint8, b: 1 },
                        0x3c: { n: 'dimmer', t: uint8 }
                    };
                    
                    function getByteSize(type) {
                        if (type === uint8 || type === int8) return 1;
                        if (type === uint16 || type === int16) return 2;
                        if (type === uint24 || type === int24) return 3;
                        // impossible as advertisements are much smaller
                        return 255;
                    }
                    
                    let BTHomeDecoder = {
                        utoi: function (num, bitsz) {
                            let mask = 1 << (bitsz - 1);
                            return num & mask ? num - (1 << bitsz) : num;
                        },
                        getUInt8: function (buffer) {
                            return buffer.at(0);
                        },
                        getInt8: function (buffer) {
                            return this.utoi(this.getUInt8(buffer), 8);
                        },
                        getUInt16LE: function (buffer) {
                            return 0xffff & ((buffer.at(1) << 8) | buffer.at(0));
                        },
                        getInt16LE: function (buffer) {
                            return this.utoi(this.getUInt16LE(buffer), 16);
                        },
                        getUInt24LE: function (buffer) {
                            return (
                                0x00ffffff & ((buffer.at(2) << 16) | (buffer.at(1) << 8) | buffer.at(0))
                            );
                        },
                        getInt24LE: function (buffer) {
                            return this.utoi(this.getUInt24LE(buffer), 24);
                        },
                        getUInt32LE: function (buffer) {
                            return (
                                0x00ffffffff & ((buffer.at(3) << 24) | (buffer.at(2) << 16) | (buffer.at(1) << 8) | buffer.at(0))
                            );
                        },
                        getInt32LE: function (buffer) {
                            return this.utoi(this.getUInt32LE(buffer), 32);
                        },
                        getBufValue: function (type, buffer) {
                            if (buffer.length < getByteSize(type)) return null;
                            let res = null;
                            if (type === uint8) res = this.getUInt8(buffer);
                            if (type === int8) res = this.getInt8(buffer);
                            if (type === uint16) res = this.getUInt16LE(buffer);
                            if (type === int16) res = this.getInt16LE(buffer);
                            if (type === uint24) res = this.getUInt24LE(buffer);
                            if (type === int24) res = this.getInt24LE(buffer);
                            if (type === uint32) res = this.getUInt32LE(buffer);
                            if (type === int32) res = this.getInt32LE(buffer);
                            return res;
                        },
                        unpack: function (buffer) {
                            // beacons might not provide BTH service data
                            if (typeof buffer !== 'string' || buffer.length === 0) return null;
                            let result = {};
                            let _dib = buffer.at(0);
                            result['encryption'] = _dib & 0x1 ? true : false;
                            result['BTHome_version'] = _dib >> 5;
                            if (result['BTHome_version'] !== 2) return null;
                            // can not handle encrypted data
                            if (result['encryption']) return result;
                            buffer = buffer.slice(1);
                    
                            let _bth;
                            let _value;
                            let _name;
                            let _btnNum = 1;
                            while (buffer.length > 0) {
                                _bth = BTH[buffer.at(0)];
                                if (typeof _bth === 'undefined') {
                                    console.log('Error: unknown type ' + buffer.at(0));
                                    break;
                                }
                                buffer = buffer.slice(1);
                                _value = this.getBufValue(_bth.t, buffer);
                                if (_value === null) break;
                                if (typeof _bth.f !== 'undefined') _value = _value * _bth.f;
                    
                                _name = _bth.n;
                                if (typeof _bth.b !== "undefined") {
                                    _name = _name + '_' + _btnNum.toString();
                                    _btnNum++;
                                }
                    
                                result[_name] = _value;
                                buffer = buffer.slice(getByteSize(_bth.t));
                            }
                            return result;
                        }
                    };
                    
                    let lastPacketId = 0x100;
                    
                    // Callback for the BLE scanner object
                    function bleScanCallback(event, result) {
                        // exit if not a result of a scan
                        if (event !== BLE.Scanner.SCAN_RESULT) {
                            return;
                        }
                    
                        // exit if service_data member is missing
                        if (
                            typeof result.service_data === 'undefined' ||
                            typeof result.service_data[BTHOME_SVC_ID_STR] === 'undefined'
                        ) {
                            // console.log('Error: Missing service_data member');
                            return;
                        }
                    
                        let unpackedData = BTHomeDecoder.unpack(
                            result.service_data[BTHOME_SVC_ID_STR]
                        );
                    
                        // exit if unpacked data is null or the device is encrypted
                        if (
                            unpackedData === null ||
                            typeof unpackedData === 'undefined' ||
                            unpackedData['encryption']
                        ) {
                            console.log('Error: Encrypted devices are not supported');
                            return;
                        }
                    
                        // exit if the event is duplicated
                        if (lastPacketId === unpackedData.pid) {
                            return;
                        }
                    
                        lastPacketId = unpackedData.pid;
                    
                        unpackedData.rssi = result.rssi;
                        unpackedData.address = result.addr;
                    
                        // create MQTT-Payload
                        let message = {
                            scriptVersion: SCRIPT_VERSION,
                            src: SHELLY_ID,
                            srcBle: {
                                type: result.local_name,
                                mac: result.addr
                            },
                            payload: unpackedData
                        };
                    
                        console.log('Received ' + JSON.stringify(unpackedData));
                    
                        if (MQTT.isConnected()) {
                            MQTT.publish(SHELLY_ID + '/events/ble', JSON.stringify(message));
                        }
                    }
                    
                    // Initializes the script and performs the necessary checks and configurations
                    function init() {
                        // get the config of ble component
                        let bleConfig = Shelly.getComponentConfig('ble');
                    
                        // exit if the BLE isn't enabled
                        if (!bleConfig.enable) {
                            console.log('Error: The Bluetooth is not enabled, please enable it in the settings');
                            return;
                        }
                    
                        // check if the scanner is already running
                        if (BLE.Scanner.isRunning()) {
                            console.log('Info: The BLE gateway is running, the BLE scan configuration is managed by the device');
                        } else {
                            // start the scanner
                            let bleScanner = BLE.Scanner.Start({
                                duration_ms: BLE.Scanner.INFINITE_SCAN,
                                active: true
                            });
                    
                            if (!bleScanner) {
                                console.log('Error: Can not start new scanner');
                            }
                        }
                    
                        BLE.Scanner.Subscribe(bleScanCallback);
                    }
                    
                    Shelly.call('Mqtt.GetConfig', '', function (res, err_code, err_msg, ud) {
                        SHELLY_ID = res['topic_prefix'];
                    
                        init();
                    });
                    

                    alle Adapter sind aktualisiert
                    Shelly Geräte auch alle,
                    JS Controller upgedatet.
                    Shelly Adapter ist auf : V8.2.1

                    Ich bekomme vom Script immer die Meldung 84 zurück, weiß vielleicht jemand von euch woran das liegen könnte?
                    2024-11-01 12_55_02-Shelly BLU Gateway Gen3.png

                    Dadurch hab ich auch bei den Objekten unter BLE nichts drin
                    2024-11-01 12_53_18-objects - glt.png

                    Für einen Tipp wäre ich sehr dankbar.

                    Vielen Dank
                    LG Mathias

                    haus-automatisierungH Online
                    haus-automatisierungH Online
                    haus-automatisierung
                    Developer Most Active
                    schrieb am zuletzt editiert von
                    #98

                    @spinotti https://github.com/iobroker-community-adapters/ioBroker.shelly/issues/1072

                    🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                    🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                    📚 Meine inoffizielle ioBroker Dokumentation

                    spinottiS 1 Antwort Letzte Antwort
                    0
                    • haus-automatisierungH haus-automatisierung

                      @spinotti https://github.com/iobroker-community-adapters/ioBroker.shelly/issues/1072

                      spinottiS Offline
                      spinottiS Offline
                      spinotti
                      schrieb am zuletzt editiert von
                      #99

                      @haus-automatisierung
                      oh, vielen Dank!
                      LG

                      1 Antwort Letzte Antwort
                      0
                      • R Offline
                        R Offline
                        rolfs
                        schrieb am zuletzt editiert von
                        #100

                        Hi,
                        hat sich schon jemand mit dem shelly blu wall switch 4 bzw. dem shelly blu rc button 4
                        beschäftigt. Habe das v0.3-Script im Einsatz und empfange darüber auch payloads von den o.g. Devices, aber so wie es aussieht muss wohl das Script für die o.g. Devices angepasst werden.
                        Hat sich schon jemand damit beschäftigt und kann mir ggf. einen Tip geben - danke vorab !

                        haus-automatisierungH 1 Antwort Letzte Antwort
                        0
                        • R rolfs

                          Hi,
                          hat sich schon jemand mit dem shelly blu wall switch 4 bzw. dem shelly blu rc button 4
                          beschäftigt. Habe das v0.3-Script im Einsatz und empfange darüber auch payloads von den o.g. Devices, aber so wie es aussieht muss wohl das Script für die o.g. Devices angepasst werden.
                          Hat sich schon jemand damit beschäftigt und kann mir ggf. einen Tip geben - danke vorab !

                          haus-automatisierungH Online
                          haus-automatisierungH Online
                          haus-automatisierung
                          Developer Most Active
                          schrieb am zuletzt editiert von
                          #101

                          @rolfs Ist längst erledigt. Funktioniert mit der aktuellen Beta und dem neuesten Script

                          🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                          🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                          📚 Meine inoffizielle ioBroker Dokumentation

                          1 Antwort Letzte Antwort
                          0
                          • G Offline
                            G Offline
                            grandslam18
                            schrieb am zuletzt editiert von
                            #102

                            Hallo Community,

                            @haus-automatisierung, danke für das Script und die Anleitungen, ein Shelly Blu Button und ein Shelly Blu Button Tough kommen super in iobroker an, keine Probleme oder Abweichungen zu den Beschreibungen. Gedanklich seh ich mich schon mit Lokalisierungs-Use Cases spielen, aber dafür müsste ich viel mehr Empfänger (Plus Plugs o.Ä.) kaufen und das steht aktuell nicht dafür.

                            Vielleicht nur ein kleiner Gedankengang (teils dem Script, teils BT Home geschuldet): ist es aus Security-Sicht sinnvoll, das Script komplett transparent zu halten, ohne irgendwelche Pairing-Aktionen zwischen Buttons und Plugs? Was ich damit meine: ich hab meinen Tough Button nach Einrichtung aller Scripts usw. gekauft, FW mit der Debug App aktualisiert und der erste Tastendruck führt sofort zur Einrichtung der Datenpunkte in iobroker mit der MAC-Adresse des Buttons. Kein Pairing durch Shelly App oder sonst was nötig. Wenn mein Nachbar seinen Blu Button in Reichweite meiner Installation hat, wird der auch an Bord geholt, wenn ein Attacker N mac Adressen "simuliert" hab ich N Datenpunkte drin, etc...

                            Kann das über Einstellungen am Shelly unterbunden werden oder müsste das Script um ein Whitelisting erweitert werden? Bluetooth Einstellungen am Plug: Bluetooth, RPC und Bluetooth Gateway aktiviert.

                            Liebe Grüße!

                            haus-automatisierungH 1 Antwort Letzte Antwort
                            0
                            • G grandslam18

                              Hallo Community,

                              @haus-automatisierung, danke für das Script und die Anleitungen, ein Shelly Blu Button und ein Shelly Blu Button Tough kommen super in iobroker an, keine Probleme oder Abweichungen zu den Beschreibungen. Gedanklich seh ich mich schon mit Lokalisierungs-Use Cases spielen, aber dafür müsste ich viel mehr Empfänger (Plus Plugs o.Ä.) kaufen und das steht aktuell nicht dafür.

                              Vielleicht nur ein kleiner Gedankengang (teils dem Script, teils BT Home geschuldet): ist es aus Security-Sicht sinnvoll, das Script komplett transparent zu halten, ohne irgendwelche Pairing-Aktionen zwischen Buttons und Plugs? Was ich damit meine: ich hab meinen Tough Button nach Einrichtung aller Scripts usw. gekauft, FW mit der Debug App aktualisiert und der erste Tastendruck führt sofort zur Einrichtung der Datenpunkte in iobroker mit der MAC-Adresse des Buttons. Kein Pairing durch Shelly App oder sonst was nötig. Wenn mein Nachbar seinen Blu Button in Reichweite meiner Installation hat, wird der auch an Bord geholt, wenn ein Attacker N mac Adressen "simuliert" hab ich N Datenpunkte drin, etc...

                              Kann das über Einstellungen am Shelly unterbunden werden oder müsste das Script um ein Whitelisting erweitert werden? Bluetooth Einstellungen am Plug: Bluetooth, RPC und Bluetooth Gateway aktiviert.

                              Liebe Grüße!

                              haus-automatisierungH Online
                              haus-automatisierungH Online
                              haus-automatisierung
                              Developer Most Active
                              schrieb am zuletzt editiert von
                              #103

                              @matthiasb85 sagte in Shelly >= 6.6.0 mit BLU-Geräten (Bluetooth Low Energy):

                              Kann das über Einstellungen am Shelly unterbunden werden oder müsste das Script um ein Whitelisting erweitert werden?

                              Könnte man schon machen. Auch im Adapter. Aber was hilft Dir das bei dem Szenario?

                              Richtig wäre, encryption auf den BLE-Geräten zu aktivieren. Aber da findet man keine Infos, wie genau das mit dem Pairing und den Schlüsseln ablaufen muss. Ich nutze die BLE-Komponenten nicht, und bin da nicht so hinterher.

                              Wenn Du ein funktionierendes Beispiel mit aktiver encryption hast, implementiere ich das aber gern.

                              🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                              🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                              📚 Meine inoffizielle ioBroker Dokumentation

                              G 1 Antwort Letzte Antwort
                              0
                              • haus-automatisierungH haus-automatisierung

                                @matthiasb85 sagte in Shelly >= 6.6.0 mit BLU-Geräten (Bluetooth Low Energy):

                                Kann das über Einstellungen am Shelly unterbunden werden oder müsste das Script um ein Whitelisting erweitert werden?

                                Könnte man schon machen. Auch im Adapter. Aber was hilft Dir das bei dem Szenario?

                                Richtig wäre, encryption auf den BLE-Geräten zu aktivieren. Aber da findet man keine Infos, wie genau das mit dem Pairing und den Schlüsseln ablaufen muss. Ich nutze die BLE-Komponenten nicht, und bin da nicht so hinterher.

                                Wenn Du ein funktionierendes Beispiel mit aktiver encryption hast, implementiere ich das aber gern.

                                G Offline
                                G Offline
                                grandslam18
                                schrieb am zuletzt editiert von
                                #104

                                @haus-automatisierung
                                Mir geht's an sich nur darum rogue devices vom Netzwerk / iobroker fern zu halten, welches Mittel auch immer das Richtige ist. Bin aber weder BLE- noch Security Experte um dazu eine qualifizierte Meinung zu haben, wie man Fremdgeräte am besten draußen hält. Ich versuch mich mal in die Encryption einzulesen und schaue mir auch an, wie das in anderen veröffentlichten Scripts gelöst ist, die ShellyBlu zu MQTT umsetzen.

                                haus-automatisierungH 1 Antwort Letzte Antwort
                                0
                                • G grandslam18

                                  @haus-automatisierung
                                  Mir geht's an sich nur darum rogue devices vom Netzwerk / iobroker fern zu halten, welches Mittel auch immer das Richtige ist. Bin aber weder BLE- noch Security Experte um dazu eine qualifizierte Meinung zu haben, wie man Fremdgeräte am besten draußen hält. Ich versuch mich mal in die Encryption einzulesen und schaue mir auch an, wie das in anderen veröffentlichten Scripts gelöst ist, die ShellyBlu zu MQTT umsetzen.

                                  haus-automatisierungH Online
                                  haus-automatisierungH Online
                                  haus-automatisierung
                                  Developer Most Active
                                  schrieb am zuletzt editiert von
                                  #105

                                  @matthiasb85 sagte in Shelly >= 6.6.0 mit BLU-Geräten (Bluetooth Low Energy):

                                  und schaue mir auch an, wie das in anderen veröffentlichten Scripts gelöst ist

                                  Ich kenne kein Beispiel, was mit aktivierter Encryption arbeitet.

                                  🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                                  🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                                  📚 Meine inoffizielle ioBroker Dokumentation

                                  1 Antwort Letzte Antwort
                                  0
                                  • haus-automatisierungH haus-automatisierung

                                    @joesch80 Na die Lösung bzw das Problem hatte ich in meiner ersten Antwort ja schon genannt. Keine Ahnung warum das bei dir anders ist mit der gleichen Firmware.

                                    Man müsste also in der nächsten Version des Scripts mal alles hinzufügen was das Protokoll kann. Nur fehlt mir dafür die Zeit aktuell.

                                    A Offline
                                    A Offline
                                    Accuface
                                    schrieb am zuletzt editiert von
                                    #106

                                    @haus-automatisierung

                                    Erst mal.....vielen Dank für das Script.

                                    Ich hab seid Sonntagabend 3x Shelly blu Door/Window im Einsatz.

                                    Eingebunden mit deinem Script über einen PM.

                                    Wozu dient die Angabe in dem Bild?
                                    Muss dass noch eingefügt werden, wenn ja, wo genau?

                                    payload DW.png

                                    haus-automatisierungH 1 Antwort Letzte Antwort
                                    0
                                    • A Accuface

                                      @haus-automatisierung

                                      Erst mal.....vielen Dank für das Script.

                                      Ich hab seid Sonntagabend 3x Shelly blu Door/Window im Einsatz.

                                      Eingebunden mit deinem Script über einen PM.

                                      Wozu dient die Angabe in dem Bild?
                                      Muss dass noch eingefügt werden, wenn ja, wo genau?

                                      payload DW.png

                                      haus-automatisierungH Online
                                      haus-automatisierungH Online
                                      haus-automatisierung
                                      Developer Most Active
                                      schrieb am zuletzt editiert von
                                      #107

                                      @accuface Nur zur Info. Die Schritte im YouTube Video sind noch aktuell

                                      🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                                      🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                                      📚 Meine inoffizielle ioBroker Dokumentation

                                      A 1 Antwort Letzte Antwort
                                      0
                                      • haus-automatisierungH haus-automatisierung

                                        @accuface Nur zur Info. Die Schritte im YouTube Video sind noch aktuell

                                        A Offline
                                        A Offline
                                        Accuface
                                        schrieb am zuletzt editiert von Accuface
                                        #108

                                        @haus-automatisierung said in Shelly >= 6.6.0 mit BLU-Geräten (Bluetooth Low Energy):

                                        @accuface Nur zur Info. Die Schritte im YouTube Video sind noch aktuell

                                        hab ich dann wohl gekonnt übersehen. sry.

                                        schau ich sofort nochmal an.

                                        Danke

                                        EDIT:

                                        Ich hab in dem Video nix gesehen dass du den Code aus meinem Bild irgendwo verwendet hast.

                                        Nur um sicher zu gehen, die Installation der Bluetooth Paket benötige ich NUR wenn ich über den Stick und den BLE Adapter gehe, richtig?

                                        haus-automatisierungH 1 Antwort Letzte Antwort
                                        0
                                        • A Accuface

                                          @haus-automatisierung said in Shelly >= 6.6.0 mit BLU-Geräten (Bluetooth Low Energy):

                                          @accuface Nur zur Info. Die Schritte im YouTube Video sind noch aktuell

                                          hab ich dann wohl gekonnt übersehen. sry.

                                          schau ich sofort nochmal an.

                                          Danke

                                          EDIT:

                                          Ich hab in dem Video nix gesehen dass du den Code aus meinem Bild irgendwo verwendet hast.

                                          Nur um sicher zu gehen, die Installation der Bluetooth Paket benötige ich NUR wenn ich über den Stick und den BLE Adapter gehe, richtig?

                                          haus-automatisierungH Online
                                          haus-automatisierungH Online
                                          haus-automatisierung
                                          Developer Most Active
                                          schrieb am zuletzt editiert von
                                          #109

                                          @accuface sagte in Shelly >= 6.6.0 mit BLU-Geräten (Bluetooth Low Energy):

                                          Ich hab in dem Video nix gesehen dass du den Code aus meinem Bild irgendwo verwendet hast.

                                          Na guck. Daher eben der Hinweis, dass das da nur zur Info steht (was genau intern ankommt).

                                          Nur um sicher zu gehen, die Installation der Bluetooth Paket benötige ich NUR wenn ich über den Stick und den BLE Adapter gehe, richtig?

                                          Richtig

                                          🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                                          🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                                          📚 Meine inoffizielle ioBroker Dokumentation

                                          A 2 Antworten Letzte Antwort
                                          0
                                          Antworten
                                          • In einem neuen Thema antworten
                                          Anmelden zum Antworten
                                          • Älteste zuerst
                                          • Neuste zuerst
                                          • Meiste Stimmen


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          668

                                          Online

                                          32.5k

                                          Benutzer

                                          81.8k

                                          Themen

                                          1.3m

                                          Beiträge
                                          Community
                                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                                          ioBroker Community 2014-2025
                                          logo
                                          • Anmelden

                                          • Du hast noch kein Konto? Registrieren

                                          • Anmelden oder registrieren, um zu suchen
                                          • Erster Beitrag
                                            Letzter Beitrag
                                          0
                                          • Home
                                          • Aktuell
                                          • Tags
                                          • Ungelesen 0
                                          • Kategorien
                                          • Unreplied
                                          • Beliebt
                                          • GitHub
                                          • Docu
                                          • Hilfe