This shows you the differences between two versions of the page.
| Next revision | Previous revision |
| indigo_2025.1_documentation:object_model_reference [2025/09/22 19:58] – created - external edit 127.0.0.1 | indigo_2025.1_documentation:object_model_reference [2025/10/22 20:09] (current) – [Boolean Functions] jay |
|---|
| |
| Returns ''True'' for an email that is constructed correctly, ''False'' otherwise. | Returns ''True'' for an email that is constructed correctly, ''False'' otherwise. |
| | |
| | === Boolean Functions === |
| | |
| | There are two functions available that will help scripters and developers in converting and using strings that represent boolean values, but are not ''True'' and ''False''. |
| | |
| | The first is ''str_to_bool(val: str)''. It will convert the string passed in to a boolean value and return it. We use the following map and it's reverse to do the mapping: |
| | |
| | <code> |
| | BOOL_MAP_TRUE: dict[str, str] = { |
| | "y": "n", |
| | "yes": "no", |
| | "t": "f", |
| | "true": "false", |
| | "on": "off", |
| | "1": "0", |
| | "open": "closed", |
| | "locked": "unlocked", |
| | } |
| | </code> |
| | |
| | ^ Command Syntax Examples ^ |
| | |<code>indigo.utils.str_to_bool("closed")</code>| |
| | |
| | ^ Parameters ^^^^ |
| | ^ Parameter ^ Required ^ Type ^ Description ^ |
| | |''val''| Yes | string |a string that represents a boolean value as mapped above| |
| | |
| | Returns ''True'' for true values, ''False'' for values that are false, and will raise an ''indigo.utils.ValueError'' if the input can't be successfully converted. |
| | |
| | The second is ''reverse_bool_str_value(val: str)''. It will return the string that represents the opposite boolean value using the map above. |
| | |
| | ^ Command Syntax Examples ^ |
| | |<code>indigo.utils.reverse_bool_str_value("closed")</code>| |
| | |
| | ^ Parameters ^^^^ |
| | ^ Parameter ^ Required ^ Type ^ Description ^ |
| | |''val''| Yes | string |a string that represents a boolean value for which we want the opposite string value| |
| | |
| | This example returns ''open'' since that's the opposite of ''closed''. It will raise an ''indigo.utils.ValueError'' if the input can't be successfully found. |
| |