more G-Labs products

Author Topic: Script to trigger Tellstick  (Read 7526 times)

August 15, 2014, 08:42:18 AM
Read 7526 times

flybob

  • *
  • Information
  • Newbie
  • Posts: 15
Hi,
I have a Tellstick (433Mhz TX, similar to X10) in a raspberry USB port.
I can control it using command line tools.

Now i want to control it from HG aswell, but since system calls / scripts is not something HG supports do you have any ideas how it could be done?

I'm thinking of using serial port to the USB port if i can figure out the Tellstick protocol, but if there is a way of using the already existing tools that would be so much easier!

September 10, 2014, 08:48:01 PM
Reply #1

flossy

  • *
  • Information
  • Newbie
  • Posts: 6
Im working on an interface for tellstick. I got switches, dimmers and temp/humidity sensors up and running and hopefully it will be ready for testing in a few days if you're interested.

September 11, 2014, 07:57:47 PM
Reply #2

flybob

  • *
  • Information
  • Newbie
  • Posts: 15
Please do share! I would love to contribute aswell if you need any assistance. I was just about to get down and dirty with it so you wrote this message just in time  :D

January 02, 2015, 04:39:00 PM
Reply #3

swaner

  • *
  • Information
  • Newbie
  • Posts: 21
+1. I would really appreciate if you share this code and I would also be happy to contribute. Even thought the code is not tested yet.

Btw, since this is my first post I would like to say thanks to Genie for making this great product opensource!

January 08, 2015, 09:07:35 AM
Reply #4

swaner

  • *
  • Information
  • Newbie
  • Posts: 21
So I did some development myself and got the basic functionalty to work by adding a new MigInterface :). The problem is to get this to work in Raspberry. I am using a third party dll which is written in c++ and from c# I am using [DllImport] in order to make this to work. This third party dll is opensource and written for both windows, linux and mac: https://github.com/telldus/telldus/tree/master/telldus-core.

Since I have never used Mono before I am confused, can I use the same dll or should I use the linux version? And how does Mono know what binary to use? The naming is different.

Please help, I am lost in the Mono world! :o
« Last Edit: January 08, 2015, 10:02:42 AM by swaner »

January 09, 2015, 12:26:59 AM
Reply #5

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
hi swaner,

telldus library compiled for Windows is binary incompatible with Linux (it is c++, not based on .Net). When compiling the telldus library for Linux, you will get a file with .so extension.
When running HG in Linux, mono will look for the .so library files to search for methods imported with DllImport. So all you have to do is copying both .dll and .so files in the HG folder so it will run on Windows and Linux as well.

g.

January 09, 2015, 03:54:49 PM
Reply #6

flybob

  • *
  • Information
  • Newbie
  • Posts: 15
I have the code from flossy working over here, it requires a new compilation of MIG.dll and uses tellduscore libs.

I'm no fan of C# so I'm happy to get it working at all, and to help you out I can provide you with a copy of the code flossy made. Could be useful to look at perhaps?
Here is his code:
https://github.com/florpan/HomeGenie

I would really love this to become a part of HG in the future, right now i recompile the MIG.dll after every update... since i don't have the time or the knowledge to finish the work.

From a PM send by flossy:
Quote
ok, needed to set up a proper fork and restructure it a bit, but it should be available here https://github.com/florpan/HomeGenie
I'ts public so you should be able to clone it, otherwise send me you github name and ill make sure you have access.

There are two parts, one lib for handling all calls (TelldusLib in Mig/Support libraries). and one MigInterface that adds tellstick as an interface in HG (Mig / Interfaces / Homeautomation / Tellstick.cs).

The lib is mostly a ripoff of the tellstick addon used for switchking, but the plan is a rewrite of that to remove some oddities in the lib.
It depends on the tellstick tools to be installed (tdtool etc for linux). I havent tested it on windows, but it should work there aswell since the pinvoke's for windows is included in the lib aswell.

Compile and dump the new Mig.dll and TelldusLib.dll in the homegeniefolder.
Also since there is no gui to turn it on, you'll need to do that manually by adding

      <Interface Domain="HomeAutomation.Tellstick" IsEnabled="true">
        <Options>
          <Option Name="Port" Value="" />
        </Options>
      </Interface>

to the <MIGService> part of the systemconfig.xml file.

I think thats all =) there are some weird stuff though. The sensors seem to pop up randomly, or my neighbours have a bunch of temperature sensors. That list need to be filtered somehow, i was thinking something simple like a comma separated textfield in the config where you can add the sensors you want to be available and then ignore the rest. Keep it running for a while and you'll see the liste of devices increasing in size.

January 20, 2015, 04:07:59 PM
Reply #7

swaner

  • *
  • Information
  • Newbie
  • Posts: 21
Thanks guys! Got it working now be adding the .so files  ;D.
I have also added the gui needed for activating the telldus interface.

I agree that it would be nice to have this included into HomeGenie, but since it depends on the tellstick tools be be installed first it's not really a perfect solution. Guess it's up to the project owners?

January 21, 2015, 07:48:35 PM
Reply #8

flybob

  • *
  • Information
  • Newbie
  • Posts: 15
Nicely done!
Great to have a GUI for the interface aswell.
I don't know of any other way than using the telldus core to get it working, perhaps that could be a prerequisite before being able to activate the interface in Homegenie, leaving it up to the user to install (with a minor help perhaps)

What do you think Gene?

Swaner: Can you please share your work so we can enjoy the fruits? =)

February 10, 2015, 02:59:50 PM
Reply #9

swaner

  • *
  • Information
  • Newbie
  • Posts: 21
Sorry for the very late reply. I would be happy to share the code. Modified flossys code slightly in order to simulate two way communication (pressing a remote control button triggers homegenie on/off).

I will try to make a forge this evening. It would be great if I could include just the MIGInterface and the Support Library to the main repo. Didn't realize how often this project get's updated, which off-course is a great thing ;)!

February 10, 2015, 06:57:30 PM
Reply #10

swaner

  • *
  • Information
  • Newbie
  • Posts: 21
Please try to download, compile and run from https://github.com/swaner/HomeGenie. Let me know if you have any issues or bugs.

February 20, 2015, 02:21:19 PM
Reply #11

Varazir

  • *
  • Information
  • Newbie
  • Posts: 2
Hello,

If I use the image for RaspberryPI I don't get this?
If not, how can implement it ? 

TIA
Daniel

February 23, 2015, 08:31:28 AM
Reply #12

swaner

  • *
  • Information
  • Newbie
  • Posts: 21
Hi Daniel

You have to download the sourcecode and compile the project in Visual Studio 2013 and manually move the files to the Pi. Search the forum for how to do this.

Also, the telldus-core lib needs to be installed on the raspberry pi. I followed this guide (in Swedish, but I guess most tellstick users are Scandinavian?): https://blogg.itslav.nu/?p=875. Step 4-6 are the only steps required for telldus-core lib.

February 23, 2015, 09:27:11 AM
Reply #13

Varazir

  • *
  • Information
  • Newbie
  • Posts: 2
Hi Daniel

You have to download the sourcecode and compile the project in Visual Studio 2013 and manually move the files to the Pi. Search the forum for how to do this.

Also, the telldus-core lib needs to be installed on the raspberry pi. I followed this guide (in Swedish, but I guess most tellstick users are Scandinavian?): https://blogg.itslav.nu/?p=875. Step 4-6 are the only steps required for telldus-core lib.

Thanks, I'll take a look at it.


KR
Daniel



February 27, 2015, 12:40:19 PM
Reply #14

flybob

  • *
  • Information
  • Newbie
  • Posts: 15
swaner:

Is it ready to be introduced to the master branch? How about a pull request to gene?
Would be better instead of us having a fork for tellstick support only.


edit:
Saw that you tried that just a few days ago and got a comment from gene 2 hours ago... so you are really close now, great!
« Last Edit: February 27, 2015, 12:46:52 PM by flybob »