Author Topic: Telldus Tellstick Light control from VoxCommando (no  (Read 12223 times)

0 Members and 1 Guest are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #15 on: March 19, 2014, 10:21:19 PM »
Thanks for the updated xml.  It looks like it is getting interesting!  I will try to find time tomorrow to look at this properly and also to address the issues with V2 maps get/set.  One thing I found is that if you access map values using the variable format {M:mapname.key} instead of using the Map.Get action, the subsequent call of Map.Set does not cause VC to freeze.

I will be adding a Launch.Capture action to Version 2 as well (to read console output from launched programs) but I have other changes in the works so I won't be able to release an update for a while.

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #16 on: March 20, 2014, 05:10:23 PM »
Thanks James. I've tried replacing the Map.Get with a {M:mapname.key} reference but for me it is still freezing.

One thing I did mean to ask. I really wanted to convert my ON|OFF match in the regex to lower case but I couldn't find a regex code that worked  (I'm assuming your using .net behind the scenes) Is there a tolower equivalent in VC.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #17 on: March 20, 2014, 06:10:45 PM »
Yeah, I've been banging my head against this one all day.  The code is identical from VC1 to VC2 so the only difference is that VC2 is using .Net 4 and that means I had to change the sqlite dll that I'm using.  I guess there is a bug in the wrapper.  It is claiming that the database is locked when we try to do the write but I am 100% sure that I am not leaving the connection open.  I am still trying to figure out a work-around for this.

I don't really understand your question about lower-case though...  We do have actions (Results.Replace and Results.RegExReplace that you could use to modify last result, though I'm not sure why it matters.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="1618" name="replace on off lowercase" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <cmdString>ON OFF</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.Replace</cmdType>
    <cmdString>ON&amp;&amp;On</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.Replace</cmdType>
    <cmdString>OFF&amp;&amp;Off</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #18 on: March 20, 2014, 08:24:49 PM »
Thanks again. Those sort of problems can be really tricky and annoying especially when its not your code (I spent the morning trying to debug DirectShow so I feel your pain)

On the lowercase it is purely cosmetic (well audio cosmetic) the voice I'm using pronounces all capital words as individual letters. I'll try to see what I can do with Results.Replace.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #19 on: March 20, 2014, 08:58:45 PM »
That is certainly a good reason.  Python to the rescue!

You can just use .lower()

Here's an example.  All that is required is that the python plugin be enabled.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="169" name="python lowercase" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PY.ExecString</cmdType>
    <cmdString>result="HAHAHA.hoHoHo!".lower()</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

It is unfortunately not practical to have an action for every little thing like this so python is really perfect to handle all the "extra" stuff.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #20 on: March 28, 2014, 01:11:53 PM »
I have posted an update to Version 2 which includes the Launch.Capture action

http://voxcommando.com/forum/index.php?topic=1443.msg12499#msg12499

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #21 on: March 28, 2014, 08:33:30 PM »
Thanks James - that is really useful. I will update my script.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #22 on: March 28, 2014, 08:47:37 PM »
The get/set of maps should be working normally too, without freezing.

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #23 on: March 28, 2014, 09:07:36 PM »
Works really well and yes the freezing has gone - what was that in the end?

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.1.9-->
<commandGroup open="True" name=" tellstick" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="1515" name="Discrete" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{1} {2}</param>
        <param>1000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.Hidden</cmdType>
      <params>
        <param>C:\Program Files\Telldus\tdtool.exe</param>
        <param>--{2}  "{1}"</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>switchstate</param>
        <param>{1} </param>
        <param>{2}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>turn</phrase>
    <payloadFromXML phraseOnly="True" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\tellusdevices.xml</payloadFromXML>
    <payloadList>on,off</payloadList>
    <event>tell.lights</event>
  </command>
  <command id="1531" name="Toggle" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Map.Get</cmdType>
      <params>
        <param>switchstate</param>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>result="{LastResult}".lower()</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>Map.CreateTable</cmdType>
          <params>
            <param>switchstate</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Map.Set</cmdType>
          <params>
            <param>switchstate</param>
            <param>{1}</param>
            <param>off</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Map.Get</cmdType>
          <params>
            <param>switchstate</param>
            <param>{1}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Reset</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)Contains(B)</ifType>
      <ifParams>{LastResult}&amp;&amp;off</ifParams>
      <then>
        <action>
          <cmdType>Map.Set</cmdType>
          <params>
            <param>switchstate</param>
            <param>{1}</param>
            <param>on</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>on</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Launch.Hidden</cmdType>
          <params>
            <param>C:\Program Files\Telldus\tdtool.exe</param>
            <param>--on "{1}"</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Map.Set</cmdType>
          <params>
            <param>switchstate</param>
            <param>{1}</param>
            <param>off</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>off</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Launch.Hidden</cmdType>
          <params>
            <param>C:\Program Files\Telldus\tdtool.exe</param>
            <param>--off "{1}"</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <payloadFromXML phraseOnly="True" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\tellusdevices.xml</payloadFromXML>
    <phrase>please</phrase>
  </command>
  <command id="1541" name="Toggle" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>OK switching</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)==(B)</ifType>
      <ifParams>{Var.lights}&amp;&amp;on</ifParams>
      <then>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>lights</param>
            <param>on</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>lights</param>
            <param>off</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>Launch.Hidden</cmdType>
      <params>
        <param>C:\Program Files\Telldus\tdtool.exe</param>
        <param>--{Var.lights} "Lounge Light"</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.Hidden</cmdType>
      <params>
        <param>C:\Program Files\Telldus\tdtool.exe</param>
        <param>--{Var.lights} "Lounge Lamps"</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>switchstate</param>
        <param>Lounge Light</param>
        <param>{Var.lights}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>switchstate</param>
        <param>Lounge Lamps</param>
        <param>{Var.lights}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{Var.lights}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Lights</phrase>
  </command>
  <command id="1567" name="List" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Launch.Hidden</cmdType>
      <params>
        <param>tellusgetlist.bat</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>File.WriteLine</cmdType>
          <params>
            <param>tellusgetlist.bat</param>
            <param>del telduslist.txt</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>File.AppendLine</cmdType>
          <params>
            <param>tellusgetlist.bat</param>
            <param>"C:\Program Files\Telldus\tdtool.exe" --list &gt;&gt;telduslist.txt</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Launch.Hidden</cmdType>
          <params>
            <param>tellusgetlist.bat</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <action>
      <cmdType>PayloadXML.Clear</cmdType>
      <params>
        <param>payloads\tellusdevices.xml</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>PayloadXML.NewFile</cmdType>
          <params>
            <param>payloads\tellusdevices.xml</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType />
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>Map.DropTable</cmdType>
      <params>
        <param>switchstate</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.CreateTable</cmdType>
      <params>
        <param>switchstate</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>File.Read</cmdType>
      <params>
        <param>telduslist.txt</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Parsing list of devices</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>(.*)\t(.*)\t(ON|OFF)\r</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Map.Set</cmdType>
      <params>
        <param>switchstate</param>
        <param>{Match.{i}.2}</param>
        <param>{Match.{i}.3}</param>
        <param>True</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <action>
      <cmdType>PayloadXML.AddPair</cmdType>
      <params>
        <param>payloads\tellusdevices.xml</param>
        <param>{Match.{i}.2}</param>
        <param>{Match.{i}.2}</param>
        <param>False</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Parsed {#M} devices</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Refresh Tellus Devices</phrase>
  </command>
  <command id="1419" name="DiscreteAlternative" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>tell.lights</param>
        <param>{2}</param>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>turn</phrase>
    <payloadList>on,off</payloadList>
    <payloadFromXML phraseOnly="True" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\tellusdevices.xml</payloadFromXML>
  </command>
</commandGroup>

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #24 on: March 29, 2014, 07:08:11 PM »
I never really figured out what the cause was, but I knew it was related to the connection to the database so I rewrote all my connection handling to use a completely different approach.  Originally I was using static methods to perform sql queries.  Each of those calls would open a new connection, perform the query, and then close and destroy the connection.  All calls were being made from the same thread and employed a "using" block so there should not have been a problem, and with .net 3.5 there wasn't.

Luckily you don't need to know the reason for the problem in order to find a solution.  You just need to try something new.

My solution was to use an object (no static calls) that maintained an open connection to the database.  It was a lot of rewriting and of course it created some new challenges (based on the availability of that object to different areas of the program) but it worked, and it probably means that it is faster now since it isn't opening and closing the database for each action.  The only possible downside is that perhaps if VC crashed hard the database would think it was still open, but I'm trying not to think about that too much...

garryjw

  • $upporter
  • Contributor
  • *****
  • Posts: 59
  • Karma: 5
    • View Profile
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #25 on: March 29, 2014, 07:57:37 PM »
Never pays to think too much :-) I can't really think why swapping from a static method should have made a difference but the class approach definitely has advantages on speed.

It is definitely quicker. I used to notice (on V1) a distinct pause between the text spoken before the map write and  that afterward - not noticeable now on V2.


maxwel

  • Jr. Member
  • **
  • Posts: 39
  • Karma: 1
    • View Profile
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #26 on: March 24, 2018, 10:36:08 AM »
Hi garryjw,

i'm trying to use your xml file to control my light with Tellstick but it's not working for me! can you help me out please?

Thank you.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #27 on: March 24, 2018, 11:21:29 AM »
Hi maxwel,

I don't know that Garry is still alerted to new forum posts.

I can't really help you because I don't have a Telldus stick and you have not described your setup or what steps you followed. However I just wanted to say that Garry's solution would have been for older Telldus products -- specifically, I think, the Tellstick Classic and Tellstick Duo.

He is using the Telldus commandline tool tdtool.exe, which came with the TelldusCenter software at the time (http://telldus.com/resources/).

Hi I'm a newbie here but I thought this group I knocked up to control my Tellstick from VoxCommando might be useful to others. It uses the tdtool.exe command line utility which is installed as part of the Telldus Command Center installation and therefore doesn't need to use eventGhost.

You will need to set your switches up in Telldus Command Center first. I use a naming convention of room then type. For example Bedroom Light or Lounge Lamps.

Are you using one of those older Tellsticks and do you have that software installed and set up with your Tellstick?
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

maxwel

  • Jr. Member
  • **
  • Posts: 39
  • Karma: 1
    • View Profile
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #28 on: March 24, 2018, 01:35:58 PM »
Hallo nime5ter,

thank you for responding to my request, i am using the older Tellesticks, specifically, the Tellstick Classic and the software Tellduscenter is already installed. tellstick is also ready set up. i was trying to use the last xml file but i dont really know what i need to edit.

Merci for any help

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Telldus Tellstick Light control from VoxCommando (no
« Reply #29 on: March 24, 2018, 02:02:30 PM »
i was trying to use the last xml file but i dont really know what i need to edit.

What do you mean by "last xml file"? Can you please link to the forum post that contains the xml you are trying to use?

No matter which of Garry's Telldus command groups you imported, there are two main things you need to do for them to work:

1. Set up and create meaningful names for your devices in the Tellduscenter software.
2. In VoxCommando, execute the Telldus command called "List". (The voice command to execute that command is "Refresh Telldus devices".)

That is the command that will generate the payloadXML file with your device names as well as a separate map table that stores the state of each of your switches (e.g. is it ON or OFF).

Garry's other commands rely on the payloadXML and the map table.

In short:

Once you have Telldus set up as required, you should see if you can successfully execute the List command without errors.

Then you can look in the "switchstate" file in the Maps editor as well as at the payloadXML file that was generated (telldux.xml) to see if they display your device information.

If those look OK, the other commands should hopefully work for you.

If you see errors in your VC History window (orange lines), then roll over the line with your mouse to see what the error message is. You can also find the error message in your log file, if you have logging enabled in VC.
« Last Edit: March 24, 2018, 02:09:21 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)