Change variable to integer (I think)

Posted on
Tue Aug 15, 2017 8:43 am
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Change variable to integer (I think)

Hi
I am using HTTPD plugin to report my weight from a Withing scale, and i get my weight in as a variable.

And i want to use this variable in a trigger as a condition "If variable is between xxx and xxx"

And this do not work, and i think its beacouse the variable is not an integer

Can this be and whats the easyest way to convert the variable to a integer? Or use this variable and convert to a new variable that i can use?

The variable is like this 85.81 so its all numbers with a dot and two decimals

Thanx

Martin

Posted on
Tue Aug 15, 2017 8:48 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Change variable to integer (I think)

Post the script you've got now and we'll tell you what needs to be fixed.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Aug 15, 2017 10:19 am
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Re: Change variable to integer (I think)

I actual don't have a script, I just used a indigo trigger and set a condition


Skickat från min iPhone med Tapatalk

Posted on
Tue Aug 15, 2017 12:02 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Change variable to integer (I think)

I think the trigger condition code auto-converts, so that's not the issue.

I'm guessing the issue is that the number from the scale is in US floating point format (with a ".") and your European locale is causing Indigo to expect a "," as the floating point separator.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Aug 15, 2017 12:58 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Change variable to integer (I think)

I'm not sure the number format is the issue. A simple way of testing it is to manually change the variable value to 85,81 (or whatever would cause the trigger to fire) and see if that works. My quick test here switching my preferred language to Swedish didn't seem to change how the number is used, though I'll admit I'm not fully versed in making my system completely localized.

Take screenshots of all 3 tabs in your trigger tabs (Trigger, Condition, Actions) so we can see how they're configured.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Aug 16, 2017 1:51 am
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Re: Change variable to integer (I think)

Hi

Here are the images, what you cant see in the images is that there is two zeros behing the dot

I tried to manual change the "httpd_withings" variable, but it wont fire

I altso tried to change the condition to between 87 and 89 without dots, and the change the "httpd_withings" variable to 88 still no fire?

//Martin
Attachments
indigo_3.PNG
indigo_3.PNG (45.51 KiB) Viewed 2899 times
indigo_2.PNG
indigo_2.PNG (39.49 KiB) Viewed 2899 times
indigo_1.PNG
indigo_1.PNG (39.35 KiB) Viewed 2899 times

Posted on
Wed Aug 16, 2017 9:21 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Change variable to integer (I think)

Let's do some tests. First:

  1. Disable the trigger or schedule that's inserting the value of the device into the httpd_withings variable so it's not changing automatically
  2. Change the Condition to Always
  3. Change the value of cbweight to something other than "yellow"
  4. Change the value of httpd_withings to 85.0, be sure to tab out of the field (you should see the trigger fire and cbweight should change to yellow)
  5. Again change the value of cbweight to something other than "yellow"
  6. Change the value of httpd_withings to 86.0, be sure to tab out of the field (again you should see the trigger fire and cbweight should change to yellow)

If something didn't work, let us know which step didn't work. If everything worked, then:

  1. Change the Condition back to between 87 and 89 (shouldn't need to use the decimals)
  2. Change the value of cbweight to something other than "yellow"
  3. Change the value of httpd_withings to 87.5, be sure to tab out of the field (you should see the trigger fire and cbweight should change to yellow)
  4. Again change the value of cbweight to something other than "yellow"
  5. Change the value of httpd_withings to 86.0, be sure to tab out of the field (this time you shouldn't see the trigger fire and cbweight shouldn't change)

If something didn't work, let us know which step didn't work. If everything worked, then the trigger is configured correctly and should be working fine. Turn the trigger or schedule that's updating httpd_withings back on and watch it to see that its working correctly.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Aug 19, 2017 2:39 am
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Change variable to integer (I think)

Hi

Idid try to do what you told me, and its working when changing the variable manually

But the weird part is, that when the httpd plugin updates the variable, it do not trigger.

And if i let Httpd plugin update the value, and directly after change the variable manually it do not trigger either. It seems like i need to change the variable value to text and back to numbers to get it to trigger??

/Martin

Posted on
Sat Aug 19, 2017 8:52 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Change variable to integer (I think)

My guess is that there's something getting inserted into the variable value that's keeping Indigo from casting it to a number (extra spaces at the beginning or end, etc). Otherwise it would work (as you've proven by manually editing the value).

When the plugin updates the variable, edit the variable and select everything that's in the edit field and then paste it into a code tag in a reply.

To put it in a code tag, first click the Code button above the post edit field (in the Selection style bar), then paste in the value. It's important to get ALL of the variable value from Indigo in between the Code tags so we can see what's really in it.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Aug 20, 2017 1:18 am
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Re: Change variable to integer (I think)

Hi

Here is the latest variable, sent by httpd plugin

Code: Select all
 88.65


You were right there is a blank before the numbers, didn't see that :-)

When i remove the blank, its triggers.

Is there any easy way to remove that blank automatic, like with a small script or something

Thanx

/Martin

Posted on
Sun Aug 20, 2017 1:53 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Change variable to integer (I think)

The HTTPD plugin author needs to tidy that up so that blank spaces before and after are handled and removed.


Sent from my iPhone using Tapatalk Pro

Posted on
Sun Aug 20, 2017 4:02 am
Gusten offline
Posts: 171
Joined: Dec 30, 2015
Location: Sweden, Gothenburg

Re: Change variable to integer (I think)

I checked another variable that httpd sets from another IFTTT source and its altso have the blank before the variable. I will make a note on the httpd forum of this. And if anyone knows of a way to get rid of the blank in a variable please let me know

/Martin


Skickat från min iPhone med Tapatalk

Posted on
Sun Aug 20, 2017 5:24 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Change variable to integer (I think)

howartp wrote:
The HTTPD plugin author needs to tidy that up so that blank spaces before and after are handled and removed.


Not so fast there. The HTTPd plugin isn't adding that space. I'm not sure it should be removing it either. I'm very reluctant to have the HTTPd plugin arbitrarily changing data.

The IFTTT applet is sending the weight string with the leading zero, it appears. That's bad in this case, but might be required in other uses. The RIGHT answer is to get it to stop doing that, if at all possible.

I don't have any Withings devices, so I can't look at the IFTT applets to see what configuration options there are. Is it possible that the OP has inadvertently added that space to the URL string specified in IFTTT that's sending the data to Indigo?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Aug 20, 2017 5:28 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Change variable to integer (I think)

I never said you were adding it, but it's a perfectly appropriate suggestion to provide the option to remove it.


Sent from my iPhone using Tapatalk Pro

Posted on
Sun Aug 20, 2017 5:28 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Change variable to integer (I think)

Gusten wrote:
I checked another variable that httpd sets from another IFTTT source and its altso have the blank before the variable. I will make a note on the httpd forum of this.


I'm not getting any blanks in the variables I've set from IFTTT. Can you post an image of the IFTTT action you're using to send the variable(s) to Indigo?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Who is online

Users browsing this forum: No registered users and 4 guests

cron