Comments (5)
a) replace all method calls in core, e.g. in smartplugin by the property. For example instead of item.path() -> item.property.path
Nope, that would only fix the issue, if the class methods in question would be removed and that would be a massive breaking change.
b) extend the item check functionality that tests for item names that might clash with python to also log a warning if an item is called the same as an item method
Could be done, but I haven't seen any problem reports concerning this in the forum or issues up to now.
Furthermore, I think in https://smarthomeng.github.io/dev_doc/lib/item_class_item.html the "Available only in SmartHomeNG v1.6, not in versions above" for path() is wrong?
Yup
from smarthome.
Ad a) Ja, stimmt schon, andererseits würde ein Anpassen des Core Codes zumindest die Gefahr drastisch verringern, dass da was Unerwartetes passiert.
ad b) Kann dir gerne einen Forumbeitrag erstellen ;) Bin selbst erst grad bei der Kombination von smartvisu Plugin WebIF und lms Plugin auf den Fehler gestoßen..
Jan 30 21:37:48 ERROR cherrypy.error.546951669792 [30/Jan/2024:21:37:48] HTTP
Traceback (most recent call last):
File "/home/smarthome/.local/lib/python3.9/site-packages/cherrypy/_cprequest.py", line 638, in respond
self._do_respond(path_info)
File "/home/smarthome/.local/lib/python3.9/site-packages/cherrypy/_cprequest.py", line 697, in _do_respond
response.body = self.handler()
File "/home/smarthome/.local/lib/python3.9/site-packages/cherrypy/lib/encoding.py", line 223, in __call__
self.body = self.oldhandler(*args, **kwargs)
File "/home/smarthome/.local/lib/python3.9/site-packages/cherrypy/_cpdispatch.py", line 54, in __call__
return self.callable(*self.args, **self.kwargs)
File "/usr/local/smarthome/plugins/smartvisu/webif/__init__.py", line 144, in get_data_html
item_config = self.plugin.get_item_config(item)
File "/usr/local/smarthome/lib/model/smartplugin.py", line 280, in get_item_config
return self._plg_item_dict[item_path].get('config_data')
KeyError: 'file:///music/Discographies/Therapy/Therapy%20-%201994%20-%20Troublegum/01.%20Therapy%20-%20Knives.mp3'
Es wurde hier also der Wert des Unteritems namens path ausgewertet anstatt dass der Itempfad zurückgegeben wurde. Werde jetzt mal das Pluginstruct anpassen oder wie sollen wir hier vorgehen? Ist halt auch ein breaking change, aber das Plugin ist noch recht frisch und vermutlich nicht sonderlich weit verbreitet...
from smarthome.
Das Problem rührt natürlich im Kern daher, dass Unteritems als Objektvariablen im Item angelegt werden (was nicht selbstverständlich und nicht streng notwendig ist). Während das tatsächlich Probleme machen kann, halte ich das nicht für sinnvoll verzichtbar; als Architekturfeature müsste der gesamte Core und ein Großteil der Plugins neu geschrieben werden.
Variante b) würde das Problem lösen zu Lasten der User, die ihre Items umbenennen müssten. Lösen allerdings nur vorläufig; wenn lib.item.item irgendwann neue Methoden bekommt (siehe add_item/remove_item/..., auch wenn das schlechte Beispiele sind ;) ), passierte das wieder von Neuem.
Also entweder
a) damit leben und Plugins (Core?) so anpassen, dass statt item.id() -> item.path() -> item.property.path verwendet wird und das gelegentliche Problem hinnehmen,
b) beim Lesen der Items prüfen, ob der Name des Sub-Items als Methode/Eigenschaft des Items vorhanden ist und
ba) das Unteritem nicht anlegen
bb) das Unteritem nicht als Objekteigenschaft einbinden (schlecht, weil inkonsistent)
Ich sehe das nicht als kurzfristig dringendes Problem und tendiere daher zu b) bzw. bb)
from smarthome.
Ich hätte noch eine Option, eine Variante zu ba): Eine Warning loggen.
Bisher gibt es in lib/config.py die Methoden remove_reserved()
(verhindert Itemnamen, die einem shng Keyword entsprechen) und remove_keyword
(verhindert Item Namen, die einem Python keyword entsprechen).
Als shng Keywords sind dort bisher nur ['set', 'get', 'property']
definiert.
Man könnte eine Methode warn_reserved()
ergänzen, die zwar die Anlage des Items zulässt, aber einen Log Eintrag erstellt. Die offene Frage dabei ist, wie man die Liste der entsprechenden Keywords am einfachsten erstellt. Ein Ansatz könnte sein, die Liste z.B. mit dir(Item)
zu erstellen. Damit würde sie immer aktuell sein.
Als Nachteil ergäbe sich, dass sich die Startzeit von shng erhöht.
from smarthome.
Fixed by #628
from smarthome.
Related Issues (20)
- cache value not converted to current item type
- Issues with (re)loading logics from the editor page of the admin gui HOT 7
- structs not checked for wrong configurations? HOT 1
- Issue with smartdeviceplugin with UTF-8 response HOT 1
- Requirements von Logiken und Userfunctions installieren beim Start? HOT 7
- Websocket crashed HOT 4
- Vorschlag zum besseren Handling von Items mit Datentyp 'dict' oder 'list' HOT 25
- Websocket Exceptions HOT 4
- struct names are applied to items including the struct
- Visu subscription of a memory log activates sending of env.core.log HOT 5
- smarthome/doc/user/source/beispiele/eval.rst Beispiel "Enumeration über Liste" funktioniert nicht HOT 1
- Log configuration: allow placeholders for filename and rotate correctly HOT 1
- Delay in scenes HOT 4
- Http module cannot bind on all interfaces
- Incompability to paho-mqtt-2.0.0 HOT 1
- Usage of logging.default.yaml HOT 7
- Problem bei max python Version zum Start? HOT 3
- Item Funktionen in der plugin.yaml? HOT 12
- Bug in ``Utils.get_all_local_ipv4_addresses()`` HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smarthome.