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

  1. ioBroker Community Home
  2. Deutsch
  3. Tester
  4. Test Adapter Philips-TV v0.2.x

NEWS

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

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    1.9k

  • Neues Video "KI im Smart Home" - ioBroker plus n8n
    BluefoxB
    Bluefox
    15
    1
    2.2k

Test Adapter Philips-TV v0.2.x

Geplant Angeheftet Gesperrt Verschoben Tester
philipsphilips tv
550 Beiträge 84 Kommentatoren 142.0k Aufrufe 48 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.
  • MicM Offline
    MicM Offline
    Mic
    Developer
    schrieb am zuletzt editiert von Mic
    #206

    Hier noch ein Update meines Test-Scripts. Es legt einen Datenpunkt unter "javascript.0.PhilipsTV.MyScript" an, womit man den Philips-TV steuern kann. Eingebaut ist auch Einschalten von Netflix, Kodi und YouTube. Sicherlich einfach in den Adapter integrierbar :-)

    /*******************************************************************************
     * ---------------------------
     * Philips TV Script for ioBroker
     * ----------------------------------------------------
     * Version: 0.2
     * Autor: Mic
     * ----------------------------------------------------
     * Documentation:
     *  - Unofficial Philips TV API Reference: https://github.com/eslavnov/pylips/wiki
     *  - Some Info: https://community.openhab.org/t/philips-tv-2016-binding/64579/61
     *  - Python Script with MQTT support: https://github.com/eslavnov/pylips
     *  - ioBroker Philips TV Adapter: https://forum.iobroker.net/topic/8791/aufruf-philips-tv-v0-1-0-testen
     ******************************************************************************/
    
    /*******************************************************************************
     * Settings
     *******************************************************************************/
    // Pfad, unter dem die Objekte angelegt werden.
    const STATE_PATH = 'javascript.0.PhilipsTV.MyScript.';
    
    // Generate User/Password: see https://github.com/nstrelow/ha_philips_2016
    const PHILIPS_USER = 'xxxxxxxxxxxxxxxxxxxxxx';
    const PHILIPS_PASS = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
    
    // URL, change IP address accordingly (and you may also need to change port, see for example https://github.com/eslavnov/pylips)
    const PHILIPS_URL = 'https://xxx.xxx.xxx.xxx:1926/6/';
    
    const LOG_DEBUG = false;
    
    
    /*******************************************************************************
     * Expert Settings
     *******************************************************************************/
    // Hier definieren wir die einzelnen Commands. 
    let pCommands = [];
    //        0.Command Name                       1.Path              2. curl Command      
    pCommands['Cmd: Ambilight Off']             = ['ambilight/power',   '{"power":"Off"}'];
    pCommands['Cmd: Ambilight On']              = ['ambilight/power',   '{"power":"On"}'];
    pCommands['Cmd: Ambilight On Video Standard'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"STANDARD"}'];
    pCommands['Cmd: Ambilight On Video Immersive'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"IMMERSIVE"}'];
    pCommands['Cmd: Ambilight On Video Natural'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"NATURAL"}'];
    pCommands['Cmd: Ambilight On Video Vivid'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"VIVID"}'];
    pCommands['Cmd: Ambilight On Video Game'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"GAME"}'];
    pCommands['Cmd: Ambilight On Video Comfort'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"COMFORT"}'];
    pCommands['Cmd: Ambilight On Video Relax'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"RELAX"}'];
    pCommands['Launch: Netflix'] = ['activities/launch',   '{"id":"com.netflix.ninja","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.netflix.ninja }","component":{"packageName":"com.netflix.ninja","className":"com.netflix.ninja.MainActivity"}},"label":"Netflix"}'];
    pCommands['Launch: Kodi'] = ['activities/launch',   '{"id":"org.xbmc.kodi","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=org.xbmc.kodi }","component":{"packageName":"org.xbmc.kodi","className":"org.xbmc.kodi.Splash"}},"label":"Kodi"}'];
    pCommands['Launch: YouTube'] = ['activities/launch',   '{"id":"com.google.android.apps.youtube.tv.activity.ShellActivity-com.google.android.youtube.tv","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.google.android.youtube.tv cmp=com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity }","component":{"packageName":"com.google.android.youtube.tv","className":"com.google.android.apps.youtube.tv.activity.ShellActivity"}},"label":"YouTube"}'];
    pCommands['Key: Adjust']  = ['input/key',   '{"key":"Adjust"}'];
    pCommands['Key: AmbilightOnOff']  = ['input/key',   '{"key":"AmbilightOnOff"}'];
    pCommands['Key: Back']  = ['input/key',   '{"key":"Back"}'];
    pCommands['Key: BlueColour']  = ['input/key',   '{"key":"BlueColour"}'];
    pCommands['Key: ChannelStepDown']  = ['input/key',   '{"key":"ChannelStepDown"}'];
    pCommands['Key: ChannelStepUp']  = ['input/key',   '{"key":"ChannelStepUp"}'];
    pCommands['Key: Confirm']  = ['input/key',   '{"key":"Confirm"}'];
    pCommands['Key: CursorDown']  = ['input/key',   '{"key":"CursorDown"}'];
    pCommands['Key: CursorLeft']  = ['input/key',   '{"key":"CursorLeft"}'];
    pCommands['Key: CursorRight']  = ['input/key',   '{"key":"CursorRight"}'];
    pCommands['Key: CursorUp']  = ['input/key',   '{"key":"CursorUp"}'];
    pCommands['Key: Digit0']  = ['input/key',   '{"key":"Digit0"}'];
    pCommands['Key: Digit1']  = ['input/key',   '{"key":"Digit1"}'];
    pCommands['Key: Digit2']  = ['input/key',   '{"key":"Digit2"}'];
    pCommands['Key: Digit3']  = ['input/key',   '{"key":"Digit3"}'];
    pCommands['Key: Digit4']  = ['input/key',   '{"key":"Digit4"}'];
    pCommands['Key: Digit5']  = ['input/key',   '{"key":"Digit5"}'];
    pCommands['Key: Digit6']  = ['input/key',   '{"key":"Digit6"}'];
    pCommands['Key: Digit7']  = ['input/key',   '{"key":"Digit7"}'];
    pCommands['Key: Digit8']  = ['input/key',   '{"key":"Digit8"}'];
    pCommands['Key: Digit9']  = ['input/key',   '{"key":"Digit9"}'];
    pCommands['Key: Dot']  = ['input/key',   '{"key":"Dot"}'];
    pCommands['Key: FastForward']  = ['input/key',   '{"key":"FastForward"}'];
    pCommands['Key: Find']  = ['input/key',   '{"key":"Find"}'];
    pCommands['Key: GreenColour']  = ['input/key',   '{"key":"GreenColour"}'];
    pCommands['Key: Home']  = ['input/key',   '{"key":"Home"}'];
    pCommands['Key: Info']  = ['input/key',   '{"key":"Info"}'];
    pCommands['Key: Mute']  = ['input/key',   '{"key":"Mute"}'];
    pCommands['Key: Next']  = ['input/key',   '{"key":"Next"}'];
    pCommands['Key: Online']  = ['input/key',   '{"key":"Online"}'];
    pCommands['Key: Options']  = ['input/key',   '{"key":"Options"}'];
    pCommands['Key: Pause']  = ['input/key',   '{"key":"Pause"}'];
    pCommands['Key: Play']  = ['input/key',   '{"key":"Play"}'];
    pCommands['Key: PlayPause']  = ['input/key',   '{"key":"PlayPause"}'];
    pCommands['Key: Previous']  = ['input/key',   '{"key":"Previous"}'];
    pCommands['Key: Record']  = ['input/key',   '{"key":"Record"}'];
    pCommands['Key: RedColour']  = ['input/key',   '{"key":"RedColour"}'];
    pCommands['Key: Rewind']  = ['input/key',   '{"key":"Rewind"}'];
    pCommands['Key: Source']  = ['input/key',   '{"key":"Source"}'];
    pCommands['Key: Standby']  = ['input/key',   '{"key":"Standby"}'];
    pCommands['Key: Stop']  = ['input/key',   '{"key":"Stop"}'];
    pCommands['Key: Subtitle']  = ['input/key',   '{"key":"Subtitle"}'];
    pCommands['Key: Teletext']  = ['input/key',   '{"key":"Teletext"}'];
    pCommands['Key: Viewmode']  = ['input/key',   '{"key":"Viewmode"}'];
    pCommands['Key: VolumeDown']  = ['input/key',   '{"key":"VolumeDown"}'];
    pCommands['Key: VolumeUp']  = ['input/key',   '{"key":"VolumeUp"}'];
    pCommands['Key: WatchTV']  = ['input/key',   '{"key":"WatchTV"}'];
    pCommands['Key: YellowColour']  = ['input/key',   '{"key":"YellowColour"}'];
    
    
    /*******************************************************************************
     * Ab hier nichts mehr ändern / Stop editing here!
     ******************************************************************************/
    
    
    /*******************************************************************************
     * Initiale Function
     *******************************************************************************/
    init();
    function init() {
        
        // 1. Create states
        createScriptStates();
    
        // 2. Schedule
        on({id: STATE_PATH + 'Command', change:'any'}, function (obj) {
            doExec(obj.state.val);
        });
    }
    
    function doExec(id) {
        if (id in pCommands) { // Check if Key exists and typed correctly - https://stackoverflow.com/questions/1098040/checking-if-a-key-exists-in-a-javascript-object
            var exec = require('child_process').exec;
            var args = "-X POST --digest --insecure -u " + PHILIPS_USER + ":" + PHILIPS_PASS + " -d '" + pCommands[id][1] + "' " + PHILIPS_URL + pCommands[id][0];
            exec('curl ' + args, function (error, stdout, stderr) {
                if (LOG_DEBUG) log('stdout: ' + stdout);
                if (LOG_DEBUG) log('stderr: ' + stderr);
                if (error !== null) {
                    log('exec error: ' + error);
                }
            });
        } else if(id == '') {
            // do nothing, will be empty if script is initally started or user did not select value
        } else {
            log('Wrong command provided to Philips TV: [' + id + ']', 'warn');
        }
    }
    
    function createScriptStates() {
        // create drop-down list
        let dropdown = '';
        for (let lpEntry of Object.keys(pCommands)) {   // 'special' loop here to get the keys
            dropdown += '"' + lpEntry + '":"' + lpEntry + '",'; // fill JSON string
        }
        dropdown = dropdown.substr(0, dropdown.length-1); // remove last comma ","
        dropdown = '{' + dropdown + '}'; // finalize JSON string
        let dropdownJSON = JSON.parse(dropdown); // convert to JSON
        // Create state. Force is set to true, so we will always update the states if e.g. configuration in this script changed.
        createState(STATE_PATH + 'Command', '', true, {
            'name':'Command', 
            'type':'string', 
            'read':false, 
            'write':true, 
            'role':'value', 
            'states': dropdownJSON
        });
    }
    
    

    Achtung:

    Update: aktuelles Script siehe auf Github.

    S B 2 Antworten Letzte Antwort
    1
    • MicM Mic

      Hier noch ein Update meines Test-Scripts. Es legt einen Datenpunkt unter "javascript.0.PhilipsTV.MyScript" an, womit man den Philips-TV steuern kann. Eingebaut ist auch Einschalten von Netflix, Kodi und YouTube. Sicherlich einfach in den Adapter integrierbar :-)

      /*******************************************************************************
       * ---------------------------
       * Philips TV Script for ioBroker
       * ----------------------------------------------------
       * Version: 0.2
       * Autor: Mic
       * ----------------------------------------------------
       * Documentation:
       *  - Unofficial Philips TV API Reference: https://github.com/eslavnov/pylips/wiki
       *  - Some Info: https://community.openhab.org/t/philips-tv-2016-binding/64579/61
       *  - Python Script with MQTT support: https://github.com/eslavnov/pylips
       *  - ioBroker Philips TV Adapter: https://forum.iobroker.net/topic/8791/aufruf-philips-tv-v0-1-0-testen
       ******************************************************************************/
      
      /*******************************************************************************
       * Settings
       *******************************************************************************/
      // Pfad, unter dem die Objekte angelegt werden.
      const STATE_PATH = 'javascript.0.PhilipsTV.MyScript.';
      
      // Generate User/Password: see https://github.com/nstrelow/ha_philips_2016
      const PHILIPS_USER = 'xxxxxxxxxxxxxxxxxxxxxx';
      const PHILIPS_PASS = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
      
      // URL, change IP address accordingly (and you may also need to change port, see for example https://github.com/eslavnov/pylips)
      const PHILIPS_URL = 'https://xxx.xxx.xxx.xxx:1926/6/';
      
      const LOG_DEBUG = false;
      
      
      /*******************************************************************************
       * Expert Settings
       *******************************************************************************/
      // Hier definieren wir die einzelnen Commands. 
      let pCommands = [];
      //        0.Command Name                       1.Path              2. curl Command      
      pCommands['Cmd: Ambilight Off']             = ['ambilight/power',   '{"power":"Off"}'];
      pCommands['Cmd: Ambilight On']              = ['ambilight/power',   '{"power":"On"}'];
      pCommands['Cmd: Ambilight On Video Standard'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"STANDARD"}'];
      pCommands['Cmd: Ambilight On Video Immersive'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"IMMERSIVE"}'];
      pCommands['Cmd: Ambilight On Video Natural'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"NATURAL"}'];
      pCommands['Cmd: Ambilight On Video Vivid'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"VIVID"}'];
      pCommands['Cmd: Ambilight On Video Game'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"GAME"}'];
      pCommands['Cmd: Ambilight On Video Comfort'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"COMFORT"}'];
      pCommands['Cmd: Ambilight On Video Relax'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"RELAX"}'];
      pCommands['Launch: Netflix'] = ['activities/launch',   '{"id":"com.netflix.ninja","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.netflix.ninja }","component":{"packageName":"com.netflix.ninja","className":"com.netflix.ninja.MainActivity"}},"label":"Netflix"}'];
      pCommands['Launch: Kodi'] = ['activities/launch',   '{"id":"org.xbmc.kodi","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=org.xbmc.kodi }","component":{"packageName":"org.xbmc.kodi","className":"org.xbmc.kodi.Splash"}},"label":"Kodi"}'];
      pCommands['Launch: YouTube'] = ['activities/launch',   '{"id":"com.google.android.apps.youtube.tv.activity.ShellActivity-com.google.android.youtube.tv","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.google.android.youtube.tv cmp=com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity }","component":{"packageName":"com.google.android.youtube.tv","className":"com.google.android.apps.youtube.tv.activity.ShellActivity"}},"label":"YouTube"}'];
      pCommands['Key: Adjust']  = ['input/key',   '{"key":"Adjust"}'];
      pCommands['Key: AmbilightOnOff']  = ['input/key',   '{"key":"AmbilightOnOff"}'];
      pCommands['Key: Back']  = ['input/key',   '{"key":"Back"}'];
      pCommands['Key: BlueColour']  = ['input/key',   '{"key":"BlueColour"}'];
      pCommands['Key: ChannelStepDown']  = ['input/key',   '{"key":"ChannelStepDown"}'];
      pCommands['Key: ChannelStepUp']  = ['input/key',   '{"key":"ChannelStepUp"}'];
      pCommands['Key: Confirm']  = ['input/key',   '{"key":"Confirm"}'];
      pCommands['Key: CursorDown']  = ['input/key',   '{"key":"CursorDown"}'];
      pCommands['Key: CursorLeft']  = ['input/key',   '{"key":"CursorLeft"}'];
      pCommands['Key: CursorRight']  = ['input/key',   '{"key":"CursorRight"}'];
      pCommands['Key: CursorUp']  = ['input/key',   '{"key":"CursorUp"}'];
      pCommands['Key: Digit0']  = ['input/key',   '{"key":"Digit0"}'];
      pCommands['Key: Digit1']  = ['input/key',   '{"key":"Digit1"}'];
      pCommands['Key: Digit2']  = ['input/key',   '{"key":"Digit2"}'];
      pCommands['Key: Digit3']  = ['input/key',   '{"key":"Digit3"}'];
      pCommands['Key: Digit4']  = ['input/key',   '{"key":"Digit4"}'];
      pCommands['Key: Digit5']  = ['input/key',   '{"key":"Digit5"}'];
      pCommands['Key: Digit6']  = ['input/key',   '{"key":"Digit6"}'];
      pCommands['Key: Digit7']  = ['input/key',   '{"key":"Digit7"}'];
      pCommands['Key: Digit8']  = ['input/key',   '{"key":"Digit8"}'];
      pCommands['Key: Digit9']  = ['input/key',   '{"key":"Digit9"}'];
      pCommands['Key: Dot']  = ['input/key',   '{"key":"Dot"}'];
      pCommands['Key: FastForward']  = ['input/key',   '{"key":"FastForward"}'];
      pCommands['Key: Find']  = ['input/key',   '{"key":"Find"}'];
      pCommands['Key: GreenColour']  = ['input/key',   '{"key":"GreenColour"}'];
      pCommands['Key: Home']  = ['input/key',   '{"key":"Home"}'];
      pCommands['Key: Info']  = ['input/key',   '{"key":"Info"}'];
      pCommands['Key: Mute']  = ['input/key',   '{"key":"Mute"}'];
      pCommands['Key: Next']  = ['input/key',   '{"key":"Next"}'];
      pCommands['Key: Online']  = ['input/key',   '{"key":"Online"}'];
      pCommands['Key: Options']  = ['input/key',   '{"key":"Options"}'];
      pCommands['Key: Pause']  = ['input/key',   '{"key":"Pause"}'];
      pCommands['Key: Play']  = ['input/key',   '{"key":"Play"}'];
      pCommands['Key: PlayPause']  = ['input/key',   '{"key":"PlayPause"}'];
      pCommands['Key: Previous']  = ['input/key',   '{"key":"Previous"}'];
      pCommands['Key: Record']  = ['input/key',   '{"key":"Record"}'];
      pCommands['Key: RedColour']  = ['input/key',   '{"key":"RedColour"}'];
      pCommands['Key: Rewind']  = ['input/key',   '{"key":"Rewind"}'];
      pCommands['Key: Source']  = ['input/key',   '{"key":"Source"}'];
      pCommands['Key: Standby']  = ['input/key',   '{"key":"Standby"}'];
      pCommands['Key: Stop']  = ['input/key',   '{"key":"Stop"}'];
      pCommands['Key: Subtitle']  = ['input/key',   '{"key":"Subtitle"}'];
      pCommands['Key: Teletext']  = ['input/key',   '{"key":"Teletext"}'];
      pCommands['Key: Viewmode']  = ['input/key',   '{"key":"Viewmode"}'];
      pCommands['Key: VolumeDown']  = ['input/key',   '{"key":"VolumeDown"}'];
      pCommands['Key: VolumeUp']  = ['input/key',   '{"key":"VolumeUp"}'];
      pCommands['Key: WatchTV']  = ['input/key',   '{"key":"WatchTV"}'];
      pCommands['Key: YellowColour']  = ['input/key',   '{"key":"YellowColour"}'];
      
      
      /*******************************************************************************
       * Ab hier nichts mehr ändern / Stop editing here!
       ******************************************************************************/
      
      
      /*******************************************************************************
       * Initiale Function
       *******************************************************************************/
      init();
      function init() {
          
          // 1. Create states
          createScriptStates();
      
          // 2. Schedule
          on({id: STATE_PATH + 'Command', change:'any'}, function (obj) {
              doExec(obj.state.val);
          });
      }
      
      function doExec(id) {
          if (id in pCommands) { // Check if Key exists and typed correctly - https://stackoverflow.com/questions/1098040/checking-if-a-key-exists-in-a-javascript-object
              var exec = require('child_process').exec;
              var args = "-X POST --digest --insecure -u " + PHILIPS_USER + ":" + PHILIPS_PASS + " -d '" + pCommands[id][1] + "' " + PHILIPS_URL + pCommands[id][0];
              exec('curl ' + args, function (error, stdout, stderr) {
                  if (LOG_DEBUG) log('stdout: ' + stdout);
                  if (LOG_DEBUG) log('stderr: ' + stderr);
                  if (error !== null) {
                      log('exec error: ' + error);
                  }
              });
          } else if(id == '') {
              // do nothing, will be empty if script is initally started or user did not select value
          } else {
              log('Wrong command provided to Philips TV: [' + id + ']', 'warn');
          }
      }
      
      function createScriptStates() {
          // create drop-down list
          let dropdown = '';
          for (let lpEntry of Object.keys(pCommands)) {   // 'special' loop here to get the keys
              dropdown += '"' + lpEntry + '":"' + lpEntry + '",'; // fill JSON string
          }
          dropdown = dropdown.substr(0, dropdown.length-1); // remove last comma ","
          dropdown = '{' + dropdown + '}'; // finalize JSON string
          let dropdownJSON = JSON.parse(dropdown); // convert to JSON
          // Create state. Force is set to true, so we will always update the states if e.g. configuration in this script changed.
          createState(STATE_PATH + 'Command', '', true, {
              'name':'Command', 
              'type':'string', 
              'read':false, 
              'write':true, 
              'role':'value', 
              'states': dropdownJSON
          });
      }
      
      

      Achtung:

      Update: aktuelles Script siehe auf Github.

      S Offline
      S Offline
      Stormbringer
      schrieb am zuletzt editiert von
      #207

      @Mic
      Mit dem Skript habe ich auch schon experimentiert. Nur leider waren meine Linux Kenntnisse zu schwach um es zum laufen zu bekommen. Ich löse das aus und einschalten vom Ambilight jetzt per CURL Befehl. Kennst du dich zufällig damit auch aus und weißt wie der richtige Befehl geht um Ambi und Hue aus und einzuschalten?

      Grundlage war die Seite

      https://gist.github.com/marcelrv/ee9a7cf97c227d069e4ee88d26691019

      Angaben zur Installation: JS Controller 5.0.12, npm 9.6.7, node 18.17.1, auf einem Intel NUC mit Ubuntu 22.04

      1 Antwort Letzte Antwort
      0
      • MicM Offline
        MicM Offline
        Mic
        Developer
        schrieb am zuletzt editiert von
        #208

        @Stormbringer
        Das macht mein Script (siehe oben), dort ist curl integriert, das per JavaScript über ioBroker ausgeführt wird. Wo hast Du da denn Fragen?

        S 1 Antwort Letzte Antwort
        0
        • MicM Mic

          @Stormbringer
          Das macht mein Script (siehe oben), dort ist curl integriert, das per JavaScript über ioBroker ausgeführt wird. Wo hast Du da denn Fragen?

          S Offline
          S Offline
          Stormbringer
          schrieb am zuletzt editiert von
          #209

          @Mic ich hab Probleme das Pylips zum Laufen zu bringen. Ich steuere daher alles mit CURL Befehle aber der CURL Befehl für Ambi und Hue bekomm ich nicht hin.. Weißt du was ich mein?

          Angaben zur Installation: JS Controller 5.0.12, npm 9.6.7, node 18.17.1, auf einem Intel NUC mit Ubuntu 22.04

          MicM 1 Antwort Letzte Antwort
          0
          • S Stormbringer

            @Mic ich hab Probleme das Pylips zum Laufen zu bringen. Ich steuere daher alles mit CURL Befehle aber der CURL Befehl für Ambi und Hue bekomm ich nicht hin.. Weißt du was ich mein?

            MicM Offline
            MicM Offline
            Mic
            Developer
            schrieb am zuletzt editiert von
            #210

            @Stormbringer
            Schau Dir diese Referenz an: https://github.com/eslavnov/pylips/wiki
            Darauf basiert auch mein Javascript von oben.

            S 1 Antwort Letzte Antwort
            0
            • R Offline
              R Offline
              rrroli
              schrieb am zuletzt editiert von
              #211

              Hallo!
              Ich habe eine Frage zu den Custom Keypresses.
              Ich konnte den Adapter richtig einbinden und ich kann auch zB einen Wert für die Lautstärke zum Gerät schicken.
              Was ich irgendwie überhaupt nicht verstehe ist, wie ich zB die Quelle auswählen kann bzw. überhaupt Custom Befehle konfigurieren kann. Kann ich das über das WebInterface machen und wenn ja wie?

              Vielen Dank im Voraus.

              lg

              1 Antwort Letzte Antwort
              0
              • R Offline
                R Offline
                rrroli
                schrieb am zuletzt editiert von
                #212

                Hi,
                Kann mir jemand vielleicht einen Tip geben, wie man auf einen bestimmten HDMI Kanal (1,2,3,4) umschalten kann?
                Ich kann nur Source auswählen, was mir am TV die Übersicht anzeigt. Dort müsste ich dann aber mit den Cursortasten nutzen, was Kacke ist.

                Danke!

                MicM 1 Antwort Letzte Antwort
                0
                • R rrroli

                  Hi,
                  Kann mir jemand vielleicht einen Tip geben, wie man auf einen bestimmten HDMI Kanal (1,2,3,4) umschalten kann?
                  Ich kann nur Source auswählen, was mir am TV die Übersicht anzeigt. Dort müsste ich dann aber mit den Cursortasten nutzen, was Kacke ist.

                  Danke!

                  MicM Offline
                  MicM Offline
                  Mic
                  Developer
                  schrieb am zuletzt editiert von
                  #213

                  @rrroli sagte in [Aufruf] Philips-TV v0.1.0 testen:

                  Hi,
                  Kann mir jemand vielleicht einen Tip geben, wie man auf einen bestimmten HDMI Kanal (1,2,3,4) umschalten kann?
                  Ich kann nur Source auswählen, was mir am TV die Übersicht anzeigt. Dort müsste ich dann aber mit den Cursortasten nutzen, was Kacke ist.

                  Danke!

                  Findest Du hier eine Option? https://github.com/eslavnov/pylips/wiki
                  Wenn es dies dort gibt, dann sicherlich möglich.

                  R 1 Antwort Letzte Antwort
                  0
                  • MicM Mic

                    @rrroli sagte in [Aufruf] Philips-TV v0.1.0 testen:

                    Hi,
                    Kann mir jemand vielleicht einen Tip geben, wie man auf einen bestimmten HDMI Kanal (1,2,3,4) umschalten kann?
                    Ich kann nur Source auswählen, was mir am TV die Übersicht anzeigt. Dort müsste ich dann aber mit den Cursortasten nutzen, was Kacke ist.

                    Danke!

                    Findest Du hier eine Option? https://github.com/eslavnov/pylips/wiki
                    Wenn es dies dort gibt, dann sicherlich möglich.

                    R Offline
                    R Offline
                    rrroli
                    schrieb am zuletzt editiert von rrroli
                    #214

                    @Mic
                    Leider nein, dort gibt es nur Source, was mir eben nur die Auswahl am TV anzeigt.
                    Das hier http://jointspace.sourceforge.net/projectdata/documentation/jasonApi/1/doc/API-Method-sources-current-POST.html sieht besser aus denke ich.
                    Leider weiß ich nicht, wie ich das einbinden kann?

                    1 Antwort Letzte Antwort
                    0
                    • R Offline
                      R Offline
                      rrroli
                      schrieb am zuletzt editiert von
                      #215

                      Ok, ich habs hinbekommen. Zumindest so halb.
                      Mit curl -X POST -d '{"id":"hdmi1"}' http://192.168.x.y:1925/1/sources/current kann ich auf HDMI wechseln.
                      Wie und wo muss ich den Befehl jetzt eingeben, damit diesen, am besten per Knopfdruck, nutzen kann?

                      Danke

                      MicM 1 Antwort Letzte Antwort
                      0
                      • R rrroli

                        Ok, ich habs hinbekommen. Zumindest so halb.
                        Mit curl -X POST -d '{"id":"hdmi1"}' http://192.168.x.y:1925/1/sources/current kann ich auf HDMI wechseln.
                        Wie und wo muss ich den Befehl jetzt eingeben, damit diesen, am besten per Knopfdruck, nutzen kann?

                        Danke

                        MicM Offline
                        MicM Offline
                        Mic
                        Developer
                        schrieb am zuletzt editiert von
                        #216

                        @rrroli sagte in [Aufruf] Philips-TV v0.1.0 testen:

                        Ok, ich habs hinbekommen. Zumindest so halb.
                        Mit curl -X POST -d '{"id":"hdmi1"}' http://192.168.x.y:1925/1/sources/current kann ich auf HDMI wechseln.
                        Wie und wo muss ich den Befehl jetzt eingeben, damit diesen, am besten per Knopfdruck, nutzen kann?

                        Danke

                        Du könntest versuchen, das in meinem Testscript oben vom 6. Juni 2019, 00:05 einzubauen.

                        Also z.B. Zeile 97 einfügen:

                        pCommands['sources: HDMI 1']             = ['sources/current',   '{"id":"hdmi1"}'];
                        

                        Dann solltest Du das über den Datenpunkt "javascript.0.PhilipsTV.MyScript.Command" die neue Option 'sources: HDMI 1' auswählen können und damit im VIS einfach einen Knopf einbinden.
                        Achtung: ungetestet von mir, sondern nur hier runter geschrieben ;)

                        R 1 Antwort Letzte Antwort
                        0
                        • MicM Offline
                          MicM Offline
                          Mic
                          Developer
                          schrieb am zuletzt editiert von
                          #217

                          @rrroli
                          Ok, mein Weg scheint mit neueren APIs nicht zu funktionieren, bei mir jedenfalls nicht: https://github.com/eslavnov/pylips/issues/3

                          Aber Du kannst es mit meinem Script mal testen, ggf. entsprechend umstellen in PHILIPS_URL Konstante.

                          1 Antwort Letzte Antwort
                          0
                          • MicM Mic

                            @rrroli sagte in [Aufruf] Philips-TV v0.1.0 testen:

                            Ok, ich habs hinbekommen. Zumindest so halb.
                            Mit curl -X POST -d '{"id":"hdmi1"}' http://192.168.x.y:1925/1/sources/current kann ich auf HDMI wechseln.
                            Wie und wo muss ich den Befehl jetzt eingeben, damit diesen, am besten per Knopfdruck, nutzen kann?

                            Danke

                            Du könntest versuchen, das in meinem Testscript oben vom 6. Juni 2019, 00:05 einzubauen.

                            Also z.B. Zeile 97 einfügen:

                            pCommands['sources: HDMI 1']             = ['sources/current',   '{"id":"hdmi1"}'];
                            

                            Dann solltest Du das über den Datenpunkt "javascript.0.PhilipsTV.MyScript.Command" die neue Option 'sources: HDMI 1' auswählen können und damit im VIS einfach einen Knopf einbinden.
                            Achtung: ungetestet von mir, sondern nur hier runter geschrieben ;)

                            R Offline
                            R Offline
                            rrroli
                            schrieb am zuletzt editiert von
                            #218

                            @Mic said in [Aufruf] Philips-TV v0.1.0 testen:

                            @rrroli sagte in [Aufruf] Philips-TV v0.1.0 testen:

                            Ok, ich habs hinbekommen. Zumindest so halb.
                            Mit curl -X POST -d '{"id":"hdmi1"}' http://192.168.x.y:1925/1/sources/current kann ich auf HDMI wechseln.
                            Wie und wo muss ich den Befehl jetzt eingeben, damit diesen, am besten per Knopfdruck, nutzen kann?

                            Danke

                            Du könntest versuchen, das in meinem Testscript oben vom 6. Juni 2019, 00:05 einzubauen.

                            Also z.B. Zeile 97 einfügen:

                            pCommands['sources: HDMI 1']             = ['sources/current',   '{"id":"hdmi1"}'];
                            

                            Dann solltest Du das über den Datenpunkt "javascript.0.PhilipsTV.MyScript.Command" die neue Option 'sources: HDMI 1' auswählen können und damit im VIS einfach einen Knopf einbinden.
                            Achtung: ungetestet von mir, sondern nur hier runter geschrieben ;)

                            Hallo,

                            Danke für deine Antwort!
                            Dazu muss ich dann vorher das pylips zu iobroker hinzufügen, oder?

                            MicM 1 Antwort Letzte Antwort
                            0
                            • R rrroli

                              @Mic said in [Aufruf] Philips-TV v0.1.0 testen:

                              @rrroli sagte in [Aufruf] Philips-TV v0.1.0 testen:

                              Ok, ich habs hinbekommen. Zumindest so halb.
                              Mit curl -X POST -d '{"id":"hdmi1"}' http://192.168.x.y:1925/1/sources/current kann ich auf HDMI wechseln.
                              Wie und wo muss ich den Befehl jetzt eingeben, damit diesen, am besten per Knopfdruck, nutzen kann?

                              Danke

                              Du könntest versuchen, das in meinem Testscript oben vom 6. Juni 2019, 00:05 einzubauen.

                              Also z.B. Zeile 97 einfügen:

                              pCommands['sources: HDMI 1']             = ['sources/current',   '{"id":"hdmi1"}'];
                              

                              Dann solltest Du das über den Datenpunkt "javascript.0.PhilipsTV.MyScript.Command" die neue Option 'sources: HDMI 1' auswählen können und damit im VIS einfach einen Knopf einbinden.
                              Achtung: ungetestet von mir, sondern nur hier runter geschrieben ;)

                              Hallo,

                              Danke für deine Antwort!
                              Dazu muss ich dann vorher das pylips zu iobroker hinzufügen, oder?

                              MicM Offline
                              MicM Offline
                              Mic
                              Developer
                              schrieb am zuletzt editiert von
                              #219

                              Danke für deine Antwort!
                              Dazu muss ich dann vorher das pylips zu iobroker hinzufügen, oder?

                              Nein, pylips wird hier nicht benötigt. Aber du musst im JavaScript-Adapter javascript.0 in den Einstellungen den Haken bei "Erlaube das Kommando 'exec'" setzen. Das Script setzt nämlich dann über exec einen curl-Befehl ab. Damit hast Du das also im ioBroker integriert.

                              R 1 Antwort Letzte Antwort
                              0
                              • MicM Mic

                                Danke für deine Antwort!
                                Dazu muss ich dann vorher das pylips zu iobroker hinzufügen, oder?

                                Nein, pylips wird hier nicht benötigt. Aber du musst im JavaScript-Adapter javascript.0 in den Einstellungen den Haken bei "Erlaube das Kommando 'exec'" setzen. Das Script setzt nämlich dann über exec einen curl-Befehl ab. Damit hast Du das also im ioBroker integriert.

                                R Offline
                                R Offline
                                rrroli
                                schrieb am zuletzt editiert von
                                #220

                                Geil, es funktioniert. Ich musste nur das Curl Kommando leicht anpassen.

                                Danke @Mic! Ohne Dich hätt ich das nicht geschafft.

                                1 Antwort Letzte Antwort
                                0
                                • R Offline
                                  R Offline
                                  rrroli
                                  schrieb am zuletzt editiert von
                                  #221

                                  Hi,

                                  jetzt muss ich noch etwas fragen, wo ich noch nichtgenau weiß, wie ich das am besten mache.
                                  Und zwar würde ich gerne per simulierten Buttondruck oder was eben sonst noch klug wäre, den HDMI Kanal auf 1,2,3, .. wechseln, also quasi den Wert "sources: HDMI1" übergeben.
                                  Wie kann ich denn am geschicktesten so etwas realisieren?
                                  Ich könnte ja das Script von Mic kopieren, alle Werte, welche ich nicht brauche löschen und als solches dann laufen lassen.
                                  Irgendwie kommt mir dass aber etwas zu umständlich vor?

                                  Jemand nen Plan wie man das sonst machen könnte?

                                  Danke!

                                  1 Antwort Letzte Antwort
                                  0
                                  • MicM Offline
                                    MicM Offline
                                    Mic
                                    Developer
                                    schrieb am zuletzt editiert von Mic
                                    #222

                                    @rrroli
                                    Das geht sehr einfach :-) Brauchst auch nix zu löschen.
                                    Du hast ja mit meinem Script den Datenpunkt javascript.0.PhilipsTV.Command (oder wie auch immer bei Dir der Pfad ist).

                                    Im VIS fügst Du also etwa das Widget "jqui - Button State" hinzu, in den Widget-Einstellungen dann unter Object ID dann den o.g. Datenpunkt einfügen, und unter "Wert" etwa "Launch: Kodi", oder bei Dir "sources: HDMI 1" (jeweils ohne Anführungszeichen) eintragen.

                                    Falls nicht per VIS, sondern gesteuert per Javascript (oder Blockly): da setzt Du einfach den Datenpunkt mit setState('javascript.0.PhilipsTV.Command', 'sources: HDMI 1');

                                    R 1 Antwort Letzte Antwort
                                    0
                                    • MicM Mic

                                      @rrroli
                                      Das geht sehr einfach :-) Brauchst auch nix zu löschen.
                                      Du hast ja mit meinem Script den Datenpunkt javascript.0.PhilipsTV.Command (oder wie auch immer bei Dir der Pfad ist).

                                      Im VIS fügst Du also etwa das Widget "jqui - Button State" hinzu, in den Widget-Einstellungen dann unter Object ID dann den o.g. Datenpunkt einfügen, und unter "Wert" etwa "Launch: Kodi", oder bei Dir "sources: HDMI 1" (jeweils ohne Anführungszeichen) eintragen.

                                      Falls nicht per VIS, sondern gesteuert per Javascript (oder Blockly): da setzt Du einfach den Datenpunkt mit setState('javascript.0.PhilipsTV.Command', 'sources: HDMI 1');

                                      R Offline
                                      R Offline
                                      rrroli
                                      schrieb am zuletzt editiert von
                                      #223

                                      @Mic
                                      Hammer!
                                      Läuft wie geschmiert.

                                      Danke Dir!

                                      lg

                                      1 Antwort Letzte Antwort
                                      0
                                      • MicM Mic

                                        @Stormbringer
                                        Schau Dir diese Referenz an: https://github.com/eslavnov/pylips/wiki
                                        Darauf basiert auch mein Javascript von oben.

                                        S Offline
                                        S Offline
                                        Stormbringer
                                        schrieb am zuletzt editiert von
                                        #224

                                        @Mic
                                        sorry, dass ich mich jetzt erst melde. Irgendwie funktionieren die Benachrichtigungen nicht mehr so im neuen Forum und habs dann vergessen...
                                        Glaube wir reden aneinander vorbei ;-) Du meinst nur Ambilight oder? Ich meinte Ambi und Hue (also, dass die Hues mit den Ambilight Farben mitleuchten)

                                        Oder fragen wir mal anders.. Siehst du eine Möglichkeit die Funktion Ambi und Hue "aus/ein" schalten zu realisieren bzw. wo wäre die in deinem Script?

                                        Oder geht das überhaupt nicht und ich interpretier das falsch?

                                        https://gist.github.com/marcelrv/ee9a7cf97c227d069e4ee88d26691019

                                        Angaben zur Installation: JS Controller 5.0.12, npm 9.6.7, node 18.17.1, auf einem Intel NUC mit Ubuntu 22.04

                                        B 1 Antwort Letzte Antwort
                                        0
                                        • MicM Mic

                                          Hier noch ein Update meines Test-Scripts. Es legt einen Datenpunkt unter "javascript.0.PhilipsTV.MyScript" an, womit man den Philips-TV steuern kann. Eingebaut ist auch Einschalten von Netflix, Kodi und YouTube. Sicherlich einfach in den Adapter integrierbar :-)

                                          /*******************************************************************************
                                           * ---------------------------
                                           * Philips TV Script for ioBroker
                                           * ----------------------------------------------------
                                           * Version: 0.2
                                           * Autor: Mic
                                           * ----------------------------------------------------
                                           * Documentation:
                                           *  - Unofficial Philips TV API Reference: https://github.com/eslavnov/pylips/wiki
                                           *  - Some Info: https://community.openhab.org/t/philips-tv-2016-binding/64579/61
                                           *  - Python Script with MQTT support: https://github.com/eslavnov/pylips
                                           *  - ioBroker Philips TV Adapter: https://forum.iobroker.net/topic/8791/aufruf-philips-tv-v0-1-0-testen
                                           ******************************************************************************/
                                          
                                          /*******************************************************************************
                                           * Settings
                                           *******************************************************************************/
                                          // Pfad, unter dem die Objekte angelegt werden.
                                          const STATE_PATH = 'javascript.0.PhilipsTV.MyScript.';
                                          
                                          // Generate User/Password: see https://github.com/nstrelow/ha_philips_2016
                                          const PHILIPS_USER = 'xxxxxxxxxxxxxxxxxxxxxx';
                                          const PHILIPS_PASS = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
                                          
                                          // URL, change IP address accordingly (and you may also need to change port, see for example https://github.com/eslavnov/pylips)
                                          const PHILIPS_URL = 'https://xxx.xxx.xxx.xxx:1926/6/';
                                          
                                          const LOG_DEBUG = false;
                                          
                                          
                                          /*******************************************************************************
                                           * Expert Settings
                                           *******************************************************************************/
                                          // Hier definieren wir die einzelnen Commands. 
                                          let pCommands = [];
                                          //        0.Command Name                       1.Path              2. curl Command      
                                          pCommands['Cmd: Ambilight Off']             = ['ambilight/power',   '{"power":"Off"}'];
                                          pCommands['Cmd: Ambilight On']              = ['ambilight/power',   '{"power":"On"}'];
                                          pCommands['Cmd: Ambilight On Video Standard'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"STANDARD"}'];
                                          pCommands['Cmd: Ambilight On Video Immersive'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"IMMERSIVE"}'];
                                          pCommands['Cmd: Ambilight On Video Natural'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"NATURAL"}'];
                                          pCommands['Cmd: Ambilight On Video Vivid'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"VIVID"}'];
                                          pCommands['Cmd: Ambilight On Video Game'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"GAME"}'];
                                          pCommands['Cmd: Ambilight On Video Comfort'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"COMFORT"}'];
                                          pCommands['Cmd: Ambilight On Video Relax'] = ['ambilight/currentconfiguration',   '{"styleName":"FOLLOW_VIDEO","isExpert":false,"menuSetting":"RELAX"}'];
                                          pCommands['Launch: Netflix'] = ['activities/launch',   '{"id":"com.netflix.ninja","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.netflix.ninja }","component":{"packageName":"com.netflix.ninja","className":"com.netflix.ninja.MainActivity"}},"label":"Netflix"}'];
                                          pCommands['Launch: Kodi'] = ['activities/launch',   '{"id":"org.xbmc.kodi","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=org.xbmc.kodi }","component":{"packageName":"org.xbmc.kodi","className":"org.xbmc.kodi.Splash"}},"label":"Kodi"}'];
                                          pCommands['Launch: YouTube'] = ['activities/launch',   '{"id":"com.google.android.apps.youtube.tv.activity.ShellActivity-com.google.android.youtube.tv","order":0,"intent":{"action":"Intent{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.google.android.youtube.tv cmp=com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity }","component":{"packageName":"com.google.android.youtube.tv","className":"com.google.android.apps.youtube.tv.activity.ShellActivity"}},"label":"YouTube"}'];
                                          pCommands['Key: Adjust']  = ['input/key',   '{"key":"Adjust"}'];
                                          pCommands['Key: AmbilightOnOff']  = ['input/key',   '{"key":"AmbilightOnOff"}'];
                                          pCommands['Key: Back']  = ['input/key',   '{"key":"Back"}'];
                                          pCommands['Key: BlueColour']  = ['input/key',   '{"key":"BlueColour"}'];
                                          pCommands['Key: ChannelStepDown']  = ['input/key',   '{"key":"ChannelStepDown"}'];
                                          pCommands['Key: ChannelStepUp']  = ['input/key',   '{"key":"ChannelStepUp"}'];
                                          pCommands['Key: Confirm']  = ['input/key',   '{"key":"Confirm"}'];
                                          pCommands['Key: CursorDown']  = ['input/key',   '{"key":"CursorDown"}'];
                                          pCommands['Key: CursorLeft']  = ['input/key',   '{"key":"CursorLeft"}'];
                                          pCommands['Key: CursorRight']  = ['input/key',   '{"key":"CursorRight"}'];
                                          pCommands['Key: CursorUp']  = ['input/key',   '{"key":"CursorUp"}'];
                                          pCommands['Key: Digit0']  = ['input/key',   '{"key":"Digit0"}'];
                                          pCommands['Key: Digit1']  = ['input/key',   '{"key":"Digit1"}'];
                                          pCommands['Key: Digit2']  = ['input/key',   '{"key":"Digit2"}'];
                                          pCommands['Key: Digit3']  = ['input/key',   '{"key":"Digit3"}'];
                                          pCommands['Key: Digit4']  = ['input/key',   '{"key":"Digit4"}'];
                                          pCommands['Key: Digit5']  = ['input/key',   '{"key":"Digit5"}'];
                                          pCommands['Key: Digit6']  = ['input/key',   '{"key":"Digit6"}'];
                                          pCommands['Key: Digit7']  = ['input/key',   '{"key":"Digit7"}'];
                                          pCommands['Key: Digit8']  = ['input/key',   '{"key":"Digit8"}'];
                                          pCommands['Key: Digit9']  = ['input/key',   '{"key":"Digit9"}'];
                                          pCommands['Key: Dot']  = ['input/key',   '{"key":"Dot"}'];
                                          pCommands['Key: FastForward']  = ['input/key',   '{"key":"FastForward"}'];
                                          pCommands['Key: Find']  = ['input/key',   '{"key":"Find"}'];
                                          pCommands['Key: GreenColour']  = ['input/key',   '{"key":"GreenColour"}'];
                                          pCommands['Key: Home']  = ['input/key',   '{"key":"Home"}'];
                                          pCommands['Key: Info']  = ['input/key',   '{"key":"Info"}'];
                                          pCommands['Key: Mute']  = ['input/key',   '{"key":"Mute"}'];
                                          pCommands['Key: Next']  = ['input/key',   '{"key":"Next"}'];
                                          pCommands['Key: Online']  = ['input/key',   '{"key":"Online"}'];
                                          pCommands['Key: Options']  = ['input/key',   '{"key":"Options"}'];
                                          pCommands['Key: Pause']  = ['input/key',   '{"key":"Pause"}'];
                                          pCommands['Key: Play']  = ['input/key',   '{"key":"Play"}'];
                                          pCommands['Key: PlayPause']  = ['input/key',   '{"key":"PlayPause"}'];
                                          pCommands['Key: Previous']  = ['input/key',   '{"key":"Previous"}'];
                                          pCommands['Key: Record']  = ['input/key',   '{"key":"Record"}'];
                                          pCommands['Key: RedColour']  = ['input/key',   '{"key":"RedColour"}'];
                                          pCommands['Key: Rewind']  = ['input/key',   '{"key":"Rewind"}'];
                                          pCommands['Key: Source']  = ['input/key',   '{"key":"Source"}'];
                                          pCommands['Key: Standby']  = ['input/key',   '{"key":"Standby"}'];
                                          pCommands['Key: Stop']  = ['input/key',   '{"key":"Stop"}'];
                                          pCommands['Key: Subtitle']  = ['input/key',   '{"key":"Subtitle"}'];
                                          pCommands['Key: Teletext']  = ['input/key',   '{"key":"Teletext"}'];
                                          pCommands['Key: Viewmode']  = ['input/key',   '{"key":"Viewmode"}'];
                                          pCommands['Key: VolumeDown']  = ['input/key',   '{"key":"VolumeDown"}'];
                                          pCommands['Key: VolumeUp']  = ['input/key',   '{"key":"VolumeUp"}'];
                                          pCommands['Key: WatchTV']  = ['input/key',   '{"key":"WatchTV"}'];
                                          pCommands['Key: YellowColour']  = ['input/key',   '{"key":"YellowColour"}'];
                                          
                                          
                                          /*******************************************************************************
                                           * Ab hier nichts mehr ändern / Stop editing here!
                                           ******************************************************************************/
                                          
                                          
                                          /*******************************************************************************
                                           * Initiale Function
                                           *******************************************************************************/
                                          init();
                                          function init() {
                                              
                                              // 1. Create states
                                              createScriptStates();
                                          
                                              // 2. Schedule
                                              on({id: STATE_PATH + 'Command', change:'any'}, function (obj) {
                                                  doExec(obj.state.val);
                                              });
                                          }
                                          
                                          function doExec(id) {
                                              if (id in pCommands) { // Check if Key exists and typed correctly - https://stackoverflow.com/questions/1098040/checking-if-a-key-exists-in-a-javascript-object
                                                  var exec = require('child_process').exec;
                                                  var args = "-X POST --digest --insecure -u " + PHILIPS_USER + ":" + PHILIPS_PASS + " -d '" + pCommands[id][1] + "' " + PHILIPS_URL + pCommands[id][0];
                                                  exec('curl ' + args, function (error, stdout, stderr) {
                                                      if (LOG_DEBUG) log('stdout: ' + stdout);
                                                      if (LOG_DEBUG) log('stderr: ' + stderr);
                                                      if (error !== null) {
                                                          log('exec error: ' + error);
                                                      }
                                                  });
                                              } else if(id == '') {
                                                  // do nothing, will be empty if script is initally started or user did not select value
                                              } else {
                                                  log('Wrong command provided to Philips TV: [' + id + ']', 'warn');
                                              }
                                          }
                                          
                                          function createScriptStates() {
                                              // create drop-down list
                                              let dropdown = '';
                                              for (let lpEntry of Object.keys(pCommands)) {   // 'special' loop here to get the keys
                                                  dropdown += '"' + lpEntry + '":"' + lpEntry + '",'; // fill JSON string
                                              }
                                              dropdown = dropdown.substr(0, dropdown.length-1); // remove last comma ","
                                              dropdown = '{' + dropdown + '}'; // finalize JSON string
                                              let dropdownJSON = JSON.parse(dropdown); // convert to JSON
                                              // Create state. Force is set to true, so we will always update the states if e.g. configuration in this script changed.
                                              createState(STATE_PATH + 'Command', '', true, {
                                                  'name':'Command', 
                                                  'type':'string', 
                                                  'read':false, 
                                                  'write':true, 
                                                  'role':'value', 
                                                  'states': dropdownJSON
                                              });
                                          }
                                          
                                          

                                          Achtung:

                                          Update: aktuelles Script siehe auf Github.

                                          B Offline
                                          B Offline
                                          Buddinski88
                                          schrieb am zuletzt editiert von
                                          #225

                                          @Mic danke vielmals für das Skript! Endlich kann ich mal meinen TV steuern (POS9002 > ruhig 2-3 x die Authentifizierung durchführen, falls noch jemand den TV besitzt).

                                          Kannst du mir sagen ein Blockly aussehen muss, damit ich den Command steuern kann? Ich habe folgendes mal kurz zusammengeklickert, aber da passiert am TV nichts :-)

                                          4402445f-af27-4bdb-8281-0f40586c9322-image.png

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


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          542

                                          Online

                                          32.4k

                                          Benutzer

                                          81.4k

                                          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