This commit is contained in:
2015-04-27 00:54:16 +02:00
parent 5d650f14c4
commit 782c00e296
108 changed files with 1826 additions and 348 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ if __name__ == '__main__':
msg_body["color"]["type"] = "core/types/color/command"
msg_body["color"]["colormode"] = "hs"
# msg_body["color"]["set"] = [300]
msg_body["color"]["set"] = [1.0, 1.0]
msg_body["color"]["set"] = [0.5, 1.0]
msg_body["alert"] = dict()
msg_body["alert"]["type"] = "hue/huelight/command/alert"
@@ -33,7 +33,7 @@ class HueController(object):
self.cmd_topic = rospy.get_param('~cmd_topic', "/hos/devices/cmd")
self.hos_update_topic = rospy.get_param('~hos_update_topic', "/hos/status/updates")
self.loop_frequency = rospy.get_param('~loop_frequency', 100)
self.statusmsg_interval = rospy.get_param('~statusmsg_interval', 3000)
self.statusmsg_interval = rospy.get_param('~statusmsg_interval', 6000000)
self.bridge_ip = rospy.get_param('~bridge_ip', "192.168.168.90")
self.bridge_secret = rospy.get_param('~bridge_secret', "matzman666")
self.device_name_base = rospy.get_param('~device_name_base', "huelight")
@@ -204,6 +204,9 @@ class HueController(object):
light.light.setStateAttr("transitiontime", value["transitiontime"])
light.light.commitStateAttrs()
light.light.refreshAttrs()
stamp = rospy.get_rostime()
self.statusPublisher.publish(self.createStatusMsg(light.light, light.name, self.msg_sequence, stamp))
self.msg_sequence += 1
def deviceStatusCallback(self):
@@ -226,11 +229,31 @@ class HueController(object):
status_timer += 1
rate.sleep()
# Remove devices from device repository
del_devices = list()
for key in self.lights:
light = self.lights[key]
del_devices.append(light.name)
key_base = "/hos/devices/repository/" + light.name
print "Remove device " + light.name + " from repository"
rospy.delete_param(key_base)
updMsg = HosStatusUpdate()
stamp = rospy.get_rostime()
updMsg.stamp = stamp
updMsg.tags.append("devices")
updBody = dict()
updBody["type"] = "core/msgs/hosstatusupdate"
updBody["devices"] = dict()
updBody["devices"]["type"] = "core/msgs/hosstatusupdate/devices";
updBody["devices"]["removed"] = del_devices
msg_schema = self.schemaProvider.getTypeSchema("core/msgs/hosstatusupdate")
validator = load(msg_schema, provider=self.schemaProvider)
validator.validate(updBody)
updMsg.msg_body = json.dumps(updBody)
sleep(1) # Apparently we need to wait before we can send messages
self.hosUpdatePublisher.publish(updMsg)
sleep(2)