NEWS
[GELÖST] Text-Wert eines states ausgeben anstatt Nummer
-
Gibt es eine einfache Möglichkeit den "übersetzten" Wert zu bekommen? `
Eine einfache Möglichkeit wüsste ich nicht, da Du meiner Meinung nach nur an den STATE und nicht an das Objekt rankommst, in dem die Werteliste steht.
Eine Alternative wäre die Werte in einem zusätzlichen Datenpunkt per Skript zu schreiben (Aktualisiert sich bei jeder Änderung):
var pfad = "Visualisierung.Xiaomi_Cleaner" + "."; var idErrorText = pfad + "statustext.error"; var idStateText = pfad + "statustext.state"; var pfadMihomeAdapter = "mihome-vacuum.0" + "."; var stateStates = { "1": "Unknown 1", "2": "Sleep no Charge", "3": "Sleep", "5": "Cleaning", "6": "Returning home", "7": "Manuell mode", "8": "Charging", "10": "Paused", "11": "Spot cleaning", "12": "Error?!" }; var errorStates = { "0": "No error", "1": "Laser distance sensor error", "2": "Collision sensor error", "3": "Wheels on top of void, move robot", "4": "Clean hovering sensors, move robot", "5": "Clean main brush", "6": "Clean side brush", "7": "Main wheel stuck?", "8": "Device stuck, clean area", "9": "Dust collector missing", "10": "Clean filter", "11": "Stuck in magnetic barrier", "12": "Low battery", "13": "Charging fault", "14": "Battery fault", "15": "Wall sensors dirty, wipe them", "16": "Place me on flat surface", "17": "Side brushes problem, reboot me", "18": "Suction fan problem", "19": "Unpowered charging station" }; createState(idErrorText, getErrorState(), { name: 'Text zum Error Status', desc: 'Text zum Error Status', type: 'string', role: 'value' }); createState(idStateText, getStateState(), { name: 'Text zum Status', desc: 'Text zum Status', type: 'string', role: 'value' }); function getStateState() { var state = getState(pfadMihomeAdapter+"info.state").val; var text = stateStates[state.toString()]; return text; } function getErrorState() { var error = getState(pfadMihomeAdapter+"info.error").val; var text = errorStates[error.toString()]; return text; } on({id: pfadMihomeAdapter + "info.state", change: "ne"}, function (obj) { setState(idStateText,getStateState()); }); on({id: pfadMihomeAdapter + "info.error", change: "ne"}, function (obj) { setState(idErrorText,getErrorState()); });
-
Oder alternativ ein anderes Widget wenn es nicht genau das sein muss?
Noch dein ObjectID auswählen und dann sollte das gehen
! ````
[{"tpl":"tplValueList","data":{"oid":"","g_fixed":false,"g_visibility":false,"g_css_font_text":false,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0,"valuelist":"Unknown 1;\nSleep no Charge;\nSleep;\nCleaning;\nReturning;\nManuell mode;\nCharging;\nPaused;\nSpot cleaning;\nError?!"},"style":{"left":"174px","top":"137px","width":"100px","height":"30px"},"widgetSet":"basic"}] -
Danke für die Ideen. Ein neues Script und Datenpunkt wollte ich auf Grund der Übersichtlichkeit vermeiden. Habe mich daher für die Idee von peoples entschieden (musste nur die Werte-Liste noch anpassen da das Widget 0-basiert ist und die Status-Werte des Roboters "Lücken" hat). Aber so klappt es.
[{"tpl":"tplValueList","data":{"oid":"mihome-vacuum.0.info.state","g_fixed":false,"g_visibility":false,"g_css_font_text":true,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0,"valuelist":"Unknown;\nUnknown;\nSleep no Charge;\nSleep;\nUnknown;\nCleaning;\nReturning home;\nManuell mode;\nCharging;\nUnknown;\nPaused;\nSpot cleaning;\nError"},"style":{"left":"433px","top":"18px","width":"110px","height":"20px","color":"#FFFFFF"},"widgetSet":"basic"}]
Danke euch!
-
@miggedy said in [GELÖST] Text-Wert eines states ausgeben anstatt Nummer:
[{"tpl":"tplValueList","data":{"oid":"mihome-vacuum.0.info.state","g_fixed":false,"g_visibility":false,"g_css_font_text":true,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0,"valuelist":"Unknown;\nUnknown;\nSleep no Charge;\nSleep;\nUnknown;\nCleaning;\nReturning home;\nManuell mode;\nCharging;\nUnknown;\nPaused;\nSpot cleaning;\nError"},"style":{"left":"433px","top":"18px","width":"110px","height":"20px","color":"#FFFFFF"},"widgetSet":"basic"}]
Habe gerade genau das gleiche Problem
Welches Widget verwendet man für sowas? -
@tropisch said in [GELÖST] Text-Wert eines states ausgeben anstatt Nummer:
@miggedy said in [GELÖST] Text-Wert eines states ausgeben anstatt Nummer:
[{"tpl":"tplValueList","data":{"oid":"mihome-vacuum.0.info.state","g_fixed":false,"g_visibility":false,"g_css_font_text":true,"g_css_background":false,"g_css_shadow_padding":false,"g_css_border":false,"g_gestures":false,"g_signals":false,"g_last_change":false,"visibility-cond":"==","visibility-val":1,"visibility-groups-action":"hide","signals-cond-0":"==","signals-val-0":true,"signals-icon-0":"/vis/signals/lowbattery.png","signals-icon-size-0":0,"signals-blink-0":false,"signals-horz-0":0,"signals-vert-0":0,"signals-hide-edit-0":false,"signals-cond-1":"==","signals-val-1":true,"signals-icon-1":"/vis/signals/lowbattery.png","signals-icon-size-1":0,"signals-blink-1":false,"signals-horz-1":0,"signals-vert-1":0,"signals-hide-edit-1":false,"signals-cond-2":"==","signals-val-2":true,"signals-icon-2":"/vis/signals/lowbattery.png","signals-icon-size-2":0,"signals-blink-2":false,"signals-horz-2":0,"signals-vert-2":0,"signals-hide-edit-2":false,"lc-type":"last-change","lc-is-interval":true,"lc-is-moment":false,"lc-format":"","lc-position-vert":"top","lc-position-horz":"right","lc-offset-vert":0,"lc-offset-horz":0,"lc-font-size":"12px","lc-font-family":"","lc-font-style":"","lc-bkg-color":"","lc-color":"","lc-border-width":"0","lc-border-style":"","lc-border-color":"","lc-border-radius":10,"lc-zindex":0,"valuelist":"Unknown;\nUnknown;\nSleep no Charge;\nSleep;\nUnknown;\nCleaning;\nReturning home;\nManuell mode;\nCharging;\nUnknown;\nPaused;\nSpot cleaning;\nError"},"style":{"left":"433px","top":"18px","width":"110px","height":"20px","color":"#FFFFFF"},"widgetSet":"basic"}]
Habe gerade genau das gleiche Problem
Welches Widget verwendet man für sowas?Problem gelöst.
Falls noch jemand diese Frage hat: Widgets - Widgets importieren -
Ich habe bei meinem Landroid das gleiche Problem. Irgendwie muss es doch noch eine andere Lösung geben, Immerhin steht ja alles in der DP Definition drin und in der Admin Oberfläche wird auch der Klartext angezeigt.
-
-
Ja, nee... dass es damit geht (aber nur in der VIS), ist mir schon klar. Aber das heisst, dass ich bereits im System vorhandene Werte nochmal eingeben muss. Das sind für mich nur work-arounds. Denken wir mal, dass Worx einen zusätzlichen Status 99 - Dein Landroid hebt in zwei Minuten ab erfindet. Dann muss ich in vile Visualisierungen und Scripte anpassen.
Ich glaube ich mache mal ein GIT Issue auf - passt wahrscheinlich in ioBroker.javascript. -
@apollon77
Ich habe gesehen, dass Du einen Enhancement Request zu einem ähnlichen Thema aufgemacht hast (https://github.com/ioBroker/ioBroker.javascript/issues/381)
Kannst Du in diesem Thread helfen: Wie kann ich mit getState (oder getObject ?) an den Klartext eines State values kommen? -
Wenn ein Objekt sowas hat dann per getObject das Objekt laden und da unter common.states stehen die Textzeilen werte.
-
@apollon77 Super, danke, funktioniert
-
@apollon77 Danke, diese relativ alte Antwort hat auch mir heut geholfen!
-
@michaelsc said in [GELÖST] Text-Wert eines states ausgeben anstatt Nummer:
@apollon77 Danke, diese relativ alte Antwort hat auch mir heut geholfen!
@apollon77: Hat zwar geholfen, aber nicht zum Erfolg geführt - ich komme mit der Syntax nicht klar.
Wie muss denn bitte so ein getObject genau aussehen? Ich hätte gerne den Namen zurück, der da drinsteht, aber da muss man doch eine bestimmte Syntax einhalten, denke ich mal...