Cool. I've been studying your Python, even before this latest update. I think it's great that you are both providing the "raw" states, and this new "human-friendly" state. Someone not python-savvy (and even those who
are "literate") will appreciate your efforts in providing a single, meaningful status statement. And for geeks like me, I can use that, and also enhance my interface by using the other states.
For example, I'm displaying your new state in my interface, and right below that I display my own version. It goes a bit more into detail (like when the base is emptying the bin), and also tracks which of my missions just ran. Helpful because my old brain was forgetting which part of my house was just vacuumed!
So I think you've got the best-of-both in the choices you made in what states to reveal, and how you reveal them.
I've been watching what the iRobot app reports at the same time I watch what your plug-in reports. So, for example, one of my notifications translates the ominous "undocumented #39" into "Saving clean map..." I have another for #68. My notifications were somewhat inspired by how the app reports various states.
Some of my efforts are now redundant, since you enhanced your statements. No matter. I'm just geeking in my usual way. (HA is a hobby for me.)
Here's what I've been doing, if it's of interest to you. Like your efforts, it's a work in progress. "roomba_message" is the variable I use to elaborate on your statements. "roomba_mission" is the variable I use to track which vac job I last initiated. It contains the name of a room or area. This code is triggered whenever either of a couple of your states change.
- Code: Select all
from datetime import datetime
vRoombaMissionStarted = (indigo.devices[765723352].states["MissionStarted"]) # "Roomba"
vRoombaRechargeFinish = (indigo.devices[765723352].states["RechargeFinish"]) # "Roomba"
vRoombaRechargeM = (indigo.devices[765723352].states["RechargeM"]) # "Roomba"
vRoombaNotReadyText = (indigo.devices[765723352].states["NotReadyText"]) # "Roomba"
vRoombaDeviceStatus = (indigo.devices[765723352].states["deviceStatus"]) # "Roomba"
vRoombaMission = (indigo.variables[1281672395].value) # "roomba_mission"
if unicode(vRoombaRechargeFinish) != '':
try:
datetime_object = datetime.strptime(vRoombaRechargeFinish, '%a %b %d %H:%M:%S %Y')
vAmPmTime = datetime_object.strftime('%-I:%M:%S%p')
indigo.variable.updateValue(1719512708, value='Will resume at ' + unicode(vAmPmTime).lower()) # "roomba_message"
except:
indigo.server.log('Trigger "Roomba Messages" script error', type="Trigger Script", isError=True)
elif unicode(vRoombaDeviceStatus) == 'Battery Low':
indigo.variable.updateValue(1719512708, value='Battery low') # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'End Mission':
indigo.variable.updateValue(1719512708, value='Returning home...') # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Returning to Base':
indigo.variable.updateValue(1719512708, value='Returning to base...') # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Emptying':
indigo.variable.updateValue(1719512708, value='Emptying bin...') # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Cancelled':
indigo.variable.updateValue(1719512708, value='Cancelled...') # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Stopped':
indigo.variable.updateValue(1719512708, value='Stopped') # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'User Docking':
indigo.variable.updateValue(1719512708, value='User docking...') # "roomba_message"
elif "39" in unicode(vRoombaDeviceStatus):
indigo.variable.updateValue(1719512708, value='Saving clean map...') # "roomba_message"
elif "68" in unicode(vRoombaDeviceStatus):
indigo.variable.updateValue(1719512708, value='Saving smart map edits...') # "roomba_message"
elif unicode(vRoombaDeviceStatus) == 'Charging':
indigo.variable.updateValue(1719512708, value='Ready (Last: ' + vRoombaMission + ')') # "roomba_message"
elif unicode(vRoombaMissionStarted) != '':
try:
datetime_object = datetime.strptime(vRoombaMissionStarted, '%a %b %d %H:%M:%S %Y')
vAmPmTime = datetime_object.strftime('%-I:%M%p')
indigo.variable.updateValue(1719512708, value='Vacuuming ' + vRoombaMission + ' at ' + unicode(vAmPmTime).lower()) # "roomba_message"
except:
indigo.server.log('Trigger "Roomba Messages" script error', type="Trigger Script", isError=True)
else:
if vRoombaNotReadyText == "Ready":
indigo.variable.updateValue(1719512708, value='Ready (Last: ' + vRoombaMission + ')') # "roomba_message"
else:
indigo.variable.updateValue(1719512708, value='Not ready...') # "roomba_message"