UPDATE: Despite the warning about invalid channel, it works. But I am hesitant to mark it as solved… @5iver what are your thoughts on this? A human error or worth an issue on Github?
Original post:
I have migrated 99% of my DSL rules to Jython and upgraded some in the process to leverage Scripting Engine functionality (like creating Items, Metadata and Channel links).
The FTP binding gives me a bit of trouble. When defining the items in an .items
file it works just fine, but when I try to create the items dynamically, it generates an error (see below). I use these items to store the base64 encoded Grafana rendered images so I can display them on HABpanel via my own openhabcloud instance. For flexibility, I want to keep stuff in Item metadata that I create on first run or if another graph is added to a Dictionary in Python.
This works (I just add the metadata programmatically and everything is fine):
// Item to store the Grafana image for Indoor temperature last 24h
Image imgTempIndoor24h
"Indoor Temp last 24h"
(gSnapshot)
{channel="ftpupload:imagereceiver:grf_temp_indoor24h:image"}
...
This doesn’t work:
from core.utils import ChannelUID
from core.items import add_item
from core.links import add_link
try:
for entry in grafImgDict.values():
imgItemName = entry.get("item_name")
if ir.getItems(imgItemName) == []:
add_item(imgItemName, item_type="Image", groups=[entry.get("item_group")], label=entry.get("item_description"), tags=["Grafana"])
add_link(imgItemName, ChannelUID("ftpupload:imagereceiver:"+entry.get("ftp_channel")+":image"))
set_metadata(imgItemName, "Grafana_Graphs", \
{"PanelId": entry.get("grafana_panelid"), \
...
The error is:
[WARN ] [openhab.automation.jython.core.utils] - [ftpupload:imagereceiver:grf_temp_indoor24h:image] is not a valid Channel
What am I missing here?