Project

General

Profile

Bug #520

Failed Replace Device Variables <$device id|field$>

Added by TechNovation about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DomotiGa3
Target version:
Start date:
12/15/2014
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

Description

I made a new action that sends an e-mail with the status of a set of device fields in the message.
The following text is in the box:

Tamper:
Frontdoor: <$68|2$>
Hallway: <$21|2$>
Livingroom: <$134|2$>
Kitchen: <$19|2$>
Attic: <$20|2$>

Motion & Last Changed:
Frontdoor: <$68|1$> <$68|lastchanged$>
Hallway: <$21|1$> <$21|lastchanged$>
Livingroom: <$134|1$> <$134|lastchanged$>
Kitchen: <$19|1$> <$19|lastchanged$>
Attic: <$20|1$> <$20|lastchanged$>

Up to a certain point it is all OK. It replaces som of the device variables correctly but stops at a certain point. What I get as output is:

Tamper:
Frontdoor: Tamper
Hallway: Tamper
Livingroom: Tamper
Kitchen: Tamper
Attic: Tamper

Motion & Last Changed:
Frontdoor: Normal 12/15/2014 14:08:46
Hallway: No Motion 12/15/2014 20:30:49
Livingroom: No Motion <= lastchanged value is missing
Kitchen: <$19|1$> <$19|lastchanged$> <= device values not replaced
Attic: $20|1$> <$20|lastchanged$> <= device values not replaced

I stepped through the code in Events.Module in the function ReplaceDeviceVar.
The replacing of the device variables goes OK, up to (and including)
Livingroom: <$134|1$>
it seems to make the proper replacement into the variable: sReplace, and into the textline
sText = Left(sText, rMatch[0].Offset) & sReplace & Mid(sText, rMatch[0].Offset + Len(rMatch[0].Text) + 1)

But then apparently iLimit =1 and I get the message in the debug log :
2014/12/15 22:00:52 ERROR: Broke loop in Events.ReplaceDeviceVar parsing 'Tamper:

Anyone got an idea what is going wrong?

History

#1 Updated by danfos about 4 years ago

  • Assignee changed from Alexie to danfos
  • Target version changed from 1.0.019 to 1.0.020
  • Resolution set to Fixed

Yes, having coded this I have an idea what is going wrong.

The idea was that there could be a bug in the code by which the loop would never exit and this iLimit variable is just counting down from 10 and when zero it will give toy this error.

The right "work-around" is to increase the 10; I never imagined more that ten values should be replaced but your example makes perfectly sense.

Fix implemented in commit:3bd9e579

#2 Updated by Alexie about 4 years ago

  • Status changed from New to Feedback

It is fixed in the BETA branch, and will be available in 1.0.020 ... Only it isn't recommended to install the BETA in a "production" system, then it is wiser to manually change 10 to 999 in your code.

#3 Updated by TechNovation about 4 years ago

Thanks Danfos & Alexie,

Increasing that value indeed did the trick (I raised it to a 100, that should be sufficient for me at the moment :) ).

A bit of topic, but maybe you are willing to answer the following 2 questions:
  1. You may have noticed from this Issue that I tried to send out a nice table with values, but the text does not really work nicely with "TAB" indents (i.e. not everything is nicely aligned underneath each other and you have to try to solve it by adding spaces). Is there a way to add a <TAB> character in the message so it nicely aligns?
  2. We are able to send out e-mails with Domotiga and it is also possible to check for new messages, but is there also an option to have a certain e-mail message "string" to trigger an event in Domotiga ? So just as an example, could I trigger an event to raise the central heating temperature setpoint by sending an e-mail message to Domotiga?

#4 Updated by danfos about 4 years ago

You may have noticed from this Issue that I tried to send out a nice table with values, but the text does not really work nicely with "TAB" indents (i.e. not everything is nicely aligned underneath each other and you have to try to solve it by adding spaces). Is there a way to add a <TAB> character in the message so it nicely aligns?

We could add code to replace \t by a Tab character but why not make the step to HTML so you can really use a table?
Thinking about this the edit window is probably small but you can prepare the text in an editor and paste it.

We are able to send out e-mails with Domotiga and it is also possible to check for new messages, but is there also an option to have a certain e-mail message "string" to trigger an event in Domotiga ? So just as an example, could I trigger an event to raise the central heating temperature setpoint by sending an e-mail message to Domotiga?

Control by email...

Question: How do you check for new messages? Is that through gmail?

#5 Updated by TechNovation about 4 years ago

We could add code to replace \t by a Tab character but why not make the step to HTML so you can really use a table?

The \t idea was in line with what I was initially thinking of, but your suggestion to use HTML does sound like a nice and elegant way to go too (I did not think of that one). I suppose taking the HTML approach would require no rework in Domotiga code, right (I should just put some HTML code in the edit window and send it to a mail client with HTML capabilities)? Then it would just be a matter of pollishing up my HTML skills a bit, but I suppose that should not be too big of an issue :).

Thinking about this the edit window is probably small but you can prepare the text in an editor and paste it.

Indeed that edit window is really small (also for other tasks), I certainly would not mind if it increased a bit in size. For now indeed a text editor helps out quite nicely.

Control by email...

Yep, that was indeed the idea. Hope it doesn't sound to weird :)

Question: How do you check for new messages? Is that through gmail?

Yes, that is indeed what I'm currently using as this seems to be one that works OK with Domotiga at the moment

#6 Updated by rdnzl about 4 years ago

  • Status changed from Feedback to Closed

Also available in: Atom PDF