autolog wrote:- Code: Select all
if radiatorsCallingForHeatNumber > 0:
if str(indigo.devices[boiler_id].hvacMode) == "Off": # Only turn boiler 'on' if it is currently 'off'
indigo.thermostat.setHvacMode(boiler_id, value=indigo.kHvacMode.Heat) # Turn boiler 'on'
else:
if not str(indigo.devices[boiler_id].hvacMode) == "Off": # Only turn boiler 'off' if it is currently 'on'
indigo.thermostat.setHvacMode(boiler_id, value=indigo.kHvacMode.Off) # Turn boiler 'off'
No need to convert to strings, just compare directly to the constants defined in the API:
- Code: Select all
if radiatorsCallingForHeatNumber > 0:
if indigo.devices[boiler_id].hvacMode == indigo.kHvacMode.Off: # Only turn boiler 'on' if it is currently 'off'
indigo.thermostat.setHvacMode(boiler_id, value=indigo.kHvacMode.Heat) # Turn boiler 'on'
else:
if not indigo.devices[boiler_id].hvacMode == indigo.kHvacMode.Heat: # Only turn boiler 'off' if it is currently 'on'
indigo.thermostat.setHvacMode(boiler_id, value=indigo.kHvacMode.Off) # Turn boiler 'off'
Using the constants rather than the string representation is future proof: if for some reason we change the underlying value for any constant it won't matter to your script since you're using the constant directly rather than the value it represents. Of course, you don't really need the comparison at all - just turn it heat/off. If it's already on HEAT then setting it again is a noop.
autolog wrote:1. It would be nice to generalise the script so that one script would handle all radiators. If it was possible to derive the id of the triggering device then that might do it as I could then work out (possibly) what the name of the associated variable was.
There is currently no information passed to the actions about what caused the action to fire. It's something we eventually want to add but it will require a rather large effort to add it so it won't happen in the short-term.
autolog wrote:2. I want to be able to set a 5 minute delay on starting the boiler as the radiator thermostat only wakes up every 5 minutes and I don't want the boiler on before the radiator is ready (I don't mind the radiator waiting for heat if it is on early). Looking in the device class documentation, it doesn't look like you can add a delay on a thermostat device? I can't use the global trigger delay as I want it to turn off immediately.
As a specific implementation you could probably use a Timer device, though I'm not following exactly what you're describing.
autolog wrote:3. Is it feasible to have this script run as a file so that I don't have to duplicate it in multiple triggers. As I see it at the moment, I have to setup two triggers for each of my 12 radiators (one for Heat Setpoint change and one for Temperature change. So I will end up with 24 triggers altogether. I looking to minimise the work, reduce the chance of error and KISS
Running the script as a file is simple. Having it replace all your triggers is a separate exercise which could be done. It would require that the script "poll" the status of each thermostat periodically, determining if they want the boiler on, then turning the boiler on/off depending on the result. You have the last part, you'd need to add the previous 2 parts. If you designed your python script as a stay-open script which just ran in an infinite loop (started by, say, a startup trigger), then each time through the loop it would do the temp vs setpoint check and turn the boiler on/off as needed.
It occurs to me, however, that building a plugin might be a better solution. Basically, what you'd do is build a plugin that allows you to map radiator thermostats to boilers. This could be done in the plugin's config dialog. So, you'd specify Thermostats 1-5 map to boiler A and Thermostats 6-10 map to boiler B (in your case, they all would map to boiler A). Then the plugin would subscribe to any change of Thermostats 1-10. Each time a thermostat change came in, you would determine which (if any) boiler needed to be active and would turn it on/off as necessary. So the plugin wouldn't actually create any new devices, events, or actions: all it would do is watch for thermostats to change and when the conditions were met it would kick on the boiler (or turn it off as necessary).
Interesting idea for a plugin - one that doesn't actually present any devices, events, or actions, but it still quite functional. I suppose you could create a device for each boiler and then add the thermostats to that device. Not sure if there's a reason to do that though since the boiler already has an Indigo device associated with it. But, in any event, an interesting idea.