-
Notifications
You must be signed in to change notification settings - Fork 0
scripting
This plugin is designed to work with Indigo 2022.1 and above and is therefore compatible with Python 3.10. I will do my best to account for other implementations where possible, but sometimes I will not be able to do that when it would cause a loss of functionality or break existing frameworks. I will also work to continue to keep the plugin current as Indigo, its Python implementation and EDS’ firmware versions evolve over time.
The plugin bundle identifier is: com.fogbert.indigoplugin.OWServer
Communicating directly with 1-Wire devices (for example, to set an alarm value) is both desirable and possible with the OWServer Sensor Command Framework. There are essentially three ways that you can accomplish this:
-
You can use the OWServer Plugin Settings Menu to initiate a one-time command to a sensor. From the Plugin Settings Menu select Send Command to 1-Wire Device. A dialog box will appear that will facilitate the operation. You will need to know four pieces of information:
- the IP address of the server where the sensor resides,
- the ROM ID address of the sensor itself,
- the name of the variable that you want to adjust, and
- the value that you want to write to the variable.
-
You can send a command to a sensor on a routine basis by initiating an Indigo Action Item. An example of this would be by using an Indigo Trigger.
- Create a new Indigo Trigger
- Set the Trigger and the Condition(s) like you normally would for any Trigger.
- Select the Action “Send Command to 1-Wire Device.”
- Complete the Send Command to 1-Wire Device communication dialog as described in item 1 above.
-
You can send a command to a sensor using a Python script. You’re on your own with respect to writing the script as a whole, but here is the helpful block of code that you will need to interface with the OWServer Sensor Command Framework. You need the same four pieces of information, only now you send them as a part of a payload dictionary.
As noted above, you can write values to individual sensor parameters to cause various things to take place. Below is a list of all the variables to which you can write data, and information about valid parameter values (and their meaning.) These values are not writeable from configuration dialog boxes, but they are writeable from several other places via the OWServer Sensor Command Framework (see Communicating Directly with 1-Wire Devices.)
pluginId = "com.fogbert.indigoplugin.OWServer"
plugin = indigo.server.getPlugin(pluginId)
props = {"server": "10.0.1.2",
"romId": "5D000003C74F4528",
"variable": "clearAlarms",
"value": "0"}
if plugin.isEnabled():
plugin.executeAction("sendToServerAction", props)
-
Activity Latch Reset
[Possible Values: 0, 1] - Resets the Activity Latch. Writing a 1 to this variable will reset the latch. -
Alarm Values
[Possible Values: ] - The OWServer Plugin allows you to set alarm values for sensors that support them. There are usually (always?) High and Low Alarm Values. The purpose of the alarm is to alert you when a condition (high or low) has been exceeded. You can set alarm values for sensors that support them by sending a 1-Wire Command to the sensor. For example: (When the sensor temperature exceeds 50 °C, an alarm will be tripped. When writing to a sensor, omit the[‘ and ‘].)
| Sample Alarm: Temperature High Alarm Value | |||
| Server | ROM ID | Variable | Value |
| 10.0.1.2 | 5D000003C74F4528 | [TemperatureHighAlarmValue] | 50 |
-
Alarm States [Possible Values: 0, 1] - Alarm states indicate that a corresponding alarm value has been exceeded (above the high alarm value or below the low alarm value.) When this occurs, the device’s corresponding [xxxxxxHighAlarmState] will be set to 1.
-
Calibration Key [Possible Values: ] - Calibration Key information coming soon.
-
Clear Alarms [Possible Values: 0, 1] - Sending the Clear Alarms command will reset all alarms associated with the device (it’s not presently possible in the 1-Wire framework to be able to clear individual alarms.) To send a clear alarms command, either select “Clear Sensor Alarms” within a device’s configuration dialog, or by sending a sensor’s [ClearAlarms] variable.
Clearing alarms has the ability to affect relay state and LED state depending on how they are configured. Additional information on the possible effects is available in Relay and LED and/or Conditional Search sections of the manual.
-
Conditional Search States [Possible Values: ] - There are two types of search commands. A normal search command performs a search with all devices participating. The alarm or conditional search command performs a search with only the devices that are in some sort of alarm state. This reduces the search pool to quickly respond to devices that need attention.
The OWServer Plugin does not currently support conditional searches natively, but that is hopefully that I’ll be able to add in a future enhancement. Until then, the OWServer Plugin does report conditional search states and provides a facility to clear conditional search states if desired. To clear conditional search states, either open a device’s configuration dialog and select “Clear [High/Low] Conditional Search State”.
-
Conversion Range [Possible Values: ] - Conversion Range information coming soon.
-
Conversion Resolution [Possible Values: ] - Conversion Resolution information coming soon.
-
Flip Flops [Possible Values: 0, 1] - The channel flip-flops are accessible through the OWServer Plugin. The power-on default for the conditional search settings and the channel flip-flops is all 1’s. Setting a channel flip-flop to 0 will make the associated PIO-transistor conducting or on; setting the flip-flop to 1 will switch the transistor off, which is identical to the power-on default.
-
LED Function [Possible Values: 0, 1, 2, 3] - The LED Function Value controls the operation of the LED (if so equipped.) There are four possible settings:
- On with alarms / off with no alarms. [0] 1) On with alarms / off with clear alarms command. [1] 1) On / off under command. [2] 1) Always off. [3]
-
LED State [Possible Values: 0, 1] - The current state of the LED (off [0], on [1]) The state of the LED is stored in non-volatile memory and is restored at power-up. Since the relay is latching, its state remains the same, even when power is removed.
-
Output Enable [Possible Values: 0, 1] - Output Control (OC) and Output Enable (OE) control the alternate use of a channel as output. For normal operation as analog input the OE bit of a channel needs to be 0, rendering the OC bit to a don’t care. With OE set to 1, a 0 for OC will make the channel’s output transistor conducting, a 1 for OC will switch the transistor off. With a pullup resistor to a positive voltage, for example, the OC bit will directly translate into the voltage equivalent of its logic state. Enabling the output does not disable the analog input. Conversions remain possible, but will result in values close to 0 if the transistor is conducting.
-
Output Control [Possible Values: 0, 1] - Output Control (OC) and Output Enable (OE) control the alternate use of a channel as output. For normal operation as analog input the OE bit of a channel needs to be 0, rendering the OC bit to a don’t care. With OE set to 1, a 0 for OC will make the channel’s output transistor conducting, a 1 for OC will switch the transistor off. With a pullup resistor to a positive voltage, for example, the OC bit will directly translate into the voltage equivalent of its logic state. Enabling the output does not disable the analog input. Conversions remain possible, but will result in values close to 0 if the transistor is conducting.
-
Output State [Possible Values: 0, 1] - Outputs are open collector MOSFET transistors with unidirectional overvoltage TVS diodes (48 volt). When the output state is high, the transistor is off. If there is pull-up current (such as a pull-up resistor), a voltmeter will read high. When the output state is low, the transistor is on and the output will read low. Note that if there is no pull-up current, the output may be off, but a voltmeter will not read high.
-
PIO Activity Latch State [Possible Values: 0-255] - The PIO Activity Latch State contains a value that represents the activity latch state of each of the DS2408’s 8 I/O channels. The OWServer Plugin takes the single value between 0-255 and imputes the activity latch state of each I/O (Note: this state is not available as of v0.8.00 of the plugin. It will be available in a future version of the plugin.)
-
PIO Output Latch State [Possible Values: 0-255] - The PIO Output Latch State contains a value that represents the state of each of the DS2408’s 8 I/O channels. The OWServer Plugin takes the single value between 0-255 and imputes the state of each I/O.
-
Power On Reset [Possible Values: 0, 1] - Sets the sensor to reset after poser loss (once power has been restored.) To set the sensor to reset after power loss, write a value of [1] to this variable.
-
Power On Reset Latch [Possible Values: 0, 1] - Resets the latch state upon power loss. When power is restored, the latch will be reset.
-
Pulldown State [Possible Values: 0, 1] - Each pin has a 1.5k Ohm, 0.5 Watt pull-down resistor which may be turned on using the Pull-down value byte (location 91). Setting a bit to high turns off the pull-down, low turns it on. This resistor may be used to read contact closures, simply connect one end of the contact to a voltage (i.e. 5, 12 or 25 volts) and the other end to the input pin. When the contact is closed, the input will read a 1, when it is open the pull-down resistor will cause it to read 0. The pull-down resistor should be turned off when a channel is being used as an output.
-
Pulse Counter Reset [Possible Values: 0, 1] - Resets the value of the pulse counter. To reset the pulse counter, write a value of [1] to this variable.
-
Relay Function [Possible Values: 0, 1, 2, 3] - The Relay Function Value controls the operation of the Relay (if so equipped.) There are four possible settings:
- On with alarms / off with no alarms. [0] 1) On with alarms / off with clear alarms command. [1] 1) On / off under command. [2] 1) Always off. [3]
-
Relay State [Possible Values: 0, 1] - The current state of the relay (unlatched [0], latched [1]) The state of the Relay is stored in non-volatile memory and is restored at power-up. Since the relay is latching, its state remains the same, even when power is removed.
-
RSTZ Configuration [Possible Values: 0, 1] - The RSTZ signal is configurable to serve as either a hard-wired reset for the PIO output or as a strobe for external circuitry to indicate that a PIO write or PIO read has completed. This setting configures RSTZ as either RST input [0] or STRB [1].
-
RTD Read Delay [Possible Values: 0, 1, 2, 3, 4, 5] - RTD (resistance temperature detectors) are used to measure temperature by correlating the resistance of the RTD element with temperature. Most RTD elements consist of a length of finely coiled wire wrapped around a ceramic or glass core. The element is typically fragile; therefore, it’s often protected inside a more durable probe for protection. The temperature element is made pure metal, most commonly platinum, nickel or copper. The material has a predictable change in resistance as the temperature changes, and it is this predictable change that is used to determine temperature.
When the RTD element is to be read, a current source of 420 μAmp is turned on, then the device is read, and then the current source is turned off (unless the RTD Read Delay is zero, in which case the current source is on all the time). The current source is on about 1 second for each read, plus 1.6 seconds, of the RTD element. Without any delay programmed, reads occur continuously. With a 1 programmed, reads occur about every 2.6 seconds. Delays and duty cycles are related as follows:
| RTD Read Delay and Duty Cycles | ||
| RTD Read Delay | Time Between Reads* (Seconds) | Duty Cycle |
| 0 | 1 | 56.30% |
| 1 | 2.6 | 100% |
| 2 | 3.6 | 41.40% |
| 3 | 4.6 | 32.10% |
| 4 | 5.6 | 26.50% |
| 5 | 6.6 | 22.00% |
-
UserBytes
[Possible Values: Any 2-bit Integer] - The User Byte fields (when present) are two bit registers, and they are non-volatile. -
VCC Control
[Possible Values: ] - VCC Control information coming soon.
The framework of the entire plugin environment as it relates to Indigo is very straightforward. Indigo talks through the plugin to the OWS which in turn talks to the 1-Wire network. Communication is bidirectional, and presently happens through routine calls to the OWS via [HTTP Get] commands. This communication via Indigo doesn’t preclude communication with the 1-Wire network by other means (such as via a direct browser session.) Users choose a predefined polling interval through the plugin, the plugin reaches out to the OWS and either requests data from it or sends data to it, interprets the results and passes the results back to user-defined OWServer devices (Indigo Custom Devices.) The plugin is also scriptable.
Under construction.
Copyright DaveL17 2023
This plugin is distributed under the MIT license; however the author reserves the right to change the license at any
time.