openhab / openhab-vscode

VS Code extension for openHAB configuration files
https://marketplace.visualstudio.com/items?itemName=openhab.openhab
Eclipse Public License 2.0
159 stars 47 forks source link

Add same name when creating items for things #78

Open fab33 opened 6 years ago

fab33 commented 6 years ago

For exemple with "ThisThing" and a channel "TestChannel", when you right click on this_thing to create all items, item name will be ThisThingTestChannel. But if you already have some channels and right click on TestChannel, item name will be TestChannel without "ThisThing" for prefix.

kubawolanin commented 6 years ago

Hi @fab33,

I'm not sure I understand. Do you think it's related to #79 ?

fab33 commented 6 years ago

No it's not related to #79. if you have this : sans titre When you right-click to creat items on "Endstop Bureau" you have items :

Switch     EndstopBureau_Status       "Status"          {channel="mysensors:light:ESPgw:Bureau_Volet_EndStop:status"}
Number     EndstopBureau_Var1         "Variable 1"      {channel="mysensors:light:ESPgw:Bureau_Volet_EndStop:var1"}
Number     EndstopBureau_Var2         "Variable 2"      {channel="mysensors:light:ESPgw:Bureau_Volet_EndStop:var2"}
Number     EndstopBureau_Var3         "Variable 3"      {channel="mysensors:light:ESPgw:Bureau_Volet_EndStop:var3"}
Number     EndstopBureau_Var4         "Variable 4"      {channel="mysensors:light:ESPgw:Bureau_Volet_EndStop:var4"}
Number     EndstopBureau_Var5         "Variable 5"      {channel="mysensors:light:ESPgw:Bureau_Volet_EndStop:var5"}
Number     EndstopBureau_Battery      "Battery Level"   {channel="mysensors:light:ESPgw:Bureau_Volet_EndStop:battery"}
DateTime   EndstopBureau_Lastupdate   "Last Update"     {channel="mysensors:light:ESPgw:Bureau_Volet_EndStop:lastupdate"}

but for example if you right-click on Var1 to create item you have :

Number Var1 "Variable 1" {channel="mysensors:light:ESPgw:Bureau_Volet_EndStop:var1"}

one time it's EndstopBureau_Var1 (right name for me) and one time it's only Var1

Confectrician commented 6 years ago

Hey @kubawolanin i find the suggested change useful and ahd a look into this. The magic happens in https://github.com/openhab/openhab-vscode/blob/master/src/ThingsExplorer/ItemsProvider.ts but it seems that we have no information about the thing in the channel model.

Are we able to get the "Parent" from somewhere, when we know the channel?

Otherwise we could improve the channel model and add a parent property. We could addd these info while building the tree view from rest api then.