Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. [Idee] ioBroker Widgets auf iPhone mittels Scriptable App

    NEWS

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [Idee] ioBroker Widgets auf iPhone mittels Scriptable App

    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kassmann @blackst225 last edited by

      @blackst225 mich würde es auch interessieren 😁

      B 1 Reply Last reply Reply Quote 0
      • B
        blackst225 @kassmann last edited by Negalein

        @kassmann

        okay versuchen wir es mal:

        Teste erst mal ob du deine Datenpunkte überhaupt über den Browser ausgegeben bekommst.
        Teste dazu bitte mal den Aufruf:

        http://192.168.xxx.xx:8082/objects

        Ob der Port bei dir auch die 8082 ist weiß ich nicht. Denke aber schon. (WebAdapter)

        Dann sollte er dir schon mal alle Werte auflisten, die deine IOBroker Instanz hat.

        Dann kannst du mit Aufruf:

        http://192.168.XXX.XX:8082/getPlainValue/device-reminder.0.Waschmaschine.liveconsumption

        Deine einzelnen Datenpunkte im Browser aufrufen.
        Wir du an die Datenpunkte kommst weißt du ja sicher!?

        Dann installierst du dir die Scriptable APP in IOS und erstellst ein neues Script.

        Inhalt des Scripts ist der Code von @hacki11 https://gist.github.com/hacki11/0a3bfbd3c5bc7d6ed460a43799687736

        Dort ist nur deine IP / Port anzupassen!

        und dann unten im Script bei der try Variable deine Datenpunkte eintragen:

        try {
                const line1 = list.addText(await getValue("**0_userdata.0.Heizung.Modus**") + " Modus")
                line1.font = Font.boldSystemFont(18)
                line1.textColor = Color.green()
            
                const line2 = list.addText(await getValue("**0_userdata.0.Heizung.Leistung_KW**") + " KW")
                line2.font = Font.boldSystemFont(18)
                line2.textColor = Color.orange()
        

        Wenn du das dann über Scriptable App ausführst solltest du die beiden Datenpunkte als Widget sehen.
        Die Werte wie KW oder STD oder was auch immer kannst du ebenfalls einfach wie im Beispiel dahinter packen...

        Wie man die Widgets oder Daten im Widget benennt, habe ich aber auch nicht hin bekommen.
        Das Neue Script blicke ich leider ebenfalls nicht 🙂

        K 1 Reply Last reply Reply Quote 0
        • K
          kassmann @blackst225 last edited by

          @blackst225 Vielen Dank für deine Hilfe. Leider kommt bei mir, beim Aufruf von http://192.168.xxx.xx:8082/objects: „File not found: {}“. 😥

          B 1 Reply Last reply Reply Quote 0
          • B
            blackst225 @kassmann last edited by

            @kassmann

            geh mal bitte in deinen webAdapter und schaue welchen Port du da eingerichtet hast.
            und WICHTIG den Haken in dem Adapter auf Eingebautes "Simple-API" setzen!

            K 1 Reply Last reply Reply Quote 0
            • K
              kassmann @blackst225 last edited by

              @blackst225 am Haken der Simlpe-API hat es gelegen. Danach klappt es. Leider nutze ich noch iQontrol und eben da muss es zwingend deaktiviert sein. 😥 Mist, Zwickmühle.

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

                @kassmann Du kannst auch den neuen https://github.com/ioBroker/ioBroker.rest-api Adapter dafür nutzen 😉

                Edit:
                Hier einmal die angepasste getValue Function

                async function getValue(point) {
                    try {
                        const req = new Request(`${host}/v1/state/${point}/plain`)
                        const value = await req.loadString()
                        return value;
                    } catch (err) {
                        console.error(err)
                        return "n/a"
                    }
                }
                
                K 1 Reply Last reply Reply Quote 0
                • K
                  kassmann @IdleBit last edited by

                  @idlebit Ich bin für alles offen 😊 . Nur sind meine Kenntnisse vom Programmieren, ähm nicht vorhanden 😵

                  Bei mir zieht es jetzt so aus.

                  async function getValue(point) {
                      try {
                          const req = new Request(`${192.168.178.xx:xxxx}/v1/state/${plenticore.0.devices.local.Pv_P}/plain`)
                          const value = await req.loadString()
                          return value;
                      } catch (err) {
                          console.error(err)
                          return "n/a"
                      }
                  }
                  
                  

                  Bleiben die "{" oder das "$" vor und nach meinen Einfügungen drin? Denn dann kommt eine Fehlermeldung: "2022-04-27 14:24:29: Error on line 3: SyntaxError: Unexpected number '.178'. Expected a closing '}' following an expression in template literal."

                  Ohne die "{" oder das "$" kommt zwar keine Fehlermeldung, aber auch kein Werte. Wenn ich aber "http://192.168.178.xx:xxxx/v1/state/plenticore.0.devices.local.Pv_P/plain" im Browser eingebe, kommt der Wert.

                  Sorry für die vielleicht blöde Frage... 😬

                  IdleBit 1 Reply Last reply Reply Quote 0
                  • IdleBit
                    IdleBit @kassmann last edited by

                    @kassmann
                    "host" und "point" sind Variablen!
                    Du musst nur die Funktion die ich gepostet habe hier austauschen
                    https://gist.github.com/hacki11/0a3bfbd3c5bc7d6ed460a43799687736
                    und der Rest läuft dann wie von @blackst225 hier oben wie beschrieben.

                    K 1 Reply Last reply Reply Quote 0
                    • K
                      kassmann @IdleBit last edited by

                      @idlebit Ah, jetzt habe ich es verstanden. 👍

                      IdleBit 1 Reply Last reply Reply Quote 0
                      • IdleBit
                        IdleBit @kassmann last edited by

                        Ich habe das gestern auch mal Probiert, aber nur ganz Basic.
                        Geht erstaunlich gut 🙂

                        80b8174e-b422-4c2a-a6e0-62c0ee48f95f-image.png

                        K 1 Reply Last reply Reply Quote 1
                        • K
                          kassmann @IdleBit last edited by

                          @idlebit sieht auf jeden Fall besser aus als meins 😕 C6F330DD-5B3A-4829-940C-375724A3DB34.jpeg
                          Bekomme ich die Nachkommastellen noch gekürzt?

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

                            @kassmann Ja mit z.B. toFixed() kann man die nachkommerstellen begrenzen.https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed

                            Sonst zeig mal deinen Code.

                            K 1 Reply Last reply Reply Quote 0
                            • K
                              kassmann @IdleBit last edited by

                              @idlebit

                              let host = args.widgetParameter;
                              if (!host)
                                host = "http://xxxxxx"
                              
                              console.log(host)
                              
                              
                              let widget = await createWidget()
                              Script.setWidget(widget)
                              widget.presentSmall()
                              Script.complete()
                              
                              async function createWidget() {
                              
                                  const list = new  ListWidget()
                              
                                  try {
                                      const line1 = list.addText(await getValue("plenticore.0.devices.local.Pv_P") + " W")
                                      line1.font = Font.boldSystemFont(17)
                                      line1.textColor = Color.green()
                                  
                                      const line2 = list.addText(await getValue("plenticore.0.devices.local.battery.SoC") + " %")
                                      line2.font = Font.boldSystemFont(17)
                                      line2.textColor = Color.orange()
                              
                                      return list
                              
                                  } catch(err) {
                                      const errorList = new ListWidget()
                                      errorList.addText(err)
                                      return errorList
                                  }
                              }
                              
                              async function getValue(point) {
                                  try {
                                      const req = new Request(`${host}/v1/state/${point}/plain`)
                                      const value = await req.loadString()
                                      return value;
                                  } catch (err) {
                                      console.error(err)
                                      return "n/a"
                                  }
                              }
                              
                              
                              IdleBit 1 Reply Last reply Reply Quote 0
                              • IdleBit
                                IdleBit @kassmann last edited by IdleBit

                                So ist in Zeile 18 der Wert auf 2 Stellen gekürzt, aber nicht gerundet.

                                let host = args.widgetParameter;
                                if (!host)
                                  host = "http://xxxxxx"
                                 
                                console.log(host)
                                 
                                 
                                let widget = await createWidget()
                                Script.setWidget(widget)
                                widget.presentSmall()
                                Script.complete()
                                 
                                async function createWidget() {
                                 
                                    const list = new  ListWidget()
                                 
                                    try {
                                        const line1 = list.addText(Number(await getValue("plenticore.0.devices.local.Pv_P")).toFixed(2)+ " W")
                                        line1.font = Font.boldSystemFont(17)
                                        line1.textColor = Color.green()
                                    
                                        const line2 = list.addText(await getValue("plenticore.0.devices.local.battery.SoC") + " %")
                                        line2.font = Font.boldSystemFont(17)
                                        line2.textColor = Color.orange()
                                 
                                        return list
                                 
                                    } catch(err) {
                                        const errorList = new ListWidget()
                                        errorList.addText(err)
                                        return errorList
                                    }
                                }
                                 
                                async function getValue(point) {
                                    try {
                                        const req = new Request(`${host}/v1/state/${point}/plain`)
                                        const value = await req.loadString()
                                        return value;
                                    } catch (err) {
                                        console.error(err)
                                        return "n/a"
                                    }
                                }
                                

                                Gerundet würde die Zeile so ausgehen:

                                const line1 = list.addText(Math.round(Number(await getValue("plenticore.0.devices.local.Pv_P")) * 100) / 100 + " W")
                                
                                K 1 Reply Last reply Reply Quote 0
                                • K
                                  kassmann @IdleBit last edited by

                                  @idlebit ungerundet ist völlig ausreichend, super vielen Dank.

                                  Kannst du eventuell deinen Code auch posten? Würde da gern was kombinieren. 😁

                                  IdleBit 1 Reply Last reply Reply Quote 0
                                  • IdleBit
                                    IdleBit @kassmann last edited by

                                    @kassmann Ja kann ich, ist aber nur so eben schnell hingeschmissen der Code

                                    let host = args.widgetParameter;
                                    if (!host)
                                        host = "http://192.168.0.203:8093"
                                    
                                    let widget = await createWidget()
                                    Script.setWidget(widget)
                                    widget.presentSmall()
                                    Script.complete()
                                    
                                    
                                    async function createWidget() {
                                        // let g = new LinearGradient();
                                        // g.colors = [Color.red(), Color.red(), Color.blue(), Color.blue()];
                                        // g.locations = [0, 0.5, 0.5, 1];
                                    
                                        const widget = new ListWidget();
                                        //list.backgroundGradient = g;
                                    
                                        const nextRefresh = Date.now() + (1000 * 30) // add 30 second to now
                                    
                                        widget.refreshAfterDate = new Date(nextRefresh)
                                    
                                        try {
                                            const solarHeader = widget.addText("Solar Strom");
                                            solarHeader.font = Font.boldSystemFont(12);
                                            solarHeader.centerAlignText();
                                    
                                            const solar = widget.addText(`${await getValue("solax.0.data.acpower")}W | ${Number(await getValue("sourceanalytix.0.solax__0__data__yieldtotal.currentYear.consumed.01_currentDay")).toFixed(1)}kWh | ${await getValue("sourceanalytix.0.solax__0__data__yieldtotal.currentYear.costs.01_currentDay")}€`);
                                            solar.font = Font.boldSystemFont(16);
                                            solar.centerAlignText();
                                    
                                            widget.addSpacer();
                                    
                                            const netzHeader = widget.addText("Netz Strom");
                                            netzHeader.font = Font.boldSystemFont(12);
                                            netzHeader.centerAlignText();
                                    
                                            const netz = widget.addText(`${await getValue("sonoff.0.SmartMeter.LK13BE_current")}W | ${Number(await getValue("sourceanalytix.0.sonoff__0__SmartMeter__LK13BE_total.currentYear.consumed.01_currentDay")).toFixed(1)}kWh | ${await getValue("sourceanalytix.0.sonoff__0__SmartMeter__LK13BE_total.currentYear.costs.01_currentDay")}€`);
                                            netz.font = Font.boldSystemFont(16);
                                            netz.centerAlignText();
                                    
                                            widget.addSpacer();
                                    
                                            const houseHeader = widget.addText("Haus Strom");
                                            houseHeader.font = Font.boldSystemFont(12);
                                            houseHeader.centerAlignText();
                                    
                                            const house = widget.addText(`${await getValue("0_userdata.0.Energy.CurrentHouseEnergyConsumption")}W | ${await getValue("0_userdata.0.Energy.TotalHouseEnergyToday")}kWh | ${await getValue("0_userdata.0.Energy.EnergyAutakie")}%`);
                                            house.font = Font.boldSystemFont(16);
                                            house.centerAlignText();
                                    
                                            widget.addSpacer();
                                    
                                            const description = widget.addText(`Stand: ${new Date().toLocaleTimeString()} Uhr`);
                                            description.centerAlignText();
                                            description.font = Font.mediumSystemFont(9);
                                    
                                            return widget;
                                    
                                        } catch (err) {
                                            const errorList = new ListWidget();
                                            errorList.addText(err);
                                            return errorList;
                                        }
                                    }
                                    
                                    async function getValue(point) {
                                        try {
                                            const req = new Request(`${host}/v1/state/${point}/plain`)
                                            const value = await req.loadString()
                                            return value;
                                        } catch (err) {
                                            console.error(err)
                                            return "n/a"
                                        }
                                    }
                                    
                                    K 1 Reply Last reply Reply Quote 0
                                    • K
                                      kassmann @IdleBit last edited by

                                      @idlebit Kannst du mir nochmal helfen, ich hoffe, dass letzte mal 😥. Hier mal ein kurzer Auszug, ich hoffe der reicht.

                                      widget.refreshAfterDate = new Date(nextRefresh)
                                       
                                          try {
                                              const solarHeader = widget.addText("Solar Strom");
                                              solarHeader.font = Font.boldSystemFont(12);
                                              solarHeader.centerAlignText();
                                       
                                              const solar = widget.addText(`${await getValue("plenticore.0.devices.local.Pv_P")).toFixed(2)}W | 
                                              ${Number(await getValue("plenticore.0.scb.statistic.EnergyFlow.EnergyHomePvDay")).toFixed(1)}kWh`);
                                              solar.font = Font.boldSystemFont(16);
                                              solar.centerAlignText();
                                      

                                      In Zeile 8 wird die Kürzung der Kommastelle nicht ausgeführt und es kommt der Fehler:
                                      SyntaxError: Unexpected token ')'. Expected a closing '}' following an expression in template literal.

                                      Zeile 9 klappt.

                                      Schon mal Danke

                                      IdleBit 1 Reply Last reply Reply Quote 0
                                      • IdleBit
                                        IdleBit @kassmann last edited by IdleBit

                                        EDIT:
                                        Ein Number fehlte

                                        widget.refreshAfterDate = new Date(nextRefresh)
                                         
                                            try {
                                                const solarHeader = widget.addText("Solar Strom");
                                                solarHeader.font = Font.boldSystemFont(12);
                                                solarHeader.centerAlignText();
                                         
                                                const solar = widget.addText(`${Number(await getValue("plenticore.0.devices.local.Pv_P")).toFixed(2)}W | 
                                                ${Number(await getValue("plenticore.0.scb.statistic.EnergyFlow.EnergyHomePvDay")).toFixed(1)}kWh`);
                                                solar.font = Font.boldSystemFont(16);
                                                solar.centerAlignText();
                                        
                                        K severendis 2 Replies Last reply Reply Quote 0
                                        • K
                                          kassmann @IdleBit last edited by

                                          @idlebit Ein Traum, tausend Dank 😀

                                          1 Reply Last reply Reply Quote 0
                                          • severendis
                                            severendis @IdleBit last edited by

                                            @idlebit

                                            Hallo!

                                            Ich habe hier ein Problem, das es bei Deinem Sycript bei mir zur Ausgabe "File state/....." kommt und das an jeder Stelle wo ein Wert stehen sollte.

                                            Der Datenpunkt stimmt. In der einfacheren Version (danke @blackst225 ) habe ich die Ausgabe bekommen.
                                            Bitte nur die erste Zeile der Datenausgabe beachten. Die anderen beiden hatte ich noch nicht angepasst.

                                            Was kann das sein?

                                            Danke schon mal!

                                            let host = args.widgetParameter;
                                            
                                            if (!host)
                                            
                                                host = "http://192.168.11.166:8082"
                                            
                                             
                                            
                                            let widget = await createWidget()
                                            
                                            Script.setWidget(widget)
                                            
                                            widget.presentSmall()
                                            
                                            Script.complete()
                                            
                                             
                                            
                                             
                                            
                                            async function createWidget() {
                                            
                                                // let g = new LinearGradient();
                                            
                                                // g.colors = [Color.red(), Color.red(), Color.blue(), Color.blue()];
                                            
                                                // g.locations = [0, 0.5, 0.5, 1];
                                            
                                             
                                            
                                                const widget = new ListWidget();
                                            
                                                //list.backgroundGradient = g;
                                            
                                             
                                            
                                                const nextRefresh = Date.now() + (1000 * 30) // add 30 second to now
                                            
                                             
                                            
                                                widget.refreshAfterDate = new Date(nextRefresh)
                                            
                                             
                                            
                                                try {
                                            
                                                    const solarHeader = widget.addText("Solar Strom");
                                            
                                                    solarHeader.font = Font.boldSystemFont(12);
                                            
                                                    solarHeader.centerAlignText();
                                            
                                                    const solar = widget.addText(`${await getValue("0_userdata.0.Huawei.Inverter.PV_P")}W | ${await getValue("0_userdata.0.Huawei.Inverter.PV_P")}kWh | ${await getValue("0_userdata.0.Huawei.Inverter.PV_P")}€`);
                                            
                                                    solar.font = Font.boldSystemFont(16);
                                            
                                                    solar.centerAlignText();
                                            
                                             
                                            
                                                    widget.addSpacer();
                                            
                                             
                                            
                                                    const netzHeader = widget.addText("Netz Strom");
                                            
                                                    netzHeader.font = Font.boldSystemFont(12);
                                            
                                                    netzHeader.centerAlignText();
                                            
                                             
                                            
                                                    const netz = widget.addText(`${await getValue("sonoff.0.SmartMeter.LK13BE_current")}W | ${Number(await getValue("sourceanalytix.0.sonoff__0__SmartMeter__LK13BE_total.currentYear.consumed.01_currentDay")).toFixed(1)}kWh | ${await getValue("sourceanalytix.0.sonoff__0__SmartMeter__LK13BE_total.currentYear.costs.01_currentDay")}€`);
                                            
                                                    netz.font = Font.boldSystemFont(16);
                                            
                                                    netz.centerAlignText();
                                            
                                             
                                            
                                                    widget.addSpacer();
                                            
                                             
                                            
                                                    const houseHeader = widget.addText("Haus Strom");
                                            
                                                    houseHeader.font = Font.boldSystemFont(12);
                                            
                                                    houseHeader.centerAlignText();
                                            
                                             
                                            
                                                    const house = widget.addText(`${await getValue("0_userdata.0.Energy.CurrentHouseEnergyConsumption")}W | ${await getValue("0_userdata.0.Energy.TotalHouseEnergyToday")}kWh | ${await getValue("0_userdata.0.Energy.EnergyAutakie")}%`);
                                            
                                                    house.font = Font.boldSystemFont(16);
                                            
                                                    house.centerAlignText();
                                            
                                             
                                            
                                                    widget.addSpacer();
                                            
                                             
                                            
                                                    const description = widget.addText(`Stand: ${new Date().toLocaleTimeString()} Uhr`);
                                            
                                                    description.centerAlignText();
                                            
                                                    description.font = Font.mediumSystemFont(9);
                                            
                                             
                                            
                                                    return widget;
                                            
                                             
                                            
                                                } catch (err) {
                                            
                                                    const errorList = new ListWidget();
                                            
                                                    errorList.addText(err);
                                            
                                                    return errorList;
                                            
                                                }
                                            
                                            }
                                            
                                             
                                            
                                            async function getValue(point) {
                                            
                                                try {
                                            
                                                    const req = new Request(`${host}/v1/state/${point}/plain`)
                                            
                                                    const value = await req.loadString()
                                            
                                                    return value;
                                            
                                                } catch (err) {
                                            
                                                    console.error(err)
                                            
                                                    return "n/a"
                                            
                                                }
                                            
                                            }
                                            
                                            IdleBit 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate
                                            FAQ Cloud / IOT
                                            HowTo: Node.js-Update
                                            HowTo: Backup/Restore
                                            Downloads
                                            BLOG

                                            935
                                            Online

                                            31.6k
                                            Users

                                            79.6k
                                            Topics

                                            1.3m
                                            Posts

                                            apple ios scriptable widget
                                            15
                                            54
                                            7448
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo