How to use displayStateValRaw ?

Posted on
Tue Mar 01, 2016 2:57 pm
Juju offline
User avatar
Posts: 108
Joined: Aug 31, 2011
Location: Toulouse - FRANCE

How to use displayStateValRaw ?

Hello,

I have defined which state to use in the device list UI by using the method getDeviceDisplayStateId.
The selected state display as follow : 1234 kWh.
I need to extract the numerical part of this state (in the exemple : 1234). I think displayStateValRaw is the best solution to do this, but this method return also 1234 kWh.

Somebody could explain me how displayStateValRaw works ?
Thanks.

Julien

Posted on
Tue Mar 01, 2016 3:35 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How to use displayStateValRaw ?

When you update a state, you can pass in an optional UI value:

Code: Select all
exampleTempFloat = 78.5
exampleTempStr = u"78.5° F"
dev.updateStateOnServer("aTempState", exampleTempFloat, uiValue=exampleTempStr)


When you set aTempState to be the displayStateId, then the displayStateValUi becomes exampleTempStr and displayStateValRaw becomes exampleTempFloat.

More generally: when you set a state value and pass a uiValue, you end up with two states: the state name and the state name + ".ui". If the state happens to be the display state, then displayStateValUi is a shortcut to the state.ui value and displayStateValRaw is a shortcut to the state value.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Mar 02, 2016 1:48 am
Juju offline
User avatar
Posts: 108
Joined: Aug 31, 2011
Location: Toulouse - FRANCE

Re: How to use displayStateValRaw ?

Thanks Jay, clear for me.

Julien


Envoyé de mon iPhone en utilisant Tapatalk

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 7 guests