Here is a script that illustrates the problem. I set the initial colorTemp to 2967. The initial bulb_name.states['colorTemp'] value = 2967. This is correct. (In fact, I get the correct bulb_name.states['colorTemp'] value on the first request every time, whether it is 2967 or any other value.)
I then set the colorTemp value to 2237. The bulb changes to 2237. The colorTemp value in the Indigo 7 app Device List updates and shows 2237. But the bulb_name.states['colorTemp'] value is still = 2967.
I then set the colorTemp value to 6410. The bulb changes to 6410. The colorTemp value in the Indigo 7 app Device List updates and shows 6410. But the bulb_name.states['colorTemp'] value is still = 2967.
I then set the colorTemp value back to 2237. The bulb changes to 2237. The colorTemp value in the Indigo 7 app Device List updates and shows 2237. But the bulb_name.states['colorTemp'] value is still = 2967.
Here is the script I have been using:
- Code: Select all
#Script to get current state of light bulb device
import time
delay_margin = 5
bulb_name = indigo.devices[345799647]
#Initial values for color temp
color_temp_initial_var = 2237
indigo.server.log("Color Temperature Initial Variable is: " + str(color_temp_initial_var))
indigo.dimmer.setColorLevels(bulb_name, 100, 100, 100, 100, 0, int(color_temp_initial_var))
time.sleep(delay_margin)
indigo.server.log("Delay in seconds: " + str(delay_margin))
#Get Initial State Values
color_temp_state = bulb_name.states['colorTemp']
indigo.server.log("Color Temperature Device State is: " + str(color_temp_state))
time.sleep(delay_margin)
indigo.server.log("Delay: " + str(delay_margin))
#Set New values for color temp
color_temp_new_var = 6410
indigo.server.log("Variable Color Temperature is: " + str(color_temp_new_var))
indigo.dimmer.setColorLevels(bulb_name, 100, 100, 100, 100, 0, int(color_temp_new_var))
time.sleep(delay_margin)
indigo.server.log("Delay in seconds: " + str(delay_margin))
#Get New State Values
indigo.server.log("Color Temperature Device State is: " + str(color_temp_state))
time.sleep(delay_margin)
indigo.server.log("Delay in seconds: " + str(delay_margin))
#Set Back to Initial values for color temp
indigo.server.log("Variable Color Temperature Initial is: " + str(color_temp_initial_var))
indigo.dimmer.setColorLevels(bulb_name, 100, 100, 100, 100, 0, int(color_temp_initial_var))
time.sleep(delay_margin)
indigo.server.log("Delay in seconds: " + str(delay_margin))
#Get State Values for Initial color_temp variable
indigo.server.log("Color Temperature Device State is: " + str(color_temp_state))
indigo.server.log("Script Complete")
Here is the log output:
Action Group - Python Test 3
Script - Color Temperature Initial Variable is: 2237
Sent Hue Lights - "Lights - Office Table Lamp Left - Hue7C" on to 100 using color temperature 2237.0 K at ramp rate 0.5 sec.
Script - Delay in seconds: 5
Script - Color Temperature Device State is: 2967
Script - Delay: 5
Script - Variable Color Temperature is: 6410
Sent Hue Lights - "Lights - Office Table Lamp Left - Hue7C" on to 100 using color temperature 6410.0 K at ramp rate 0.5 sec.
Script - Delay in seconds: 5
Script - Color Temperature Device State is: 2967
Script - Delay in seconds: 5
Script - Variable Color Temperature Initial is: 2237
Sent Hue Lights - "Lights - Office Table Lamp Left - Hue7C" on to 100 using color temperature 2237.0 K at ramp rate 0.5 sec.
Script - Delay in seconds: 5
Script - Color Temperature Device State is: 2967
Script - Script Complete
Is there something else I need to do to get the correct device state of the colorTemp (or any of the values) after I change them in a python script? Thanks for any help.