This is used only if websocket fails

def toggle_sensor(request, sensorname):
    """
    This is used only if websocket fails
    """
    if service.read_only:
        service.logger.warning("Could not perform operation: read only mode enabled")
        raise Http404
    source = request.GET.get('source', 'main')
    sensor = service.system.namespace[sensorname]
    sensor.status = not sensor.status
    service.system.flush()
    return HttpResponseRedirect(reverse(source))