- Posted on
Wed Apr 08, 2020 6:40 pm
-
Gangotti
offline
-
- Posts: 81
- Joined: Dec 23, 2014
- Location: Las Vegas, NV
Colorado4Wheeler wrote:
I'm not sure what you are trying to do but you can assign an action to successful entry and have that action create or modify a variable.
Sorry for the delayed response to your question, I have lots of free time now so....
Basically I am trying to create setpoints for the levels of my ceiling fans. I currently am using phantom x10 dimmers (dimmers in indigo with no hardware in the house) that the keypad sets the brightness on. I have one for the Low, Medium, and High setpoint. I then have a trigger that monitors a temperature sensor in the room. If there is any change in temperature it runs a script that compares the actual temperature to the brightness of the dimmer and adjusts the speed of the fan. the temp is above the high setpoint it switches the fan to high, if it is below the setpoint it switches to medium. The same happens for the other 2 setpoints and their speeds. The problem I am running into is the x10 dimmer in indigo is doing some weird rounding calculation that makes it skips numbers for example if I try to set the dimmer to a value of 70 indigo sets it to 69 this happens throughout the range of values on the dimmer, 72 becomes 73, 75 becomes 76 and so on. This makes it impossible to set the temperature setpoint to a value like 70, 72, or 75 (in the cases pointed out above) doing it with variables gave me the control but I have no way to use the control page keypad to change the variable. Here is the trigger script I am running if it helps explain it better
# Get the temperature value from the sensor and get the setpoint value from the setpoint device.
RoomTemp = indigo.devices[1770450782].sensorValue # ID of the Temperature device
RoomHighSetpoint = indigo.devices[1254352989].brightness # "Office Fans High Setpoint"
RoomMedSetpoint = indigo.devices[66589004].brightness # "Office Fans Medium Setpoint"
RoomLowSetpoint = indigo.devices[1388629990].brightness # "Office Fans Low Setpoint"
# Log the values and the calculation results:
calculation_resulth = RoomTemp - RoomHighSetpoint
indigo.server.log("{} - {} = {}".format(RoomTemp, RoomHighSetpoint, calculation_resulth))
calculation_resultm = RoomTemp - RoomMedSetpoint
indigo.server.log("{} - {} = {}".format(RoomTemp, RoomHighSetpoint, calculation_resultm))
calculation_resultl = RoomTemp - RoomLowSetpoint
indigo.server.log("{} - {} = {}".format(RoomTemp, RoomHighSetpoint, calculation_resultl))
#calculate the difference and check to see if it is greater or equal to 0
if (calculation_resulth) >= 0: # Difference is greater than 0, so turn on the device
indigo.speedcontrol.setSpeedIndex(731663956, value=3) # turns fan to High
elif (calculation_resulth) < 0 and (calculation_resultm) >= 0: # Difference is LESS than 0, so turn on the device
indigo.speedcontrol.setSpeedIndex(731663956, value=2) # turns fan to Med
elif (calculation_resultm) < 0 and (calculation_resultl) >= 0: # Difference is LESS than 0, so turn on the device
indigo.speedcontrol.setSpeedIndex(731663956, value=1) # turns fan to Low
elif (calculation_resultl) < 0: # Difference is LESS than 0, so turn on the device
indigo.speedcontrol.setSpeedIndex(731663956, value=0) # turns fan to Off