That was based on the example on this HS doc page. But I'll play around a bit and see what I can figure out. Thanks!
Announcement
Collapse
No announcement yet.
tenScripting4, the extensions, and C#
Collapse
X
-
I am writing all my code moving forward in C# instead of VB.Net for HS4. The more I read about Microsoft's waning support for VB, the more sense it makes for me to transition to C#. Thanks to you guys for making progress on ironing out issues with C# and HS4.---------------------------------------------------
Jean-Marie G. Vaneskahian
jean@vaneskahian.com
---------------------------------------------------
- Likes 2
Comment
-
Originally posted by jeanv View PostI am writing all my code moving forward in C# instead of VB.Net for HS4. The more I read about Microsoft's waning support for VB, the more sense it makes for me to transition to C#. Thanks to you guys for making progress on ironing out issues with C# and HS4.tenholde
- Likes 1
Comment
-
Will do! I am nowhere near the coder you are tenholde and I use your tools to help write my simple plug-ins and scripts. Most of my issues relate to understanding how to convert from VB.Net to C# and less about C# use in HS4. Here are some initial thoughts on items I have come across:- C# requires that the calls to HomeSeer names be case sensitive and do not always match what is in the various HomeSeer document repositories.
- I can no longer declare a variable as just type "object" for use in HS4. I seem to have to cast that variable as a specific HomeSeer type.
- I have to use a lot of casting to data types in the form of: (double)hs4.GetPropertyByRef((int)Custom_HomeSeer_Device_Enums.Attic_Temperature, HomeSeer.PluginSdk.Devices.EProperty.Value)
- I have to convert data types in a way I do not recalling having to be explicit about in VB.Net: int Attic_Temperature = Convert.ToInt32((double)hs4.GetPropertyByRef((int)Custom_HomeSeer_Device_Enums.Attic _Temperature, HomeSeer.PluginSdk.Devices.EProperty.Value))
- In VB.Net this used to work: Dim Pair As VSPair / Dim GPair As VGPair - But now I have to be explicit: HomeSeerAPI.VSVGPairs.VSPair Pair; / HomeSeerAPI.VSVGPairs.VGPair GPair;
I am sure these are terrible examples, but it is part of the difficulty I have come across. I spend some of my time using online code converters to move from VB.Net to C#. Usually it works, sometimes it does not.
I can't tell you how much I appreciate all that you do for this community! Please let me know how else I can help...
Thanks again!---------------------------------------------------
Jean-Marie G. Vaneskahian
jean@vaneskahian.com
---------------------------------------------------
Comment
-
Oh yes, I also figured out how to get a device name and change a device name using C#
Get Device Name
string Old_Device_Name = (Scheduler.Classes.DeviceClass)hs.GetDeviceByRef(Device_Reference)).get_Name(hs);
Set Device Name
((Scheduler.Classes.DeviceClass)hs.GetDeviceByRef(Device_Reference)).set_Name(hs, New_Device_Name_Stirng);---------------------------------------------------
Jean-Marie G. Vaneskahian
jean@vaneskahian.com
---------------------------------------------------
Comment
-
Originally posted by dlmorgan999 View PostYup. I'm running it as a service, so I stopped the service, copied the latest tenGlobalMethods.dll file to the HS4 root folder, edited the settings file, and started the service.
This sounds like an HS4 issue and nothing to do with your code, but I figured I would ask if you've tried using the extensions with C# before. Also, unless the documentation is just a bit behind (always a distinct possibility), this page makes it sounds like you still only use settings.ini for VB scripts.
This should be reported as a bug.tenholde
Comment
-
Originally posted by tenholde View Post
Comment
Comment