Help With Conversion

ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Help With Conversion

Post by ckeyes888 »

Hoping it may be possible using the Device Extentions plugin to convert a device state like 100.00%, or less, to a simple integer, 100, 90, 5 etc? I'm trying to trigger from a luminance sensor value.
The state always includes the .00% at the end.

Thanks,

Carl
howartp
Posts: 4559
Joined: Thu Jan 09, 2014 4:43 pm
Location: West Yorkshire, UK

Re: Help With Conversion

Post by howartp »

Are you sure the value actually includes the %?

Indigo supports readings having two values. The raw value (eg 100) and the UI value (eg 100% or 100’c).

The figure you see will generally be the UI one, but try creating a trigger and you’ll often find it allows <100, >85 etc.


Sent from my iPhone using Tapatalk Pro
User avatar
Colorado4Wheeler
Posts: 2794
Joined: Mon Jul 20, 2009 10:48 am
Location: Colorado

Re: Help With Conversion

Post by Colorado4Wheeler »

As Howard says, the % is generally a UI value, but you can still do this with DE by using the 'Convert to String' option and chopping off the last character. You can also use the String to Number conversion to get what you are looking for - which could be better since it will allow you to convert to an integer (no decimals) or a float (decimals) and you can decide how many decimal places you want it to have.
Screen Shot 2018-07-04 at 6.58.36 AM.png
Screen Shot 2018-07-04 at 6.58.36 AM.png (66.25 KiB) Viewed 2654 times
My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here
ckeyes888
Posts: 2438
Joined: Thu Nov 26, 2009 2:41 pm
Location: Kalispell, MT

Re: Help With Conversion

Post by ckeyes888 »

The device state shows the % sign when using the sensorValue (UI Value), but not when just using sensorValue.
Seems to be working fine.

Thanks,

Carl
User avatar
Colorado4Wheeler
Posts: 2794
Joined: Mon Jul 20, 2009 10:48 am
Location: Colorado

Re: Help With Conversion

Post by Colorado4Wheeler »

ckeyes888 wrote:The device state shows the % sign when using the sensorValue (UI Value), but not when just using sensorValue.
Seems to be working fine.

Thanks,

Carl
Yup, that's exactly what you should be seeing.
My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here
Post Reply

Return to “Device Extensions Plugin”