Commit 11b65f05 authored by Harald Klein's avatar Harald Klein

Merge branch 'develop' into 'qpid-removal'

# Conflicts:
#   devices/MySensors/agoMySensors.cpp
parents f62e7262 937c7d38
Pipeline #382 failed with stage
in 1 minute
......@@ -72,7 +72,7 @@ function Applications(agocontrol)
method : "GET",
async : true,
}).done(function(result) {
if( !result || !result.result || result.result===0 )
if( !result || result.error.length>0 )
{
//revert changes
$(el).bootstrapSwitch('toggleState', true);
......
......@@ -16,7 +16,7 @@ import json
import os
import re
UI_DIR = os.path.join(agoclient.CONFDIR, '/ui')
UI_DIR = os.path.join(agoclient.CONFDIR, 'ui')
def loadFile(f):
content = {}
......
......@@ -257,7 +257,7 @@ function device(agocontrol, obj, uuid) {
//update cover first only if album is different
if( infos.cover && this.album()!=infos.album )
{
this.cover('data:image/jpeg;base64,'+infos.cover);
this.cover('data:image/jpeg;base64,' + infos.cover);
}
//update other infos
......@@ -317,7 +317,7 @@ function device(agocontrol, obj, uuid) {
content.command = 'mediainfos';
self.agocontrol.sendCommand(content)
.then(function(resp) {
self.updateMediaInfos(resp);
self.updateMediaInfos(resp.data);
});
};
this.requestMediaInfos();
......
This diff is collapsed.
......@@ -51,21 +51,9 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
if( res.result.error==0 )
{
notif.success('#sp');
}
else
{
//error occured
notif.error(res.result.msg);
}
}
else
{
notif.fatal('#nr', 0);
notif.success('#sp');
}
});
};
......@@ -79,14 +67,10 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
self.port(res.result.port);
}
else
{
notif.fatal('#nr', 0);
}
});
};
......@@ -101,14 +85,10 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
notif.success('#rc');
}
else
{
notif.fatal('#nr', 0);
}
});
}
};
......@@ -125,14 +105,10 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
notif.success('#rc');
}
else
{
notif.fatal('#nr', 0);
}
});
}
};
......@@ -146,14 +122,10 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
self.devices(res.result.devices);
}
else
{
notif.fatal('#nr', 0);
}
});
};
......@@ -169,24 +141,13 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
if( res.result.error==0 )
{
notif.success('#ds');
//refresh devices list
self.getDevices();
self.getCounters();
}
else
{
//error occured
notif.error(res.result.msg);
}
}
else
{
notif.fatal('#nr', 0);
notif.success('#ds');
//refresh devices list
self.getDevices();
self.getCounters();
}
});
}
......@@ -202,17 +163,13 @@ function MySensors(devices, agocontrol)
self.agocontrol.sendCommand(content, function(res)
{
var counters = [];
if( res!==undefined && res.result!==undefined && res.result!=='no-reply')
if( !res.error )
{
for( device in res.result.counters )
{
counters.push(res.result.counters[device]);
}
}
else
{
notif.fatal('#nr', 0);
}
self.counters(counters);
});
};
......
......@@ -996,8 +996,7 @@ Json::Value AgoMySensors::commandHandler(const Json::Value& content)
setDeviceInfos(device["internalid"].asString(), infos);
}
}
returnval["error"] = 0;
returnval["msg"] = "";
errorMessage = "";
}
else
{
......@@ -1091,8 +1090,7 @@ Json::Value AgoMySensors::commandHandler(const Json::Value& content)
else
{
//invalid command format
returnval["error"] = 6;
returnval["msg"] = "Invalid command received";
errorMessage = "Invalid command received";
}
}
else
......@@ -1295,7 +1293,13 @@ Json::Value AgoMySensors::commandHandler(const Json::Value& content)
returnval["msg"] = "Unhandled internalid";
}
}
return returnval;
if( errorMessage.length()>0 )
{
return responseFailed(errorMessage);
}
return responseSuccess(returnval);
}
/**
......
This diff is collapsed.
......@@ -49,6 +49,7 @@ class Ipx800v3Telnet(threading.Thread):
"""
threading.Thread.__init__(self)
self.logger = logging.getLogger('Ipx800v3Telnet')
self.logger.setLevel(logging.INFO)
self.ip = ip
self.port = port
self.__callback = callback
......@@ -209,7 +210,7 @@ class Ipx800v3(threading.Thread):
OUTPUT_SETPULSE = 'http://%s/leds.cgi?'
OUTPUT_SETNOPULSE = 'http://%s/preset.htm?'
OUTPUT_CONFIGURE = 'http://%s/protect/settings/output1.htm?'
COUNTER_SET = 'http://%s/protect/assignio/counter.htm?'
COUNTER_SET = 'http://%s/protect/assignio/counter1.htm?'
PINGWATCHDOG = 'http://%s/protect/settings/ping.htm?'
STATUS = 'http://%s/status.xml'
......@@ -357,10 +358,10 @@ class Ipx800v3(threading.Thread):
"""
try:
url += urllib.urlencode(params)
self.logger.info(url)
req = urllib2.urlopen(url)
lines = req.readlines()
req.close()
self.logger.debug(url)
#self.logger.debug('\n'.join(lines))
return True, lines
except Exception as e:
......@@ -621,7 +622,7 @@ class Ipx800v3(threading.Thread):
return self.__sendUrl(url, params)
"""----------COUNTERS----------"""
def setCounter(self, ipx, counterId, value, name='counter'):
def setCounter(self, ipx, counterId, value, name=None):
"""
Set counter value and/or name
@info: /!\ name if mandatory otherwise command doesn't work :S
......@@ -646,9 +647,12 @@ class Ipx800v3(threading.Thread):
#prepare and send url
url = Ipx800v3.COUNTER_SET % (ipx)
params = {'counter%d'%counterId:value}
params = {
'num': counterId,
'counter': value
}
if name and len(name)>0:
params['countername%d'%counterId] = name.strip()
params['cname'] = name.strip()
return self.__sendUrl(url, params)
"""----------PING----------"""
......
......@@ -199,94 +199,108 @@ def messageHandler(internalid, content):
#check parameters
if not content.has_key("command"):
logging.error('No command specified in content')
return None
return client.response_unknown_command(message='No command specified')
if internalid==host:
#server command
if content["command"]=="allon":
logging.info("Command ALLON: %s" % internalid)
for player in getPlayers():
player.on()
return True
return client.response_success()
elif content["command"]=="alloff":
logging.info("Command ALLOFF: %s" % internalid)
for player in getPlayers():
player.off()
return True
return client.response_success()
elif content["command"]=="displaymessage":
if content.has_key('line1') and content.has_key('line2') and content.has_key('duration'):
logging.info("Command DISPLAYMESSAGE: %s" % internalid)
for player in getPlayers():
player.display(content['line1'], content['line2'], content['duration'])
return True
return client.response_success()
else:
logging.error('Missing parameters to command DISPLAYMESSAGE')
return False
return client.response_missing_parameters(data={'command': 'displaymessage', 'params': ['line1', 'line2', 'duration']})
#unhandled command
logging.warn('Unhandled server command')
return False
return client.response_unknown_command(message='Unhandled server command', data=content["command"])
else:
#player command
#get player
player = getPlayer(internalid)
logging.info('Found player: %s' % player)
if not player:
logging.error('Player %s not found!' % internalid)
return False
return client.response_failed('Player "%s" not found!' % internalid)
if content["command"] == "on":
logging.info("Command ON: %s" % internalid)
player.on()
return True
return client.response_success()
elif content["command"] == "off":
logging.info("Command OFF: %s" % internalid)
player.off()
return True
return client.response_success()
elif content["command"] == "play":
logging.info("Command PLAY: %s" % internalid)
player.play()
return True
return client.response_success()
elif content["command"] == "pause":
logging.info("Command PAUSE: %s" % internalid)
player.pause()
return True
return client.response_success()
elif content["command"] == "stop":
logging.info("Command STOP: %s" % internalid)
player.stop()
return True
return client.response_success()
elif content["command"] == "next":
logging.info("Command NEXT: %s" % internalid)
player.next()
return True
return client.response_success()
elif content["command"] == "previous":
logging.info("Command PREVIOUS: %s" % internalid)
player.prev()
return True
return client.response_success()
elif content["command"] == "setvolume":
logging.info("Command SETVOLUME: %s" % internalid)
if content.has_key('volume'):
player.set_volume(content['volume'])
return True
return client.response_success()
else:
logging.error('Missing parameter "volume" to command SETVOLUME')
return False
return client.response_missing_parameters(data={'command': 'setvolume', 'params': ['volume']})
elif content["command"] == "displaymessage":
if content.has_key('line1') and content.has_key('line2') and content.has_key('duration'):
logging.info("Command DISPLAYMESSAGE: %s" % internalid)
player.display(content['line1'], content['line2'], content['duration'])
return True
return client.response_success()
else:
logging.error('Missing parameters to command DISPLAYMESSAGE')
return False
return client.response_missing_parameters(data={'command': 'displaymessage', 'params': ['line1', 'line2', 'duration']})
elif content["command"] == "mediainfos":
infos = get_media_infos(internalid, None)
logging.info(infos)
return infos
return client.response_success(infos)
#unhandled device command
logging.warn('Unhandled device command')
return False
return client.response_unknown_command(message='Unhandled device command', data=content["command"])
#init
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment