Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

TellStick Duo

Questions and comments specific to a particular plugin should go here.
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: TellStick Duo

Post by Mastiff »

Hi again! I'm at the cabin now, and I have gotten part of the way. I have installed Nethome, and the Tellstick works very well there. I have (after quite a bit of messing around) managed to install Mosquitto as well, but I can't get that to work. I made a regular windows install, and I also installed the Visual Studio files, that were needed. I also copied your files from your website to the python directory of Mosquitto.

Edit: Got the service to surface the second time I installed Mosquitto - perhaps because I had installed Visual Studio this time? Watch this space, though. I'm sure I'll manage to get stuck again soon! :lol:
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: TellStick Duo

Post by Mastiff »

Didn't take long... ;) I have the Mosquitto service running and the client started in EG. In the MQTT plugin I see NetHomeServer as name, 127.0.0.1 as ip, 1883 as port and /nethomeserver as topic. It's listed as active thread. I guess that means that it's working, right?

It's the Nethome configuration I'm sure I haven't gotten right. I have set up two ports on 8005, UDP and TCP. Under Ports in NetHomeServer I see Eventbroker, and the two ports I have created. But of course nothing happens in EG. :) Any ideas would be welcome.

Edit: I telnetted into it, and at first it was just standing there without a connection. But pressing enter once again gave me:

error,2,No Instance specified
ok

So I wrote:

subscribe

And got:

ok

And then the events started flowing. So it seems I'm halfway there. :mrgreen:
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Hello,

So your test works fine with telnet, that is good, it proofs that you have everything correctly configured in NetHome.

The script MQTTevents.py does the following; it connects with NetHome in tha same way as you tried with telnet and it subscribes to events from the specified topic (I also have /nethomeserver both in the script as well as in the MQTT Client in EG). When an event arrives to the script it just publishes it to the Mosquitto message broker if it is different from the previous one. From there it gets received by other subscribers, e.g. the MQTT Client in EG.

How do you run/start the script? I added a line with 'print myEvent' so that you should be able to see what is happening. I have noticed that it can take a little while until the script gets its subscription working. If you still have the long delay at start (120 seconds as default) you can try to lower this value maybe to 5 seconds)

I just tried to run the script as a python script from inside EG and it works fine for me (I just had to adjust the ip-addresses since both NetHome and the message broker runs in a separate Pi but it should also work locally in the same machine)

Best regards, Walter
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: TellStick Duo

Post by Mastiff »

Walter, is it possible that I have gotten this stuff backwards? I copied your MQTTevents.py and mosquitto.py into the python directory of mosquitto. Should that be somewhere else? Also I have no idea how I start that thing! :lol: I just copied them there and sort of assumed/hoped/prayed that they would actually start firing of themselves. I am expecting you to give me a Padme to Qui-Gon quote: "You assume too much." :oops:

Edit: Oh, I couldn't name the command port in NetHomeServer /nethomeserver it didn't seem to like that /.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Yes, the script has to be started at startup somehow, you can do that by pasting the script into a python script in EventGhost. The problem will be that the only way you can stop it is by closing/restarting EG itself but this might be ok. I also just tested to put both files in EG root folder and then you can run from a command prompt with 'C:\Program Files (x86)\EventGhost>py MQTTevents.py' but I got some error messages as well. In the command prompt You can stop the script with Ctrl+Break

I have a new idea! Since you are interested to get the events into EG I can easily put together a script that skips the MQTT and instead creates events directly in EG. Do you think this will be ok?
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: TellStick Duo

Post by Mastiff »

Hallelujah! :mrgreen: That would be great! Then I can go back to the backup I took of this VM before I started messing around and do a clean install of NetHomeServer when I know a bit more about what I'm doing! Thank you very much! I'm guessing that won't be done in five minutes.

Btw I was thinking (without a brain, mostly): Is it possible to create a plugin for Telldus Duo by using the same USB serial driver as NetHomeServer is using? That would be the really amazing thing. But maybe that's not possible or practical? Just talking off the top of my head here...
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Is it possible to create a plugin for Telldus Duo by using the same USB serial driver as NetHomeServer is using?
I would love to but there are currently two major things in the way
- the native support is written in Java I think and is a part of NetHome so there is no separate driver (and I haven't spoken with the NetHome author about this either)
- the effort would not be limited only to replace the driver, it would require thatthe plugin takes over a lot of what is done by Telldus center like how I did it in the RFXrtrx plugin. You can just compare the source size of the TellStickDuo and RFXtrx plugins...and there is no salary for such work either
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: TellStick Duo

Post by Mastiff »

Well, I told you I was thinking without a brain! ;) But OK, I will just wait for a script that can take NetHomeServer signals. I'll be here until Sunday. Do you think there's any chance it can be done by then? :D
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Here, you can try this script, it works fine in my setup

1) Copy the code into a new macro/python script in EG

2) Change the ip so that it point to your NetHomeServer

3) Run it, it will print a line if connection is succesful

4) Wait for events...

I have added a global variable, eg.globals.th_abort, that allows you to end the script using another python command or script. Once the script is running, run another python command in EG with the code

Code: Select all

eg.globals.th_abort=True
and after a short while the script will disconnect from NetHomeServer and close itself down, you will get a printed notification about that

What else?
- Well, the events are as they come from NetHome and I added the same also as payload if any kind of python script is supposed to evaluate the content
- It receives events from NetHomeServer, it does not support sending commands to NetHomeServer (It is possible but maybe a plugin would in this case be better)

Code: Select all

#!/usr/bin/python

import time
import socket
from threading import Thread, Event

def create_event(msg):
    eg.TriggerEvent(
        msg, 
        payload = msg,
        prefix = 'OpenNetHomeServer')

def outgoing(outThreadEvent):
    event_Old = []
    cCount = 0
    try:
        skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        skt.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        skt.settimeout(5.0)
        skt.connect((hostName, portNbr))
        skt.sendall("subscribe\r\n")
        rsp = skt.recv(8)
        if rsp.find("ok") != -1:
            connectionError = False
        skt.settimeout(socketTout)
        print 'Connected with OpenNetHomeServer'
    except socket.error, e:
        connectionError = True
    
    while eg.globals.th_abort == False:
        tst = ''
        try:
            if cCount > 50:
                skt.sendall("\r\n")
                p = ''
                p = skt.recv(8)
                cCount = 0
                if p.find("ok") == -1:
                    connectionError = True
            else:
                tst = skt.recv(512)
                cCount += 1
        except EOFError:
            connectionError = True
        except socket.error, e:
            connectionError = True
       
        if not tst[0:5]=='event':
            tst = tst[tst.find('\n\r')+2:]
            
        if(len(tst.split(',')) > 7):
            e_lst = []
            e_lst = tst.split("\n\r")
            myEvent = ''
            for myEvent in e_lst:
                if myEvent != '':
                    myEvent = myEvent.split(',')
                    #print myEvent
                    if event_Old != myEvent:
                        event_Old = myEvent
                        create_event(str(myEvent))
                    else:
                        pass
        outThreadEvent.wait(0.3)
    print 'Outgoing thread ended'
    skt.close()
    outThreadEvent.wait(1.0)
    

# Main starts here -----------------------------------------------------------
time.sleep(2)
eg.globals.th_abort = False
debug = False

#NetHomeServer settings
hostName = '192.168.10.253'
portNbr = 8005
socketTout = 600
connectionError = True
event_Old = []

#Threads
outThreadEvent = Event()
outThread = Thread(
    target=outgoing,
    args=(outThreadEvent,)
)
outThread.start()

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

:oops:

And by the way, I had forgotten that, I made already a plugin for NetHomeServer back in 2010...it is available, I am just verifying that it is still working...
I think it is a good idea anyway to start with the script too get a bit familiar with the things
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: TellStick Duo

Post by Mastiff »

Impressive! Here I was expecing days, and it's minutes! :D Yessir, it's working! Thank you very much! Btw I really hate the forum software when copying code! It always adds a bunch of spaces first, so it messes up the indentations for Python!

But is it possible to move more of the stuff from the event to the payload? The event changes for temperature changes, I have a couple of sensors I would like to get as well. The temps are rather weird, btw. I highly doubt that there's -188 degrees in my living room! :shock: It's a bit chilly outside, but not in that level..

I would like to be able to send as well, yeah. But I'm guessing that's not a five minute job, huh? :mrgreen:

Oh, and I'll look at that plugin too.
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: TellStick Duo

Post by Mastiff »

I'm not getting any active threads in the NetHome plugin. But maybe I haven't done it correctly? Host 127.0.0.1 or 192.168.2.100 doesn't matter, port should be 8005 and time out 600 looks like what I've seen in the other script.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

You have to add an action as well, 'Start new or control a running action' and put that under Autostart

........

The script is rather stupid, it is providing the data raw "as is" and the temperature (and humidity) has to be calculated from that. The formula is

Temperature = (dataTemperature * 0.0625) - 50.0
Humidity = dataHumidity / 2

What kind of sensors do you have. I just checked the plugin that provides better formatting and correct calculations but it seems that it is currently only supporting ESIC/UPM (I have Oregon). The current plugin works with Pronto, Nexa, Nexa Learn, Nexa Fire and UPM/ESIC but it is really easy to add others as well (back in 2010 I did not have those sensors...)

BestR
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: TellStick Duo

Post by Mastiff »

Got it! It's pumping out data now. :) I have Oregon and Viking temp sensors, Oregon rain and wind, RollerTrol blinds and a bunch of Nexa wallswitches, door sensors and similar. And then I have a Fineoffset fridge sensor, with channel selection on dip switches. So I guess Fineoffset would cover both my Vikings and the fridge sensor, right?
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: TellStick Duo

Post by krambriw »

Good,
Just list here which types are working and which ones are not
Post Reply