Author Topic: endless loop and limitations to broadcasts  (Read 4220 times)

0 Members and 1 Guest are viewing this topic.

achel

  • Jr. Member
  • **
  • Posts: 39
  • Karma: 4
    • View Profile
endless loop and limitations to broadcasts
« on: December 11, 2014, 05:35:35 AM »
Hello
at the moment I have a timer in eventghost sending a event to vc every 4s. This tells vc to check the status of vertual switches on vera. From here vc would fire the ir to turn on/off based on the state of switch in vera.

I had a problem where only 3 of the 4 events was getting through so I put a delay of 4ms in between each bordcast
that fix it.

1st question is there a limit to simultaneous broadcast.
2nd question as I add more vertual switches could I slow down vc or vera if I'm constantly asking for updates on state on switches.

And is there a way to endless ask for status. I was thinking to make a self triggering  action with a delay but did not know if this is the best way to loop
« Last Edit: December 11, 2014, 05:37:53 AM by achel »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: endless loop and limitations to broadcasts
« Reply #1 on: December 11, 2014, 10:14:00 AM »
Hi Achel,

It seems that you are making your computer do a lot of unnecessary work.  Your overall approach is one that I would try to avoid.  Ideally, you should have as much of this being taken care of by your Vera and only when VoxCommando actually needs to do something that your Vera cannot (in this case send an IR signal) then Vera should tell VoxCommando to act.

Please describe the "big picture" from the user's point of view of what you are trying to accomplish.

Please let us know exactly what type of "virtual switch" you are talking about (provide links if possible) and how you are using it.

I had a problem where only 3 of the 4 events was getting through so I put a delay of 4ms in between each bordcast
that fix it.

1st question is there a limit to simultaneous broadcast.
On the request of another VC user, VC will ignore subsequent back to back identical UDP messages that it receives because there was a problem with some kind of "UDP echo" on some networks.  I do not have access to the exact source code right now, but I believe it would check if the message was identical to the last message and if the time since the last message was less than 50 milliseconds, then it would discard the second message.  In any case you should not be doing what you are doing so it is not really important.  If you really do need to send the same repeated event from EventGhost to VoxCommando you will need to implement a short delay between messages.  I don't really understand why this is an issue since you said you were only sending it every 4 seconds.

2nd question as I add more vertual switches could I slow down vc or vera if I'm constantly asking for updates on state on switches.

And is there a way to endless ask for status. I was thinking to make a self triggering  action with a delay but did not know if this is the best way to loop
Yes, this is bad.  See the beginning of my post.

If you want to repeat an event in VC you should do it within VC using VC.SetEventTimer instead of using EventGhost, but if you are going to do this it should not be done on such a short interval.

achel

  • Jr. Member
  • **
  • Posts: 39
  • Karma: 4
    • View Profile
Re: endless loop and limitations to broadcasts
« Reply #2 on: December 11, 2014, 07:01:58 PM »
Quote
Please describe the "big picture" from the user's point of view of what you are trying to accomplish.

Oh no, you'd of wished you'd never asked.

It's to have Voxcommando and eventghost to be the heart of the home automation to interact between software and to carry out commands.

The goal is to have whole house integration, I'll explain
Kitchen

Lights: Control based on if occupied or current lux of the room and the task being performed. Example: Preparing dinner would have a well lit room so you could see where your working or if it was the middle of the night and you were just getting a drink there would be night lighting.

Food organization and stock maintenance of the home http://www.livingcookbook.com/Product/Features when stock cupboard is opened the monitor in the kitchen will automatically open program for stock adjustment. (trying to find a way as you can export stock lists but there in fdx/fdxz I don't know these formats I think they are unique to that software but I printed them off as pdf and then copy and pasted into notepad, a bit clunky but an experiment and I used VC to read the lines. My plan was to ask vox how much we had of X item.)
Without being an advertisement the software also tells you what to order based on the menus created for that week and the price of the shopping it adjusts the stock using the menus you created for that week and it does other things as well.

Food preparation

On returning home from work or school the user will simply say to Vc "I'm ready to prepare dinner"
Vc will know what dinner is because it will be on a formatted notepad for instance say line 4 is always dinner  (this is untested this is how I think it should work) which will trigger the script which will be timed and go something like this Vc would say "Tonight we are having pasta and meatballs this meal takes 25 minutes to cook and be ready at 7:25pm please preheat oven to 190c" and I know my oven takes at most 11 minutes to preheat, so in 11 minutes Vc will say "place meatballs in oven" etc
I played with the idea of having a thermometer in the oven so the preheat would be triggered by the thermometer. This guy here making a probe thermometer so you can watch your food cook on the web http://forum.arduino.cc/index.php?topic=51947.0 just a fun read if your into arduino stuff.

Living room
In this room I have a UB1 - USB Boundary Microphone  which I read on the forum one of the members recommended I use it with Vc in sp mode I use a wii remote for a gyroscopic mouse and using a script for glovepie http://glovepie.org/ when I press the home key on the wii remote it turns it into a controller for XBMC. I then use the + and - which Vc triggers volume to my amp my amp doesn't have anyway of communicating to it apart from IR. The 1 key on the wii remote acts as a push to talk with Vc so you just press and hold 1 to talk to Vc and release puts it back into red mode. I will implement later to mute the amp when I push the button. I use the hook plugin because I didn't know how to get Vc to read joystick presses as my wii remote drivers make it appear as a joystick I use a program called Xpadder http://xpadder.com/  to convert the joystick presses into keyboard presses. If anyone is interested in the multi mouse/joystick script just ask its not mine but I copied and pasted it from two sources and my son made it work.

Lighting

The lighting is also automated depending on how the room is being used. I use a projector with high lumens for my everyday viewing so when watching a movie the lights will dim and when pausing the lights will raise up again.

Entertainment

I use XBMC with mediaportal as tv server with a colossus to capture sky and feed the channels to mediaportal tv server. I hope to use here all Vc wonderful things the user can play with e.g play artist, watch X film and show me newly added.
Also here you can ask Vc to show you new film releases, open I like playing games so I would say whats happening in the MMO world and she would open my favourite news website.

Communicating with Vc
I will use voxwave in bedrooms, kitchen with tablets. Each voxwave will be identified individually by its IP so Vc will know which room is talking to it.
I'm hoping to use Skype to communicate with Vc from outside the house.

House environment
Temperature of each room is monitored by Vc I was hoping to write each temperature of each room to a notepad like monitoring it and then opening it in a graph. I have created certain scenes with the help of you forum guys that fit in with how we want our heating for the house. Here is one example:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.5-->
<command id="362" name="Allen weekend work" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="81" loop="False" loopDelay="0" loopMax="0" description="Allen weekend work">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>04,05,06,09,02,03,&amp;&amp;{DtCustom.HH}</ifParams>
    <then>
      <action>
        <cmdType>Group.Enable</cmdType>
        <params>
          <param>aircon switch on</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Group.Enable</cmdType>
        <params>
          <param>aircon switch off</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>toggleoff</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.Pause</cmdType>
        <params>
          <param>100</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Group.Disable</cmdType>
        <params>
          <param>heat off</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.StopMacro</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>froomtemp1</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.EnableGroup</cmdType>
        <params>
          <param>heat off</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <event>aircon switch from eventghost</event>
</command>
I have certain scenes for going to bed that turn off projector, amp and in the future I hope we will put night lights on, arm the sensors etc.
I will stop there because I think I have gone on enough. I have other plans for other rooms I was planning to have a Vc for each room for example Vc kitchen, Vc living room they manage there own rooms.
 Ideas: for using tasker for informing Vc of whether someone is at home or not with GPS or maybe use a ping so when the phone is near my house tasker turns the wifi on and sends a message to Vc.

Quote
Please let us know exactly what type of "virtual switch" you are talking about (provide links if possible) and how you are using it.

This is the virtual switch I use in vera https://apps.mios.com/plugin.php?id=1408
The way I have set this virtual switch up all my IR stuff has a switch so I will use my denon amp as an example.
Virtual switch named Denon amp in vera ui5
Then eventghost broadcasts to Vc every 4 seconds I done this because if someone was to turn a virtual switch on versa webpage there would only be a 4 second delay at most from pressing the button on the webpage and Vc sending the ir. The eventghost broadcast  triggers this
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.5-->
<command id="335" name="denon amp  get status" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Vera.Get.Status</cmdType>
    <params>
      <param>{M:Vera1D.denon amp}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.TriggerEvent</cmdType>
    <params>
      <param>denon amp</param>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>denon amp switch from eventghost</event>
</command>
which then triggers an event with the state of the switch as a payload to this
Code: [Select]
[<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.5-->
<command id="377" name="denon amp  switch convert" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{1}&amp;&amp;1</ifParams>
    <then>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>denon amp on</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>VC.TriggerEvent</cmdType>
        <params>
          <param>denon amp off</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <event>denon amp</event>
</command>/code]



which then triggers an event depending on the state of the switch on/off
this is the code for on
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.5-->
<command id="396" name="Denon on switch" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>UsbUIRT.Send</cmdType>
    <params>
      <param>{M:denonAmp.on}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.DisableGroup</cmdType>
    <params>
      <param>Denon on switch</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.EnableGroup</cmdType>
    <params>
      <param>Denon off switch</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>denon amp on</event>
</command>
and this is off
Code: [Select]
[<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.5-->
<command id="376" name="Denon off switch" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>UsbUIRT.Send</cmdType>
    <params>
      <param>{M:denonAmp.off}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.DisableGroup</cmdType>
    <params>
      <param>Denon off switch</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.EnableGroup</cmdType>
    <params>
      <param>Denon on switch</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>denon amp off</event>
</command>/code]
The only variation of the switch is for the projector which needs two on ir blasts to turn it off
I appreciate your time you took to read this. I thought that Vc would be more than able to deal with the logic of what I hope to achieve. I did not like the way vera handles its scenes and did not feel comfortable using it. I was hoping to use Vc for all the control of scenes and just use vera as a way to communicate with the zwave nodes.
Please let me know whether I am over estimating what I thought I could achieve with Vc. I don't want to get down the line and achieve lots of slow down and headache because I am not using Vc as intended. My ideas came from what I read on the forums and the wikki  what the actions did.

Edited: Tried to stop the need for eventghost to send to Vc asking for status of virtual switch but vera doesn't send a notification to Vc telling it has changed. There is probably something I am not doing to the settings of the switch to make it behave the way I want. I get notifications about other nodes, just not my virtual switches.
« Last Edit: December 12, 2014, 06:15:03 AM by achel »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: endless loop and limitations to broadcasts
« Reply #3 on: December 12, 2014, 10:32:05 AM »
Yeah, I meant "big picture" in terms of your virtual switch, not your entire plan for world domination.  >:D

Anyway, too much information is better than not enough.

The best way to handle this is just to use events.  The Vera plugin can generate events for just about any scene or device and it will be much, much, much more efficient, and will be almost instantaneous as opposed to having to wait up to 4 seconds.  It will leave both VC and Vera free to handle other things, and will reduce your network and ZWave traffic.

The only problem here is that the Vera does not seem to recognize what category the virtual switch is (probably because it is using a non-standard device type of urn:schemas-upnp-org:device:VSwitch:1

Vera assigns these devices a category of 0 and a subcategory of -1.  I don't know what these numbers mean other than probably "unknown" or "error" but we can still use them.  Go into your Vera plugin settings and do the following:

1 - Makes sure "Generate Events" is checked.  You should already have this set if you are using motion events etc.
2 - Check "Show Event Customization.  This is where we will add the category info for the virtual switch
3 - Add a new row with the following information (also shown in the attached image)
- Category: 0.-1  (that is zero point minus one, with no spaces)
- Variable: status
- EventName: Device  (you could change this if you like to VSwitch for example)
- "0 Val" and "1 Val" can be set to 0 and 1 or On and Off if you prefer

4 - Finally, and this is very important... CLICK SAVE OPTIONS!

Now you should see events in the history window when your virtual switches turn on or off and you can assign these events to macros that send your IR codes etc.
« Last Edit: December 12, 2014, 10:48:23 AM by jitterjames »

achel

  • Jr. Member
  • **
  • Posts: 39
  • Karma: 4
    • View Profile
Re: endless loop and limitations to broadcasts
« Reply #4 on: December 12, 2014, 01:12:27 PM »
fantastic thanks a bunch the  vswitch working a dream now